Skip to content

Instantly share code, notes, and snippets.

@cmacrander
Last active August 29, 2015 14:02
Show Gist options
  • Save cmacrander/d0edf7e693e8d460879c to your computer and use it in GitHub Desktop.
Save cmacrander/d0edf7e693e8d460879c to your computer and use it in GitHub Desktop.
Logic for setting up qualtrics links
class QualtricsLink(NamedModel):
def get_link(self):
keys = QualtricsLink.all().fetch(100, keys_only=True)
try:
link = self._get_link_transactionally(keys.pop())
# repeat if you don't have a link
return link.link_string
@db.transactional
def _get_link_transactionally(self, key):
# Will db.get fail properly if the key it's got has been deleted?
link = db.get(keys.pop())
# If it doesn't, maybe this?
if link is None:
raise Exception()
db.delete(link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment