Пример #1
0
    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()
Пример #2
0
    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)
Пример #3
0
 def loadAll(self, class_alias):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).all()
Пример #4
0
 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()
Пример #5
0
 def save(self, obj):
     session = Schema().session
     merged_obj = session.merge(obj)
     session.commit()
     return merged_obj
Пример #6
0
 def load(self, class_alias, key):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).get(key)
Пример #7
0
 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()
Пример #8
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Пример #9
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Пример #10
0
 def save(self, obj):
     session = Schema().session
     merged_obj = session.merge(obj)
     session.commit()
Пример #11
0
 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()
Пример #12
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Пример #13
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Пример #14
0
 def loadAll(self, class_alias):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).all()
Пример #15
0
 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()
Пример #16
0
 def load(self, class_alias, key):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).get(key)