def insertDefaultData(self): user = models.User() user.first_name = 'Bill' user.last_name = 'Lumbergh' for label, email in {'personal': '*****@*****.**', 'work': '*****@*****.**'}.iteritems(): email_obj = models.Email() email_obj.label = label email_obj.email = email user.emails.append(email_obj) for label, number in {'personal': '1-800-555-5555', 'work': '1-555-555-5555'}.iteritems(): phone_obj = models.PhoneNumber() phone_obj.label = label phone_obj.number = number user.phone_numbers.append(phone_obj) session = Schema().session session.add(user) session.commit()
def insertDefaultData(self): user = models.User() user.first_name = 'Bill' user.last_name = 'Lumbergh' user.created = datetime.utcnow() for label, email in { 'personal': '*****@*****.**', 'work': '*****@*****.**' }.iteritems(): email_obj = models.Email() email_obj.label = label email_obj.email = email user.emails.append(email_obj) for label, number in { 'personal': '1-800-555-5555', 'work': '1-555-555-5555' }.iteritems(): phone_obj = models.PhoneNumber() phone_obj.label = label phone_obj.number = number user.phone_numbers.append(phone_obj) session = Schema().session session.add(user) session.commit() return 'Added user: %s %s' % (user.first_name, user.last_name)
def loadAll(self, class_alias): class_def = self.getClassDefByAlias(class_alias) session = Schema().session return session.query(class_def.class_).all()
def remove(self, class_alias, key): class_def = self.getClassDefByAlias(class_alias) session = Schema().session obj = session.query(class_def.class_).get(key) session.delete(obj) session.commit()
def save(self, obj): session = Schema().session merged_obj = session.merge(obj) session.commit() return merged_obj
def load(self, class_alias, key): class_def = self.getClassDefByAlias(class_alias) session = Schema().session return session.query(class_def.class_).get(key)
def remove(self, class_alias, key): klass = pyamf.load_class(class_alias).klass session = Schema().session obj = session.query(klass).get(key) session.delete(obj) session.commit()
def loadAll(self, class_alias): klass = pyamf.load_class(class_alias).klass session = Schema().session return session.query(klass).all()
def load(self, class_alias, key): klass = pyamf.load_class(class_alias).klass session = Schema().session return session.query(klass).get(key)
def save(self, obj): session = Schema().session merged_obj = session.merge(obj) session.commit()