本文整理汇总了Python中trac.web.chrome.Chrome.get_all_templates_dirs方法的典型用法代码示例。如果您正苦于以下问题:Python Chrome.get_all_templates_dirs方法的具体用法?Python Chrome.get_all_templates_dirs怎么用?Python Chrome.get_all_templates_dirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.web.chrome.Chrome
的用法示例。
在下文中一共展示了Chrome.get_all_templates_dirs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_diffs
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import get_all_templates_dirs [as 别名]
def get_diffs(self, req, title, old_text, new_text):
diff_style, diff_options, diff_data = get_diff_options(req)
diff_context = 3
for option in diff_options:
if option.startswith('-U'):
diff_context = int(option[2:])
break
if diff_context < 0:
diff_context = None
diffs = diff_blocks(old_text.splitlines(), new_text.splitlines(), context=diff_context,
tabwidth=2,
ignore_blank_lines=True,
ignore_case=True,
ignore_space_changes=True)
chrome = Chrome(self.env)
loader = TemplateLoader(chrome.get_all_templates_dirs())
tmpl = loader.load('diff_div.html')
changes=[{'diffs': diffs, 'props': [],
'title': title,
'new': {'path':"", 'rev':'', 'shortrev': '', 'href':''},
'old': {'path':"", 'rev':'', 'shortrev': '', 'href': ''}}]
data = chrome.populate_data(req,
{ 'changes':changes , 'no_id':True, 'diff':diff_data,
'longcol': '', 'shortcol': ''})
diff_data['style']='sidebyside';
data.update({ 'changes':changes , 'no_id':True, 'diff':diff_data,
'longcol': '', 'shortcol': ''})
stream = tmpl.generate(**data)
return stream.render()
示例2: _render
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import get_all_templates_dirs [as 别名]
def _render(self, data, template):
c = Chrome(self.env)
self.stantheman.template_dirs = c.get_all_templates_dirs()
return self.stantheman.render(data, template=template)
示例3: test_templates_dirs
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import get_all_templates_dirs [as 别名]
def test_templates_dirs(self):
chrome = Chrome(self.env)
self.assertFalse(self.env.is_component_enabled(DashboardModule))
for dir in self.bhtheme.get_templates_dirs():
self.assertIn(dir, chrome.get_all_templates_dirs())
示例4: dispatch
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import get_all_templates_dirs [as 别名]
def dispatch(self, req):
"""Find a registered handler that matches the request and let it process
it.
In addition, this method initializes the HDF data set and adds the web
site chrome.
"""
# FIXME: For backwards compatibility, should be removed in 0.11
self.env.href = req.href
# FIXME in 0.11: self.env.abs_href = Href(self.env.base_url)
self.env.abs_href = req.abs_href
# Select the component that should handle the request
chosen_handler = None
early_error = None
req.authname = 'anonymous'
req.perm = NoPermissionCache()
try:
if not req.path_info or req.path_info == '/':
chosen_handler = self.default_handler
else:
for handler in self.handlers:
if handler.match_request(req):
chosen_handler = handler
break
# Attach user information to the request early, so that
# the IRequestFilter can see it while preprocessing
if not getattr(chosen_handler, 'anonymous_request', False):
try:
req.authname = self.authenticate(req)
req.perm = PermissionCache(self.env, req.authname)
req.session = Session(self.env, req)
req.form_token = self._get_form_token(req)
except:
req.authname = 'anonymous'
req.perm = NoPermissionCache()
early_error = sys.exc_info()
chosen_handler = self._pre_process_request(req, chosen_handler)
except:
early_error = sys.exc_info()
if not chosen_handler and not early_error:
early_error = (HTTPNotFound(u'Aucun composant ne peut gérer la '
u'requète %s', req.path_info),
None, None)
# Prepare HDF for the clearsilver template
try:
use_template = getattr(chosen_handler, 'use_template', True)
req.hdf = None
if use_template:
chrome = Chrome(self.env)
req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs())
populate_hdf(req.hdf, self.env, req)
chrome.populate_hdf(req, chosen_handler)
except:
req.hdf = None # revert to sending plaintext error
if not early_error:
raise
if early_error:
try:
self._post_process_request(req)
except Exception, e:
self.log.exception(e)
raise early_error[0], early_error[1], early_error[2]