Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def htmlfill(self, content, **htmlfill_kwargs):
"""
Runs FormEncode **htmlfill** on content.
"""
charset = getattr(self.request, 'charset', 'utf-8')
htmlfill_kwargs.setdefault('encoding', charset)
return htmlfill.render(content,
defaults=self.data,
errors=self.errors,
**htmlfill_kwargs)
@app.route("/", methods=['POST'])
def post():
try:
paste = Paste.create(request.form, request.remote_addr)
return redirect(url_for('view', key=paste.key))
except Invalid, inv:
return htmlfill.render(index(), auto_insert_errors=False,
defaults=request.form,
errors=inv.unpack_errors())
def update(self):
'Show account update page'
# Load
personID = h.getPersonID()
# If the person is not logged in,
if not personID:
# Return
return redirect(url('person_login', targetURL=h.encodeURL('/')))
# Render
c.isNew = False
person = Session.query(model.Person).get(personID)
# Return
return formencode.htmlfill.render(render('/people/change.mako'), {
'username': person.username,
'nickname': person.nickname,
'email': person.email,
'email_sms': person.email_sms,
})
def render(self, template_name, **kwargs):
html = self._handler.render_string(template_name, **kwargs)
if not self._result:
html = htmlfill.render(
html,
defaults=self._values,
errors=self._form_errors,
encoding="utf8",
)
self._handler.finish(html)
def error_fill(page, values, errors):
return htmlfill.render(page,
defaults=values,
errors=errors,
auto_error_formatter=\
lambda m: "<p class="error-message">%s</p>" % m,
prefix_error=False,
force_defaults=False)
def render(self, template_name, **kwargs):
html = self._handler.render_string(template_name, **kwargs)
if not self._result:
html = htmlfill.render(html,
defaults=self._values,
errors=self._form_errors,
encoding="utf8")
self._handler.finish(html)