Beispiel #1
0
 def refresh(self, session=None, attrs=None):
     """Refresh this object."""
     if not session:
         session = Session.object_session(self)
         if not session:
             session = get_session()
     session.refresh(self, attrs)
Beispiel #2
0
 def expire(self, session=None, attrs=None):
     """Expire this object ()."""
     if not session:
         session = Session.object_session(self)
         if not session:
             session = get_session()
     session.expire(self, attrs)
Beispiel #3
0
 def delete(self, session=None):
     """Delete this object."""
     self.deleted = True
     self.deleted_at = datetime.datetime.utcnow()
     if not session:
         session = Session.object_session(self)
         if not session:
             session = get_session()
     session.delete(self)
     session.flush()
Beispiel #4
0
 def save(self, session=None):
     """Save this object."""
     if not session:
         session = Session.object_session(self)
         if not session:
             session = get_session()
     session.add(self)
     try:
         session.flush()
     except IntegrityError as e:
         if str(e).endswith('is not unique'):
             raise DuplicateException(str(e))
         else:
             raise
Beispiel #5
0
def _session(context):
    return context or get_session()
Beispiel #6
0
def _session(context):
    return context or get_session()