本文整理汇总了Python中repoze.bfg.chameleon_zpt.get_template函数的典型用法代码示例。如果您正苦于以下问题:Python get_template函数的具体用法?Python get_template怎么用?Python get_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: receive
def receive(context,request):
logging.debug("Receiving Katz...")
post = request.POST
logged_in = authenticated_userid(request)
accounts = context['accounts']
errors={}
message = ''
master = get_template('templates/master.pt')
if post.has_key('amount'):
source = post.get('source','')
amount = post.get('amount','')
target = accounts.get(logged_in)
logging.debug("Source: %s Amount: %s Target: %s",source,amount,target)
#errors = context['transactions'].isTransactionInvalid(source,logged_in,amount)
if str(post.get('pin','')) != str(target.password):
logging.error("views.py::receive Invalid pin")
errors['pin'] = 'invalid pin'
try:
tacc = accounts.get(logged_in)
sacc = accounts.get(source)
sacc.transfer(logged_in,amount)
return rtr('templates/paid.pt',context=context,request=request,master=master,logged_in=logged_in,source=sacc,target=tacc,amount=amount,message=message)
except Errors, e:
errors.update(e.message)
if errors:
message= 'please correct the errors'
开发者ID:stephenbee,项目名称:lqn-demo,代码行数:28,代码来源:views.py
示例2: _send_invitation_email
def _send_invitation_email(request, community, community_href, invitation):
mailer = getUtility(IMailDelivery)
info = _get_common_email_info(community, community_href)
subject_fmt = 'Please join the %s community at %s'
info['subject'] = subject_fmt % (info['c_title'],
info['system_name'])
body_template = get_template('templates/email_invite_new.pt')
msg = Message()
msg['From'] = info['mfrom']
msg['To'] = invitation.email
msg['Subject'] = info['subject']
body = body_template(
system_name=info['system_name'],
community_href=info['c_href'],
community_name=info['c_title'],
community_description=info['c_description'],
personal_message=invitation.message,
invitation_url=model_url(invitation.__parent__, request,
invitation.__name__)
)
if isinstance(body, unicode):
body = body.encode("UTF-8")
msg.set_payload(body, "UTF-8")
msg.set_type('text/html')
mailer.send([invitation.email,], msg)
开发者ID:cguardia,项目名称:karl,代码行数:28,代码来源:members.py
示例3: _send_signup_ai_email
def _send_signup_ai_email(request, username, profile):
"""Send email to user who has signed up to site.
"""
info = {}
info['system_name'] = get_setting(profile, 'system_name', 'OpenCore')
info['system_email_domain'] = get_setting(profile, 'system_email_domain')
info['from_name'] = '%s invitation' % info['system_name']
info['from_email'] = '[email protected]%s' % info['system_email_domain']
info['c_title'] = info['system_name']
info['c_description'] = ""
info['c_href'] = request.api.app_url
info['mfrom'] = '%s <%s>' % (info['from_name'], info['from_email'])
info['subject'] = 'Thank you for joining the %s community' % info['system_name']
body_template = get_template('templates/email_accept_signup_invitation.pt')
mailer = getUtility(IMailDelivery)
msg = Message()
msg['From'] = info['mfrom']
msg['To'] = profile.email
msg['Subject'] = info['subject']
body = body_template(
system_name=info['system_name'],
system_href=info['c_href'],
username=username,
)
if isinstance(body, unicode):
body = body.encode("UTF-8")
msg.set_payload(body, "UTF-8")
msg.set_type('text/html')
mailer.send(info['mfrom'], [profile.email,], msg)
开发者ID:amarandon,项目名称:opencore,代码行数:33,代码来源:members.py
示例4: _send_aeu_emails
def _send_aeu_emails(community, community_href, profiles, text):
# To make reading the add_existing_user_view easier, move the mail
# delivery part here.
info = _get_common_email_info(community, community_href)
subject_fmt = 'You have been added to the %s community'
subject = subject_fmt % info['c_title']
body_template = get_template('templates/email_add_existing.pt')
html_body = text
mailer = getUtility(IMailDelivery)
for profile in profiles:
to_email = profile.email
msg = Message()
msg['From'] = info['mfrom']
msg['To'] = to_email
msg['Subject'] = subject
body = body_template(
system_name=info['system_name'],
community_href=info['c_href'],
community_name=info['c_title'],
community_description=info['c_description'],
personal_message=html_body,
)
if isinstance(body, unicode):
body = body.encode("UTF-8")
msg.set_payload(body, "UTF-8")
msg.set_type('text/html')
mailer.send([to_email,], msg)
开发者ID:cguardia,项目名称:karl,代码行数:32,代码来源:members.py
示例5: _send_ai_email
def _send_ai_email(community, community_href, username, profile):
"""Send email to user who has accepted a community invitation.
"""
info = _get_common_email_info(community, community_href)
subject_fmt = 'Thank you for joining the %s community'
subject = subject_fmt % info['c_title']
body_template = get_template('templates/email_accept_invitation.pt')
mailer = getUtility(IMailDelivery)
msg = Message()
msg['From'] = info['mfrom']
msg['To'] = profile.email
msg['Subject'] = subject
body = body_template(
community_href=info['c_href'],
community_name=info['c_title'],
community_description=info['c_description'],
username=username,
)
if isinstance(body, unicode):
body = body.encode("UTF-8")
msg.set_payload(body, "UTF-8")
msg.set_type('text/html')
mailer.send([profile.email,], msg)
开发者ID:cguardia,项目名称:karl,代码行数:26,代码来源:members.py
示例6: __init__
def __init__(self, context, request, page_title=None):
self.context = context
self.request = request
self.snippets = get_template("templates/snippets.pt")
self.snippets.doctype = xhtml
self.userid = authenticated_userid(request)
self.app_url = app_url = request.application_url
self.profile_url = app_url + "/profiles/%s" % self.userid
self.here_url = self.context_url = model_url(context, request)
self.view_url = model_url(context, request, request.view_name)
settings = queryUtility(ISettings)
self.js_devel_mode = settings and getattr(settings, "js_devel_mode", None)
self.static_url = "%s/static/%s" % (app_url, _get_static_rev())
# Provide a setting in the INI to fully control the entire URL
# to the static. This is when the proxy runs a different port
# number, or to "pipeline" resources on a different URL path.
full_static_path = getattr(settings, "full_static_path", False)
if full_static_path:
if "%d" in full_static_path:
full_static_path = full_static_path % _start_time
self.static_url = full_static_path
self.page_title = page_title
self.system_name = get_setting(context, "system_name", "KARL")
self.user_is_admin = "group.KarlAdmin" in effective_principals(request)
site = find_site(context)
self.admin_url = model_url(site, request, "admin.html")
self.site_announcement = getattr(site, "site_announcement", "")
开发者ID:boothead,项目名称:karl,代码行数:28,代码来源:api.py
示例7: login
def login(context, request):
referrer = request.url
if referrer == '/login.html':
referrer = '/' # never use the login form itself as came_from
came_from = request.params.get('came_from', referrer)
logging.debug("views.py::login Logging in...")
if 'login' in request.POST.keys():
login = request.params['login']
password = request.params['password']
accounts = context['accounts']
#import pdb; pdb.set_trace()
if password and accounts.has_key(login) and str(password) == str(
accounts.get(login).password):
headers = remember(request, login)
logging.debug("views.py::login : Login OK.")
return HTTPFound(location=came_from, headers=headers)
master = get_template('templates/master.pt')
logged_in = authenticated_userid(request)
return rtr(
'templates/login.pt',
context=context,
request=request,
master=master,
message='',
logged_in=logged_in,
came_from=came_from)
开发者ID:stephenbee,项目名称:lqn-demo,代码行数:26,代码来源:views.py
示例8: render_form_widget
def render_form_widget(self, widget_id, id, label, choices=[], compulsory=False, default=None, description=None, disabled=False, alt=False):
if default is None:
default = self.formdata.get(id, '')
error = self.formerrors.get(id, '')
if isinstance(error, (list, tuple)):
error = '\n'.join(error)
from repoze.bfg.chameleon_zpt import get_template
#template = template_cache.get('form_widgets', createfunc=get_form_widgets)
template = get_template('templates/form_widgets.pt')
if isinstance(default, (list, tuple)):
default_list = default
else:
default_list = [default]
return template.render_macro(widget_id, global_scope=True,
parameters=dict(name=id,
label=label,
description=description,
choices=choices,
compulsory=compulsory,
default_value=default,
default_list=default_list,
error=error,
disabled=disabled,
alt=alt,
api=self,))
开发者ID:amarandon,项目名称:opencore,代码行数:25,代码来源:api.py
示例9: _send_signup_email
def _send_signup_email(request, invitation):
site = find_site(request.context)
mailer = getUtility(IMailDelivery)
info = {}
info['system_name'] = get_setting(site, 'system_name', 'OpenCore')
info['system_email_domain'] = get_setting(site, 'system_email_domain')
info['from_name'] = '%s invitation' % info['system_name']
info['from_email'] = '[email protected]%s' % info['system_email_domain']
info['c_title'] = info['system_name']
info['c_description'] = ""
info['c_href'] = model_url(site, request)
info['mfrom'] = '%s <%s>' % (info['from_name'], info['from_email'])
info['subject'] = 'Please join the %s community' % info['system_name']
body_template = get_template('templates/email_signup.pt')
msg = Message()
msg['From'] = info['mfrom']
msg['To'] = invitation.email
msg['Subject'] = info['subject']
body = body_template(
system_name=info['system_name'],
personal_message=invitation.message,
invitation_url=model_url(site, request, 'signup', invitation.__name__)
)
if isinstance(body, unicode):
body = body.encode("UTF-8")
msg.set_payload(body, "UTF-8")
msg.set_type('text/html')
mailer.send(info['mfrom'], [invitation.email,], msg)
开发者ID:amarandon,项目名称:opencore,代码行数:33,代码来源:members.py
示例10: send_digests
def send_digests(self, context):
mailer = getUtility(IMailDelivery)
system_name = get_setting(context, "system_name", "KARL")
system_email_domain = get_setting(context, "system_email_domain")
sent_from = "%[email protected]%s" % (system_name, system_email_domain)
from_addr = "%s <%s>" % (system_name, sent_from)
subject = "[%s] Your alerts digest" % system_name
template = get_template("email_digest.pt")
for profile in find_profiles(context).values():
if not profile._pending_alerts:
continue
# Perform each in its own transaction, so a problem with one
# user's email doesn't block all others
transaction.manager.begin()
try:
attachments = []
for alert in profile._pending_alerts:
attachments += alert['attachments']
msg = MIMEMultipart() if attachments else Message()
msg["From"] = from_addr
msg["To"] = "%s <%s>" % (profile.title, profile.email)
msg["Subject"] = subject
body_text = template(
system_name=system_name,
alerts=profile._pending_alerts,
)
if isinstance(body_text, unicode):
body_text = body_text.encode("UTF-8")
if attachments:
body = MIMEText(body_text, 'html', 'utf-8')
msg.attach(body)
else:
msg.set_payload(body_text, "UTF-8")
msg.set_type("text/html")
for attachment in attachments:
msg.attach(attachment)
mailer.send(sent_from, [profile.email,], msg)
del profile._pending_alerts[:]
transaction.manager.commit()
except Exception, e:
# Log error and continue
log.error("Error sending digest to %s <%s>" %
(profile.title, profile.email))
b = StringIO()
traceback.print_exc(file=b)
log.error(b.getvalue())
b.close()
transaction.manager.abort()
开发者ID:boothead,项目名称:karl,代码行数:60,代码来源:alerts.py
示例11: __call__
def __call__(self):
page_title = u"Forgot Password Request"
snippets = get_template("forms/templates/snippets.pt")
snippets.doctype = xhtml
blurb_macro = snippets.macros["reset_request_blurb"]
api = TemplateAPI(self.context, self.request, page_title)
return {"api": api, "blurb_macro": blurb_macro}
开发者ID:reebalazs,项目名称:karl,代码行数:7,代码来源:resetpassword.py
示例12: __call__
def __call__(self):
api = TemplateAPI(self.context, self.request, "Change Password")
layout_provider = get_layout_provider(self.context, self.request)
layout = layout_provider("generic")
snippets = get_template("forms/templates/snippets.pt")
snippets.doctime = xhtml
blurb_macro = snippets.macros["change_password_blurb"]
return {"api": api, "layout": layout, "actions": [], "blurb_macro": blurb_macro}
开发者ID:reebalazs,项目名称:karl,代码行数:8,代码来源:people.py
示例13: __call__
def __call__(self):
if "invoice" in self.request.matchdict:
session = DBSession()
invoice_id = self.request.matchdict['invoice']
invoice = session.query(Invoice).filter_by(id=invoice_id).first()
if not invoice:
return Response(status = 404)
main = get_template('templates/master.pt')
return dict(request=self.request, main=main, msgs=statusmessage.messages(self.request))
开发者ID:seantis,项目名称:seantisinvoice,代码行数:10,代码来源:invoice.py
示例14: transactions
def transactions(context, request):
master = get_template('templates/master.pt')
logged_in = authenticated_userid(request)
return rtr(
'templates/transactions.pt',
context=context,
request=request,
master=master,
logged_in=logged_in,
message=None)
开发者ID:stephenbee,项目名称:lqn-demo,代码行数:10,代码来源:views.py
示例15: __call__
def __call__(self):
if "customer" in self.request.matchdict:
customer_id = self.request.matchdict['customer']
session = DBSession()
customer = session.query(Customer).filter_by(id=customer_id).first()
if not customer:
return Response(status = 404)
main = get_template('templates/master.pt')
return dict(request=self.request, main=main, msgs=statusmessage.messages(self.request))
开发者ID:seantis,项目名称:seantisinvoice,代码行数:10,代码来源:customer.py
示例16: render
def render(name, request, context=None, status_int=None, view=None, section=None, **kw):
if os.path.sep!="/":
name=name.replace("/", os.path.sep)
template=os.path.join("templates", name)
response=render_template_to_response(template,
request=request, context=context, view=view, section=section,
layout=get_template(os.path.join("templates", "layout.pt")),
**kw)
if status_int is not None:
response.status_int=status_int
return response
开发者ID:wichert,项目名称:checking,代码行数:12,代码来源:utils.py
示例17: GlobalsFactory
def GlobalsFactory(system):
"""Globals factory to add extra globals to the variables passed to
a template.
This method should be registered using
:py:meth:`repoze.bfg.configuration.Configurator.set_renderer_globals_factory`.
"""
request=system["request"]
return { "tools": Tools(request),
"locale": locale,
"formatter": formatter,
"layout": get_template(os.path.join("templates", "layout.pt")),
}
开发者ID:wichert,项目名称:checking,代码行数:13,代码来源:utils.py
示例18: vouchers
def vouchers(context,request):
master = get_template('templates/master.pt')
logged_in = authenticated_userid(request)
errors={}
post = request.POST
if 'amount' in post:
try:
logging.debug("views.py::vouchers Adding voucher")
trans = context['vouchers'].addVoucher(logged_in,post.get('amount'),request.application_url)
logging.debug("views.py::vouchers Adding voucher ok")
except Errors,e:
logging.error(e.message)
errors = e.message
开发者ID:stephenbee,项目名称:lqn-demo,代码行数:13,代码来源:views.py
示例19: message
def message(self):
if self._message is not None:
return self._message
community = self._community
request = self.request
profile = self.profile
model = self._model
community_href = model_url(community, request)
model_href = model_url(model, request)
manage_preferences_href = model_url(profile, request)
system_name = get_setting(self.context, "system_name", "KARL")
system_email_domain = get_setting(self.context, "system_email_domain")
body_template = get_template(self._template)
from_name = "%s | %s" % (self.creator.title, system_name)
msg = Message()
msg["From"] = "%s <%s>" % (from_name, self.mfrom)
msg["To"] = "%s <%s>" % (community.title, profile.email)
msg["Subject"] = self._subject
body = body_template(
context=self.context,
community=community,
community_href=community_href,
model=model,
model_href=model_href,
manage_preferences_href=manage_preferences_href,
profile=profile,
creator=self.creator,
content_type=self._content_type_name,
digest=self.digest,
alert=self,
)
if self.digest:
# Only interested in body for digest
html = document_fromstring(body)
body_element = html.cssselect('body')[0]
span = etree.Element("span", nsmap=body_element.nsmap)
span[:] = body_element[:] # Copy all body elements to an empty span
body = etree.tostring(span, pretty_print=True)
if isinstance(body, unicode):
body = body.encode('utf-8')
msg.set_payload(body, 'utf-8')
msg.set_type("text/html")
self._message = msg
return msg
开发者ID:boothead,项目名称:karl,代码行数:50,代码来源:adapters.py
示例20: get_base_data
def get_base_data(context, request):
main = get_template("../templates/master.pt")
data = {"main": main, "project": "lanyard"}
home_node = find_root(context)
data["navitems"] = [
{"href": model_url(home_node, request), "title": "Home", "state": ""},
{
"href": model_url(home_node.slcs, request),
"title": home_node.slcs.__name__.upper(),
"state": ("", "current_page_item")[home_node.slcs == context],
},
{
"href": model_url(home_node.proxies, request),
"title": "MyProxy",
"state": ("", "current_page_item")[home_node.proxies == context],
},
]
return data
开发者ID:russell,项目名称:lanyard,代码行数:18,代码来源:utils.py
注:本文中的repoze.bfg.chameleon_zpt.get_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论