Exemplo n.º 1
0
 def add_relationship(self, other_user, relationship):
     rel = UserRelationship()
     rel.user = self
     rel.target = other_user
     rel.relationship = relationship
     try:
         Session.add(rel)
     except IntegrityError:
         pass
     return
Exemplo n.º 2
0
 def get_by_text(cls, text, create=False):
     text = Tag.sanitize(text)
     if not Tag.cache_by_text.has_key(text):
         try:
             tag = Session.query(Tag).filter(Tag.text == text).one()
             Tag.cache_by_id[tag.id] = tag
         except InvalidRequestError:
             if create:
                 # Need to create tag
                 tag = Tag(text=text)
                 Session.add(tag)
             else:
                 return None
         Tag.cache_by_text[text] = tag
     return Tag.cache_by_text[text]
Exemplo n.º 3
0
 def get_by_text(cls, text, create = False):
     text = Tag.sanitize(text)
     if not Tag.cache_by_text.has_key(text):
         try:
             tag = Session.query(Tag).filter(Tag.text == text).one()
             Tag.cache_by_id[tag.id] = tag
         except InvalidRequestError:
             if create:
                 # Need to create tag
                 tag = Tag(text=text)
                 Session.add(tag)
             else:
                 return None
         Tag.cache_by_text[text] = tag
     return Tag.cache_by_text[text]