Beispiel #1
0
 def get(identifier):
     """Return the paste for an identifier.  Private pastes must be loaded
     with their unique hash and public with the paste id.
     """
     if isinstance(identifier, basestring) and not identifier.isdigit():
         return Paste.query.filter(Paste.private_id == identifier).first()
     return Paste.query.filter(db.and_(
         Paste.paste_id == int(identifier),
         Paste.private_id == None)).first()
Beispiel #2
0
 def _set_private(self, value):
     if not value:
         self.private_id = None
         return
     if self.private_id is None:
         while 1:
             self.private_id = generate_paste_hash()
             cond = db.and_(Paste.private_id == self.private_id,
                            Paste.paste_id != self.paste_id)
             paste = Paste.query.filter(cond).first()
             if paste is None:
                 break