Home | Trees | Indices | Help |
|
---|
|
1 # ============================================================================ 2 # 3 # Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 4 # www.conceptive.be / project-camelot@conceptive.be 5 # 6 # This file is part of the Camelot Library. 7 # 8 # This file may be used under the terms of the GNU General Public 9 # License version 2.0 as published by the Free Software Foundation 10 # and appearing in the file LICENSE.GPL included in the packaging of 11 # this file. Please review the following information to ensure GNU 12 # General Public Licensing requirements will be met: 13 # http://www.trolltech.com/products/qt/opensource.html 14 # 15 # If you are unsure which license is appropriate for your use, please 16 # review the following information: 17 # http://www.trolltech.com/products/qt/licensing.html or contact 18 # project-camelot@conceptive.be. 19 # 20 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 # 23 # For use of this library in commercial applications, please contact 24 # project-camelot@conceptive.be 25 # 26 # ============================================================================ 27 from elixir.entity import Entity 28 from elixir.options import using_options 29 from elixir.fields import Field 30 from sqlalchemy.types import Unicode, INT, DateTime, PickleType 31 from elixir.relationships import ManyToOne 32 33 from camelot.model import metadata 34 from camelot.view import filters 35 36 """Set of classes to keep track of changes to objects and 37 be able to restore their state 38 """ 39 40 __metadata__ = metadata 41 42 from camelot.core.utils import ugettext_lazy as _ 43 from camelot.view.elixir_admin import EntityAdmin 44 import datetime48 """Keeps information on the previous state of objects, to keep track 49 of changes and enable restore to that previous state""" 50 using_options( tablename = 'memento' ) 51 model = Field( Unicode( 256 ), index = True, required = True ) 52 primary_key = Field( INT(), index = True, required = True ) 53 creation_date = Field( DateTime(), default = datetime.datetime.now ) 54 authentication = ManyToOne( 'AuthenticationMechanism', 55 required = True, 56 ondelete = 'restrict', 57 onupdate = 'cascade' ) 58 description = property( lambda self:'Change' ) 596961 verbose_name = _( 'History' ) 62 verbose_name_plural = _( 'History' ) 63 list_display = ['creation_date', 64 'authentication', 65 'model', 66 'primary_key', 67 'description'] 68 list_filter = [filters.ComboBoxFilter('model')]72 """The state of the object before an update took place""" 73 using_options( inheritance = 'multi', tablename = 'memento_update', ) 74 previous_attributes = Field( PickleType() ) 75 76 @property8678 if self.previous_attributes: 79 return u'Update %s when previous value was %s' % ( 80 ','.join( self.previous_attributes.keys() ), 81 ','.join( unicode( v ) for v in self.previous_attributes.values() ) )8288 """The state of the object before it is deleted""" 89 using_options( inheritance = 'multi', tablename = 'memento_delete', ) 90 previous_attributes = Field( PickleType() ) 91 92 @property 9599101 """Marks the creation of an object""" 102 using_options( inheritance = 'multi', tablename = 'memento_create', ) 103 104 @property 107111
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:13 2010 | http://epydoc.sourceforge.net |