Beispiel #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()
Beispiel #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)
Beispiel #3
0
 def loadAll(self, class_alias):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).all()
Beispiel #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()
Beispiel #5
0
 def save(self, obj):
     session = Schema().session
     merged_obj = session.merge(obj)
     session.commit()
     return merged_obj
Beispiel #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)
Beispiel #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()
Beispiel #8
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Beispiel #9
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Beispiel #10
0
 def save(self, obj):
     session = Schema().session
     merged_obj = session.merge(obj)
     session.commit()
Beispiel #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()
Beispiel #12
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Beispiel #13
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Beispiel #14
0
 def loadAll(self, class_alias):
     class_def = self.getClassDefByAlias(class_alias)
     session = Schema().session
     return session.query(class_def.class_).all()
Beispiel #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()
Beispiel #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)