def __init__(self, span_name=None): session = Session() self.linkage = Linkage() self.linkage.relation.cardinality = session.query(Cardinality). \ filter(Cardinality.id == 'NONE').one() self.form_name = 'default_form' self.css = "left:" + str(self.label_width) + "px; width:" + \ str(self.width) + "px; height:" + str(self.height) + "px;" super(EmbeddedForm, self).__init__(span_name)
def post_order_traverse(self, mode): if mode == 'save': from p2.datashackle.management.model.model import Model plan_id = self.plan_identifier session = Session() plan = session.query(Model).filter_by(plan_identifier=plan_id).one() source_type = self.op_setobject_type target_type = setobject_type_registry.lookup(plan.klass) # Set computed values on inner objects m = session.query(Model).filter_by(klass=source_type.__name__).one() self.linkage.source_model = m m = session.query(Model).filter_by(klass=plan.klass).one() self.linkage.target_model = m self.linkage.relation.source_table = source_type.get_table_name() self.linkage.relation.target_table = target_type.get_table_name() if self.linkage.relation.cardinality.id != 'NONE': self.linkage.relation.create_relation()
def my_view(request): session = Session() persons = session.query(Person).all() return {'persons': persons}
def __init__(self, cardinality='ONE_TO_MANY'): session = Session() self.cardinality = session.query(Cardinality). \ filter(Cardinality.id == str(cardinality)).one() super(Relation, self).__init__()
def media(request): id = int(request.matchdict['id']) session = Session() image = session.query(Media).get(id) return Response(body=image.thumbnail, headerlist=[('Content-Type', str(image.mime_type))])