Last active
August 29, 2015 14:02
-
-
Save cmacrander/d0edf7e693e8d460879c to your computer and use it in GitHub Desktop.
Logic for setting up qualtrics links
This file contains 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
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