Changeset 5699
- Timestamp:
- 11/17/08 15:21:13 (2 months ago)
- Files:
-
- branches/1.1/turbogears/view/base.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/turbogears/view/base.py
r5692 r5699 28 28 29 29 def _choose_engine(template): 30 """a private method to parse template name from the 31 expose template argument. If the @expose decorator did not contain 32 a template argument, we fetch the default engine info from the 33 configuration file. 34 35 @param template: a template string as seen in the expose decorator. 36 This can be "kid:myproj.templates.welcome" or just 37 "myproj.templates.welcome". 38 If a colon is found, then we try to get the engine name from the 39 template string. Else we try to search it from the default engine in 40 the configuration file. 41 @type template: basestring or None 42 """ 30 43 if isinstance(template, basestring): 44 # if a template arg was given we try to find the engine declaration 45 # in it by 31 46 colon = template.find(":") 32 47 if colon > -1: 33 48 enginename = template[:colon] 34 49 template = template[colon+1:] 50 35 51 else: 36 52 engine = engines.get(template, None) … … 38 54 return engine, None, template 39 55 enginename = config.get("tg.defaultview", "kid") 56 40 57 else: 41 58 enginename = config.get("tg.defaultview", "kid") 59 42 60 engine = engines.get(enginename, None) 61 43 62 if not engine: 44 63 raise KeyError, \ 45 64 "Template engine %s is not installed" % enginename 65 46 66 return engine, template, enginename 47 67 … … 73 93 template = format == 'json' and 'json' or info.pop( 74 94 "tg_template", template) 95 75 96 if not info.has_key("tg_flash"): 76 97 if config.get("tg.empty_flash", True): 77 98 info["tg_flash"] = None 99 78 100 engine, template, enginename = _choose_engine(template) 101 79 102 if format: 80 103 if format == 'plain': 81 104 if enginename == 'genshi': 82 105 format = 'text' 106 83 107 elif format == 'text': 84 108 if enginename == 'kid': 85 109 format = 'plain' 110 86 111 else: 87 112 format = enginename == 'json' and 'json' or config.get(