本文整理汇总了Python中pyramid.renderers.get_renderer函数的典型用法代码示例。如果您正苦于以下问题:Python get_renderer函数的具体用法?Python get_renderer怎么用?Python get_renderer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_renderer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_base_template
def add_base_template(event):
main = get_renderer('templates/main.pt').implementation()
generic_macros = get_renderer('templates/macro/generic_macros.pt').implementation()
base_search = get_renderer('templates/base/search.pt').implementation()
event.update({'main': main})
event.update({'generic_macros': generic_macros})
event.update({'base_search': base_search})
示例2: add_renderer
def add_renderer(self, delivery_format, renderer_name):
"""
Adds a matching to the render proxy's matching dict. It is possible to overwrite an existing one. If you do, a
notice (warning) is printed to your server logs.
:param delivery_format: The format string to which the renderer should be bound to (e.g. "json", "xml", ...)
:type delivery_format: str
:param renderer_name: The name of the renderer which was used to assign it to the pyramid applications
configuration.
:type renderer_name: str
:raises: ConfigurationError
"""
try:
get_renderer(renderer_name)
self._format_to_renderer[delivery_format] = renderer_name
log.warning('You overwrite the renderer for the "{format_name}" format'.format(format_name=delivery_format))
except ValueError, e:
text = 'Adding mapping from format "{format_name}" to renderer "{renderer_name}" could not be completed. ' \
'The renderer "{renderer_name}" does not exist. Original error was: {error_txt}'.format(
format_name=delivery_format,
renderer_name=renderer_name,
error_txt=e
)
log.warning(text)
raise ConfigurationError()
示例3: get_document
def get_document(context, request):
path = request.path.split('/')
if path[-1] == 'edit':
docid = path[-2]
doc = IDatabase(context).get_document(docid)
return render_to_response(
"templates/editdocument.pt",
{
'title': doc.title,
'body': doc.display(edit=True),
'save_url': doc.url + '/save',
'formid': doc.form.id,
'master': get_renderer('templates/master.pt').implementation(),
},
request)
elif path[-1] == 'save':
docid = path[-2]
doc = IDatabase(context).get_document(docid)
doc.save(request.params)
return HTTPFound(
location=doc.url
)
else:
docid = path[-1]
doc = IDatabase(context).get_document(docid)
return render_to_response(
"templates/opendocument.pt",
{
'title': doc.title,
'body': doc.display(),
'master': get_renderer('templates/master.pt').implementation(),
},
request)
示例4: add_base_template
def add_base_template(event):
"""Add base templates.
"""
main = get_renderer('templates/indexLTE.pt').implementation()
test = get_renderer('templates/main.pt').implementation()
email_main = get_renderer('templates/email/main.pt').implementation()
event.update({'main': main, 'test': test, 'email_main': email_main})
示例5: swordfish
def swordfish(context,request):
logged_in = authenticated_userid(request)
main = get_renderer('../templates/register.pt').implementation()
if not 'god' in context:
context["god"] = User("god", hashlib.sha1("eden".encode('UTF-8')).digest(), 777777, firstName = "Jesus", lastName = "Christ", email = "[email protected]", phone = "777-777-7707", gradYear = 2013, inductionYear = 0, isofficer=True, isadvisor=True); context["god"].__parent__ = context
return {'red':'','main':get_renderer('../templates/register.pt').implementation(),'content':'And on the eighth day, Man created God','logged_in':authenticated_userid(request),'name':'Apotheosis Sucessful (:'}
return {'red':'','main':get_renderer('../templates/register.pt').implementation(),'content':'You already have a God','logged_in':authenticated_userid(request),'name':'Apotheosis Failed D:'}
示例6: site_layout
def site_layout(level):
if level == 'min':
renderer = get_renderer("arsenalweb:templates/min_layout.pt")
else:
renderer = get_renderer("arsenalweb:templates/global_layout.pt")
layout = renderer.implementation().macros['layout']
return layout
示例7: patient_list_view
def patient_list_view(request):
# get other templates that will be included via macros
footer = get_renderer('../templates/va-footer.pt').implementation()
logo = get_renderer('../templates/va-logo.pt').implementation()
nav = get_renderer('../templates/va-navigation.pt').implementation()
patientidentification = get_renderer('../templates/patient-identification.pt').implementation()
return {'project': 'mmpspupc', 'footer': footer, 'logo': logo, 'nav': nav, 'patientidentification': patientidentification}
示例8: edit_group
def edit_group(context, request):
if 'id' in request.matchdict:
try:
group = DBSession().query(Group).get(request.matchdict.get('id'))
is_new = False
except SQLAlchemyError:
raise HTTPNotFound
if not group:
raise HTTPNotFound
else:
group = Group()
is_new = True
schema = GroupSchema(after_bind=maybe_remove_fields).bind(request=request, group=group)
form = deform.Form(schema, buttons=('zapisz', 'anuluj'), css_class=u'form-horizontal', requirements = ( ('bootstrap', None), ))
js.deform.auto_need(form)
if request.POST:
if not 'zapisz' in request.POST:
return HTTPFound(location='/groups/only_mine')
items = request.POST.items()
try:
appstruct = form.validate(items)
except deform.ValidationFailure, e:
return {'form': e.render(),
'group_nav': get_renderer('templates/group_macros.pt').implementation(),
'group': group,
'main': get_renderer('templates/master.pt').implementation()}
if 'activation_code' in request.POST:
group.state = u'aktywna'
request.session.flash({'title': u'Gotowe!',
'body': u'Grupa %s została aktywowana.' % group.name},
queue='success')
return HTTPFound(location='/groups/%s' % group.id)
if appstruct['logo']:
logo = File()
logo.filename = appstruct['logo']['filename']
logo.mimetype = appstruct['logo']['mimetype']
appstruct['logo']['fp'].seek(0)
logo.data = appstruct['logo']['fp'].read()
appstruct['logo']['fp'].seek(0,2)
logo.size = appstruct['logo']['fp'].tell()
appstruct['logo']['fp'].close()
appstruct['logo'] = logo
group = merge_session_with_post(group, appstruct)
session = DBSession()
session.add(group)
if is_new:
group.add_member(request.user, 'owner')
request.session.flash({'title': u'Gotowe!',
'body': u'Grupa %s została stworzona.' % group.name},
queue='success')
else:
request.session.flash({'title': u'Gotowe!',
'body': u'Grupa %s została zaktualizowana.' % group.name},
queue='success')
return HTTPFound(location='/groups/only_mine')
示例9: bridal_party
def bridal_party(request):
if (request.host.startswith('localhost') or
request.host.startswith('suralka')):
bridal_party_renderer = 'templates/surag_bridal_party.pt'
main = get_renderer('templates/surag_index.pt').implementation()
else:
bridal_party_renderer = 'templates/bridal_party2.pt'
main = get_renderer('templates/index.pt').implementation()
args = {'main': main}
return render_to_response(bridal_party_renderer, args, request=request)
示例10: add_base_template
def add_base_template(event):
"""
Expose the base template as per the Pyramid cookbook:
https://docs.pylonsproject.org/projects/pyramid_cookbook/dev/templates.html#using-a-beforerender-event-to-expose-chameleon-base-template
"""
base = get_renderer('templates/base.pt').implementation()
event.update({'base': base})
base = get_renderer('templates/base_bare.pt').implementation()
event.update({'basebare': base})
示例11: our_story
def our_story(request):
if (request.host.startswith('localhost') or
request.host.startswith('suralka')):
story_renderer = 'templates/surag_our_story.pt'
main = get_renderer('templates/surag_index.pt').implementation()
else:
story_renderer = 'templates/our_story.pt'
main = get_renderer('templates/index.pt').implementation()
args = {'main': main}
return render_to_response(story_renderer, args, request=request)
示例12: __init__
def __init__(self, request):
self.request = request
self.context = request.context
self.site = find_root(request.context)
## FIXME: could be reified (?)
self.admin_layout = get_renderer(
'petrel:templates/admin_layout.pt').implementation()
self.admin_toolbar = get_renderer(
'petrel:templates/toolbar.pt').implementation().macros['toolbar']
self.context_url = request.resource_url(request.context)
self.user_md = get_user_metadata(self.request)
示例13: __init__
def __init__(self, context, request):
self.context = context
self.request = request
renderer = get_renderer("../../../templates/layout.pt")
self.layout = renderer.implementation().macros['layout']
renderer = get_renderer("../../../templates/main.pt")
self.main = renderer.implementation().macros['main']
renderer = get_renderer("../../../templates/pbbd/nav.pt")
self.nav = renderer.implementation().macros['nav']
示例14: add_templates
def add_templates(event):
base = get_renderer('templates/base.pt').implementation()
frontend = get_renderer('templates/frontend.pt').implementation()
backend = get_renderer('templates/backend.pt').implementation()
macros = get_renderer('templates/macros.pt').implementation()
event.update({
'base': base,
'frontend': frontend,
'backend': backend,
'm': macros
})
示例15: __init__
def __init__(self, context, request):
self.context = context
self.request = request
self.response = dict(
api = self,
form_resources = {},
main_tpl_macro = get_renderer('templates/main.pt').implementation().macros['master'],
view_content_tpl_macro = get_renderer('templates/view.pt').implementation().macros['view'],
resource_url = resource_url,
)
progress_main_css.need()