~ewanmellor/glance/lp694382

« back to all changes in this revision

Viewing changes to glance/registry/db/sqlalchemy/models.py

  • Committer: Tarmac
  • Author(s): Rick Harris
  • Date: 2010-12-23 19:41:59 UTC
  • mfrom: (27.1.2 use_datetime_obj)
  • Revision ID: tarmac-20101223194159-304tpg996wuo6mwf
Converts timestamp attributes to datetime objects before persisting.

Refactors image_update and image_create to use the same basic code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    __table_args__ = {'mysql_engine': 'InnoDB'}
46
46
    __table_initialized__ = False
47
47
    __prefix__ = 'none'
 
48
    __protected_attributes__ = set([
 
49
        "created_at", "updated_at", "deleted_at", "deleted"])
 
50
 
48
51
    created_at = Column(DateTime, default=datetime.datetime.utcnow)
49
52
    updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow)
50
53
    deleted_at = Column(DateTime)
160
163
            raise exception.Invalid("Invalid status '%s' for image." % status)
161
164
        return status
162
165
    
163
 
    # TODO(sirp): should these be stored as properties?
164
 
    #user_id = Column(String(255))
165
 
    #project_id = Column(String(255))
166
 
    #arch = Column(String(255))
167
 
    #default_kernel_id = Column(String(255))
168
 
    #default_ramdisk_id = Column(String(255))
169
 
    #
170
 
    #@validates('default_kernel_id')
171
 
    #def validate_kernel_id(self, key, val):
172
 
    #    if val != 'machine':
173
 
    #        assert(val is None)
174
 
    # 
175
 
    #@validates('default_ramdisk_id')
176
 
    #def validate_ramdisk_id(self, key, val):
177
 
    #    if val != 'machine':
178
 
    #        assert(val is None)
179
 
 
180
166
 
181
167
class ImageProperty(BASE, ModelBase):
182
168
    """Represents an image properties in the datastore"""