Created
November 9, 2012 13:32
-
-
Save sivy/4045681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def post(self): | |
uid = self.account.dropbox_uid | |
action = self.request.get('action', '') | |
if action != 'save': | |
self.error_out(500, 'Bad request, not action provided.') | |
template_name = self.request.get('template_name') | |
template_content = self.request.get('content') | |
tid = uid + template_name | |
logging.debug(template_name) | |
template_key = ndb.Key(UserTemplate, tid) | |
template = template_key.get() | |
template.populate( | |
content=template_content, | |
) | |
template.put() | |
# we're having weird template issues | |
logging.debug('template saved: checking others...') | |
utq = UserTemplate.query(UserTemplate.name == template_name) | |
for t in utq.iter(): | |
logging.debug("template: %s modified: %s content:\n\n%s" % (t.key.id(), repr(t.modified), t.content)) | |
# defer this for moar faster | |
self.client.put_file("/templates/" + template.name, template.content, overwrite=True) | |
self.session.add_flash("Your template has been saved.", "info") | |
self.redirect('/dash/templates?template=' + template_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment