本文整理汇总了Python中sentry.web.helpers.render_to_string函数的典型用法代码示例。如果您正苦于以下问题:Python render_to_string函数的具体用法?Python render_to_string怎么用?Python render_to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_to_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build
def build(self, to):
if self.headers is None:
headers = {}
else:
headers = self.headers.copy()
headers.setdefault('Reply-To', ', '.join(to))
if self.template:
txt_body = render_to_string(self.template, self.context)
else:
txt_body = self.body
if self.html_template:
html_body = render_to_string(self.html_template, self.context)
else:
html_body = self.html_body
msg = EmailMultiAlternatives(
self.subject,
txt_body,
settings.SERVER_EMAIL,
to,
headers=headers
)
if html_body:
msg.attach_alternative(
UnicodeSafePynliner().from_string(html_body).run(),
"text/html")
return msg
开发者ID:XuYong,项目名称:sentry,代码行数:31,代码来源:email.py
示例2: build
def build(self, to):
if self.headers is None:
headers = {}
else:
headers = self.headers.copy()
if ENABLE_EMAIL_REPLIES and "X-Sentry-Reply-To" in headers:
reply_to = headers["X-Sentry-Reply-To"]
else:
reply_to = ", ".join(to)
headers.setdefault("Reply-To", reply_to)
if self.template:
txt_body = render_to_string(self.template, self.context)
else:
txt_body = self.body
if self.html_template:
html_body = render_to_string(self.html_template, self.context)
else:
html_body = self.html_body
msg = EmailMultiAlternatives(self.subject, txt_body, settings.SERVER_EMAIL, to, headers=headers)
if html_body:
msg.attach_alternative(UnicodeSafePynliner().from_string(html_body).run(), "text/html")
return msg
开发者ID:jmsche,项目名称:sentry,代码行数:28,代码来源:email.py
示例3: to_html
def to_html(self, event, **kwargs):
if not self.values:
return ''
if len(self.values) == 1 and not self.values[0].stacktrace:
exception = self.values[0]
context = exception.get_context(event=event, **kwargs)
return render_to_string('sentry/partial/interfaces/exception.html', context)
context = self.get_context(event=event, **kwargs)
return render_to_string('sentry/partial/interfaces/chained_exception.html', context)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:11,代码来源:exception.py
示例4: send_recover_mail
def send_recover_mail(self):
from django.core.mail import send_mail
from sentry.web.helpers import render_to_string
context = {
'user':
self.user,
'domain':
urlparse.urlparse(settings.SENTRY_URL_PREFIX).hostname,
'url':
absolute_uri(
reverse(
'sentry-account-recover-confirm',
args=[self.user.id, self.hash])),
}
body = render_to_string('sentry/emails/recover_account.txt', context)
try:
send_mail(
'%sPassword Recovery' % (settings.EMAIL_SUBJECT_PREFIX, ),
body,
settings.SERVER_EMAIL, [self.user.email],
fail_silently=False)
except Exception, e:
logger = logging.getLogger('sentry.mail.errors')
logger.exception(e)
开发者ID:theatlantic,项目名称:django-sentry,代码行数:26,代码来源:models.py
示例5: post_process
def post_process(self, group, event, is_new, is_sample, **kwargs):
if not is_new:
return
project = group.project
token = self.get_option('token', project)
subject = '[%s] %s: %s' % (
project.name.encode('utf-8'),
unicode(event.get_level_display()).upper().encode('utf-8'),
event.error().encode('utf-8').splitlines()[0])
interface_list = []
for interface in event.interfaces.itervalues():
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
message = render_to_string('sentry_flowdock/event.html', {
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
})
self.send_payload(
token=token,
subject=subject,
message=message,
link=group.get_absolute_url(),
)
开发者ID:livedo,项目名称:sentry-flowdock,代码行数:33,代码来源:models.py
示例6: client_guide
def client_guide(request, project, platform):
if platform not in PLATFORM_LIST:
return HttpResponseRedirect(reverse('sentry'))
key = ProjectKey.objects.get(user=request.user, project=project)
dsn = key.get_dsn()
dsn_public = key.get_dsn(public=True)
template = 'sentry/partial/client_config/%s.html' % (platform,)
context = {
'platform': platform,
'platform_title': platform.title(),
'project': project,
'dsn': dsn,
'dsn_public': dsn_public,
'page': 'client_help'
}
if request.is_ajax():
return render_to_response(template, context, request)
context['template'] = render_to_string(template, context, request)
return render_to_response('sentry/projects/docs/client_config.html', context, request)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:25,代码来源:docs.py
示例7: resolve
def resolve(request, project):
gid = request.REQUEST.get("gid")
if not gid:
return HttpResponseForbidden()
try:
group = Group.objects.get(pk=gid)
except Group.DoesNotExist:
return HttpResponseForbidden()
Group.objects.filter(pk=group.pk).update(status=1)
group.status = 1
data = [
(
m.pk,
{
"html": render_to_string("sentry/partial/_group.html", {"group": m, "request": request}).strip(),
"count": m.times_seen,
},
)
for m in [group]
]
response = HttpResponse(json.dumps(data))
response["Content-Type"] = "application/json"
return response
开发者ID:rtnpro,项目名称:sentry,代码行数:26,代码来源:api.py
示例8: html_body
def html_body(self):
try:
return inline_css(render_to_string(self.email.get_html_template(), self.get_context()))
except Exception:
import traceback
traceback.print_exc()
raise
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:7,代码来源:mail.py
示例9: to_html
def to_html(self, event, is_public=False, **kwargs):
data = self.data
headers_is_dict, headers = self._to_dict(self.headers)
# educated guess as to whether the body is normal POST data
if headers_is_dict and headers.get("Content-Type") == "application/x-www-form-urlencoded" and "=" in data:
_, data = self._to_dict(data)
context = {
"is_public": is_public,
"event": event,
"full_url": "?".join(filter(bool, [self.url, self.query_string])),
"url": self.url,
"method": self.method,
"data": data,
"query_string": self.query_string,
"headers": self.headers,
}
if not is_public:
# It's kind of silly we store this twice
_, cookies = self._to_dict(self.cookies)
context.update({"cookies": cookies, "env": self.env})
return render_to_string("sentry/partial/interfaces/http.html", context)
开发者ID:huy8989,项目名称:sentry,代码行数:25,代码来源:interfaces.py
示例10: to_html
def to_html(self, event, is_public=False, **kwargs):
if not self.frames:
return ""
system_frames = 0
frames = []
for frame in self.frames:
frames.append(frame.get_context(event=event, is_public=is_public))
if not frame.in_app:
system_frames += 1
if len(frames) == system_frames:
system_frames = 0
newest_first = self.is_newest_frame_first(event)
if newest_first:
frames = frames[::-1]
return render_to_string(
"sentry/partial/interfaces/stacktrace.html",
{
"is_public": is_public,
"newest_first": newest_first,
"system_frames": system_frames,
"event": event,
"frames": frames,
"stacktrace": self.get_traceback(event, newest_first=newest_first),
},
)
开发者ID:nmartini,项目名称:sentry,代码行数:30,代码来源:interfaces.py
示例11: to_html
def to_html(self, event):
data = self.data
data_is_dict = False
headers_is_dict, headers = self._to_dict(self.headers)
if headers_is_dict and headers.get("Content-Type") == "application/x-www-form-urlencoded":
data_is_dict, data = self._to_dict(data)
# It's kind of silly we store this twice
cookies_is_dict, cookies = self._to_dict(self.cookies or headers.pop("Cookie", {}))
return render_to_string(
"sentry/partial/interfaces/http.html",
{
"event": event,
"full_url": "?".join(filter(bool, [self.url, self.query_string])),
"url": self.url,
"method": self.method,
"data": data,
"data_is_dict": data_is_dict,
"query_string": self.query_string,
"cookies": cookies,
"cookies_is_dict": cookies_is_dict,
"headers": self.headers,
"headers_is_dict": headers_is_dict,
"env": self.env,
},
)
开发者ID:JonatanM,项目名称:sentry,代码行数:28,代码来源:interfaces.py
示例12: send_invite_email
def send_invite_email(self):
from django.core.mail import send_mail
from sentry.web.helpers import render_to_string
context = {
'email':
self.email,
'team':
self.team,
'url':
absolute_uri(
reverse(
'sentry-accept-invite',
kwargs={
'member_id': self.id,
'token': self.token,
})),
}
body = render_to_string('sentry/emails/member_invite.txt', context)
try:
send_mail(
'%sInvite to join team: %s' % (settings.EMAIL_SUBJECT_PREFIX,
self.team.name),
body,
settings.SERVER_EMAIL, [self.email],
fail_silently=False)
except Exception, e:
logger = logging.getLogger('sentry.mail.errors')
logger.exception(e)
开发者ID:theatlantic,项目名称:django-sentry,代码行数:30,代码来源:models.py
示例13: to_html
def to_html(self, event, is_public=False, **kwargs):
data = self.data
headers_is_dict, headers = self._to_dict(self.headers)
# educated guess as to whether the body is normal POST data
if headers_is_dict and headers.get('Content-Type') == 'application/x-www-form-urlencoded' and '=' in data:
_, data = self._to_dict(data)
context = {
'is_public': is_public,
'event': event,
'url': self.url,
'short_url': self.short_url,
'method': self.method,
'query_string': self.query_string,
'fragment': self.fragment,
'headers': self.headers,
}
if not is_public:
# It's kind of silly we store this twice
_, cookies = self._to_dict(self.cookies)
context.update({
'cookies': cookies,
'env': self.env,
'data': data,
})
return render_to_string('sentry/partial/interfaces/http.html', context)
开发者ID:DarkHorseComics,项目名称:sentry,代码行数:29,代码来源:interfaces.py
示例14: to_html
def to_html(self, event):
frames = []
for frame in self.frames:
if frame.get("context_line"):
context = get_context(
frame["lineno"], frame["context_line"], frame.get("pre_context"), frame.get("post_context")
)
start_lineno = context[0][0]
else:
context = []
start_lineno = None
context_vars = []
if frame.get("vars"):
context_vars = self._shorten(frame["vars"])
else:
context_vars = []
frames.append(
{
"abs_path": frame.get("abs_path"),
"filename": frame["filename"],
"function": frame.get("function"),
"start_lineno": start_lineno,
"lineno": frame.get("lineno"),
"context": context,
"vars": context_vars,
}
)
return render_to_string(
"sentry/partial/interfaces/stacktrace.html",
{"event": event, "frames": frames, "stacktrace": self.get_traceback(event)},
)
开发者ID:bgyss,项目名称:sentry,代码行数:34,代码来源:interfaces.py
示例15: to_html
def to_html(self, event):
data = self.data
data_is_dict = False
if self.headers.get('Content-Type') == 'application/x-www-form-urlencoded':
try:
data = QueryDict(data)
except:
pass
else:
data_is_dict = True
# It's kind of silly we store this twice
cookies = self.cookies or self.headers.pop('Cookie', {})
cookies_is_dict = isinstance(cookies, dict)
if not cookies_is_dict:
try:
cookies = QueryDict(cookies)
except:
pass
else:
cookies_is_dict = True
return render_to_string('sentry/partial/interfaces/http.html', {
'event': event,
'full_url': '?'.join(filter(None, [self.url, self.query_string])),
'url': self.url,
'method': self.method,
'data': data,
'data_is_dict': data_is_dict,
'query_string': self.query_string,
'cookies': cookies,
'cookies_is_dict': cookies_is_dict,
'headers': self.headers,
'env': self.env,
})
开发者ID:lboaretto,项目名称:sentry,代码行数:35,代码来源:interfaces.py
示例16: to_html
def to_html(self, event, is_public=False, **kwargs):
data = self.data
data_is_dict = False
headers_is_dict, headers = self._to_dict(self.headers)
if headers_is_dict and headers.get('Content-Type') == 'application/x-www-form-urlencoded':
data_is_dict, data = self._to_dict(data)
cookies = self.cookies or headers.pop('Cookie', {})
context = {
'is_public': is_public,
'event': event,
'full_url': '?'.join(filter(bool, [self.url, self.query_string])),
'url': self.url,
'method': self.method,
'data': data,
'data_is_dict': data_is_dict,
'query_string': self.query_string,
'headers': self.headers,
'headers_is_dict': headers_is_dict,
}
if not is_public:
# It's kind of silly we store this twice
cookies_is_dict, cookies = self._to_dict(cookies)
context.update({
'cookies': cookies,
'cookies_is_dict': cookies_is_dict,
'env': self.env,
})
return render_to_string('sentry/partial/interfaces/http.html', context)
开发者ID:TracyWebTech,项目名称:sentry,代码行数:33,代码来源:interfaces.py
示例17: resolve
def resolve(request, project):
gid = request.REQUEST.get('gid')
if not gid:
return HttpResponseForbidden()
try:
group = Group.objects.get(pk=gid)
except Group.DoesNotExist:
return HttpResponseForbidden()
if group.project and group.project.pk not in get_project_list(request.user):
return HttpResponseForbidden()
Group.objects.filter(pk=group.pk).update(status=1)
group.status = 1
data = [
(m.pk, {
'html': render_to_string('sentry/partial/_group.html', {
'group': m,
'request': request,
}).strip(),
'count': m.times_seen,
}) for m in [group]]
response = HttpResponse(json.dumps(data))
response['Content-Type'] = 'application/json'
return response
开发者ID:twoolie,项目名称:sentry,代码行数:27,代码来源:api.py
示例18: to_html
def to_html(self, event, is_public=False, **kwargs):
if not self.frames:
return ''
system_frames = 0
frames = []
for frame in self.frames:
frames.append(frame.get_context(event=event, is_public=is_public))
if not frame.in_app:
system_frames += 1
if len(frames) == system_frames:
system_frames = 0
newest_first = self.is_newest_frame_first(event)
if newest_first:
frames = frames[::-1]
return render_to_string('sentry/partial/interfaces/stacktrace.html', {
'is_public': is_public,
'newest_first': newest_first,
'system_frames': system_frames,
'event': event,
'frames': frames,
'stacktrace': self.get_traceback(event, newest_first=newest_first),
})
开发者ID:ecarreras,项目名称:sentry,代码行数:27,代码来源:interfaces.py
示例19: notify_users
def notify_users(self, group, event, fail_silently=False):
project = event.project
interface_list = []
for interface in event.interfaces.itervalues():
body = interface.to_string(event)
if not body:
# Skip
continue
interface_list.append((interface.get_title(), mark_safe(body)))
title = ('[%s] %s' % (
project.name.encode(API_CHARSET),
unicode(group.get_level_display().upper().encode(API_CHARSET))))
link = group.get_absolute_url()
message = render_to_string(message_template, ({
'group': group,
'event': event,
'tags': event.get_tags(),
'link': link,
'interfaces': interface_list
}))
if len(message) > self.BASE_MAXIMUM_MESSAGE_LENGTH:
message = message[:self.BASE_MAXIMUM_MESSAGE_LENGTH - 4] + ' ...'
message = message.encode(API_CHARSET)
else:
message = message.encode(API_CHARSET)
self.send_notification(title, message, link, project)
开发者ID:p0is0n,项目名称:sentry-pushover,代码行数:33,代码来源:models.py
示例20: to_email_html
def to_email_html(self, event, **kwargs):
return render_to_string('sentry/partial/interfaces/http_email.html', {
'event': event,
'url': self.full_url,
'short_url': self.url,
'method': self.method,
'query_string': self.query_string,
})
开发者ID:rayleyva,项目名称:sentry,代码行数:8,代码来源:http.py
注:本文中的sentry.web.helpers.render_to_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论