- Timestamp:
- Feb 26, 2009, 11:09:28 PM (16 years ago)
- Location:
- trunk/packages/invirt-database
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-database/debian/changelog
r2158 r2191 1 invirt-database (0.1.8) unstable; urgency=low 2 3 [Peter Iannucci] 4 * Added Record superclass for models, handling __repr__ consistently. 5 6 [Greg Price] 7 * use self.c rather than self.__dict__ for SQLAlchemy fields 8 * make Record._ignore, Owner.get* classmethods 9 10 -- Greg Price <price@mit.edu> Thu, 26 Feb 2009 22:38:02 -0500 11 1 12 invirt-database (0.1.7) unstable; urgency=low 2 13 -
trunk/packages/invirt-database/python/database/owner.py
r2187 r2191 16 16 _identity_field = 'owner_id' 17 17 18 def getMemoryQuotas(owner): 19 owner_info = Owner.query().filter_by(owner_id=owner).first() 18 @classmethod 19 def getMemoryQuotas(cls, owner): 20 owner_info = cls.query().filter_by(owner_id=owner).first() 20 21 if owner_info == None: 21 owner_info = Owner(owner_id=owner)22 owner_info = cls(owner_id=owner) 22 23 return (owner_info.get('ram_quota_total'), owner_info.get('ram_quota_single')) 23 getMemoryQuotas = staticmethod(getMemoryQuotas)24 24 25 def getDiskQuotas(owner): 26 owner_info = Owner.query().filter_by(owner_id=owner).first() 25 @classmethod 26 def getDiskQuotas(cls, owner): 27 owner_info = cls.query().filter_by(owner_id=owner).first() 27 28 if owner_info == None: 28 owner_info = Owner(owner_id=owner)29 owner_info = cls(owner_id=owner) 29 30 return (owner_info.get('disk_quota_total'), owner_info.get('disk_quota_single')) 30 getDiskQuotas = staticmethod(getDiskQuotas)31 31 32 def getVMQuotas(owner): 33 owner_info = Owner.query().filter_by(owner_id=owner).first() 32 @classmethod 33 def getVMQuotas(cls, owner): 34 owner_info = cls.query().filter_by(owner_id=owner).first() 34 35 if owner_info == None: 35 owner_info = Owner(owner_id=owner)36 owner_info = cls(owner_id=owner) 36 37 return (owner_info.get('vms_quota_total'), owner_info.get('vms_quota_active')) 37 getVMQuotas = staticmethod(getVMQuotas)38 39 def _ignore(self):40 return super(Owner, self)._ignore() + ['getMemoryQuotas', 'getDiskQuotas', 'getVMQuotas'] -
trunk/packages/invirt-database/python/database/record.py
r2187 r2191 1 1 class Record(object): 2 2 _identity_field = None 3 3 4 def get(self, field): 4 5 try: … … 6 7 except: 7 8 return None 9 8 10 def _formatField(self, field): 9 11 v = self.get(field) … … 17 19 else: 18 20 return repr(v) 21 22 @classmethod 23 def _ignore(cls): 24 return [cls._identity_field] 25 19 26 def _fields(self): 20 27 ignore = self._ignore() 21 keys = sorted(self.__class__.__dict__.keys()) 22 return [(k,self._formatField(k)) for k in keys if k[0]!="_" and k not in ignore] 28 keys = sorted(self.c.keys()) 29 return [(k,self._formatField(k)) for k in keys if k not in ignore] 30 23 31 def __repr__(self): 24 32 classname = self.__class__.__name__ … … 35 43 36 44 return "<%s%s%s>" % (classname, identity, payload) 37 def _ignore(self):38 return [self._identity_field, 'c', 'query', 'get']39 45 40 46 class FormattableRecord(Record):
Note: See TracChangeset
for help on using the changeset viewer.