Exemplo n.º 1
0
 def handle_delete(self, action, data):
     selected = self._getSelected(action, data)
     session = get_session()
     for object in selected:
         session.delete(object)
     # we need to flush the session explicitly now
     session.flush()
Exemplo n.º 2
0
 def handle_delete( self, action, data ):
     selected = self._getSelected( action, data )
     session = get_session()
     for object in selected:
         session.delete( object )
     # we need to flush the session explicitly now
     session.flush()
 def __call__( self ):
     klass = resolve( self.klass )
     session = get_session()
     query = session.query( klass )
     return query.get( self.primary_key )
 def __call__(self):
     klass = resolve(self.klass)
     session = get_session()
     query = session.query(klass)
     return query.get(self.primary_key)
person.address = address

# because of the backref we can use either endpoint to get to the other.
# ie. we get bidirectional references.
#
print "Person name", address.person.last_name == 'wolf'

# commit the transaction
transaction.commit()


#################################
# Querying Objects
#################################


# session accessor api
from ore.alchemist.manager import get_session

# get the current session
object_session = get_session()

# create a person query
query = object_session.query( domain.Person )

# query by email
print query.select_by_email(u'*****@*****.**')[0].last_name