Changeset 123
- Timestamp:
- 04/10/07 19:40:10 (2 years ago)
- Files:
-
- trunk/bin/domainmodel-admin (modified) (1 diff)
- trunk/src/dm/cli/admin.py (modified) (2 diffs)
- trunk/src/dm/command/__init__.py (modified) (1 diff)
- trunk/src/dm/command/accesscontrol.py (modified) (1 diff)
- trunk/src/dm/command/base.py (added)
- trunk/src/dm/command/captcha.py (modified) (1 diff)
- trunk/src/dm/command/initialise.py (added)
- trunk/src/dm/command/person.py (modified) (1 diff)
- trunk/src/dm/command/plugin.py (modified) (1 diff)
- trunk/src/dm/command/role.py (modified) (1 diff)
- trunk/src/dm/command/state.py (modified) (1 diff)
- trunk/src/dm/db.py (modified) (10 diffs)
- trunk/src/dm/dictionary.py (modified) (1 diff)
- trunk/src/dm/dictionarywords.py (modified) (2 diffs)
- trunk/src/dm/dom/base.py (modified) (6 diffs)
- trunk/src/dm/dom/meta.py (modified) (1 diff)
- trunk/src/dm/dom/plugin.py (modified) (1 diff)
- trunk/src/dm/dom/state.py (modified) (3 diffs)
- trunk/src/dm/dom/stateful.py (modified) (2 diffs)
- trunk/src/dm/plugin/accesscontrol.py (added)
- trunk/src/dm/plugin/example.py (added)
- trunk/src/dm/soleInstance.py (added)
- trunk/src/dm/strategy.py (modified) (3 diffs)
- trunk/src/dm/strategytest.py (modified) (3 diffs)
- trunk/src/dm/util/db.py (modified) (1 diff)
- trunk/src/dm/util/mailer.py (added)
- trunk/src/dm/util/mailertest.py (added)
- trunk/src/dm/view/base.py (modified) (5 diffs)
- trunk/src/dm/view/manipulator.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bin/domainmodel-admin
r29 r123 1 1 #!/usr/bin/env python 2 2 3 import os 4 os.environ['DJANGO_SETTINGS_MODULE'] = 'dm.django.settings.main' 5 3 6 import dm.cli.admin 4 5 7 dm.cli.admin.UtilityRunner() 6 8 trunk/src/dm/cli/admin.py
r108 r123 104 104 105 105 def takeDatabaseAction(self, actionName): 106 raise Exception, "Method not implemented." 106 dbUtilClass = self.getDatabaseUtilityClass() 107 dbUtil = dbUtilClass() 108 actionMethod = getattr(dbUtil, actionName) 109 actionMethod() 110 111 def getDatabaseUtilityClass(self): 112 from dm.util.db import Database 113 return Database 107 114 108 115 def help_db(self, line=None): … … 246 253 # lower-cased with underscore to match definition in system dictionary 247 254 system_name = 'domainmodel' 255 utilityClass = AdministrationUtility 248 256 249 257 def __init__(self, *args, **kwds): trunk/src/dm/command/__init__.py
r106 r123 3 3 """ 4 4 5 from dm. iocimport *6 from dm. exceptionsimport *5 from dm.command.base import * 6 from dm.command.initialise import * 7 7 8 debug = RequiredFeature('Debug')9 10 # todo: Move base class to base.pm module (create it first).11 class Command(object):12 """13 Command layer supertype.14 'Service Layer', [Fowler, 2003] 'Command (233)' [GoF, 1995].15 """16 17 registry = RequiredFeature('DomainRegistry')18 dictionary = RequiredFeature('SystemDictionary')19 logger = RequiredFeature('Logger')20 exceptionClass = KforgeCommandError21 22 def __init__(self, isTransaction=False, **kwds):23 self.isTransaction = isTransaction24 if self.isTransaction:25 self.transaction = self.registry.database.beginTransaction()26 self.kwds = kwds27 self.logger = RequiredFeature('Logger')28 29 def execute(self):30 if debug:31 #message = "Command: "+ self.getCommandName() +" "+ str(self.kwds)32 message = "Executed command: "+ self.getCommandName()33 self.logger.debug(message)34 35 def getCommandName(self):36 return self.__class__.__name__37 38 def commitSuccess(self):39 "Commit any transaction."40 if self.isTransaction:41 self.transaction.commit()42 43 def raiseError(self, message):44 "Raise command error exception."45 if self.isTransaction:46 self.transaction.rollback()47 if debug:48 self.logger.debug("Command error: " + message)49 exceptionClass = self.exceptionClass50 raise exceptionClass(message)51 52 53 class MacroCommand(Command):54 "Execute a sequence of commands."55 56 def execute(self):57 "Make them so."58 commands = self.getCommands()59 for command in commands:60 command.execute()61 62 def getCommands(self):63 "List of commands."64 return []65 66 67 class DomainObjectCommand(Command):68 69 # todo: rename: objectId -> domainObjectKey70 71 def __init__(self, typeName=None, objectId=None, objectKwds={}, **kwds):72 super(DomainObjectCommand, self).__init__(**kwds)73 if not typeName:74 raise KforgeCommandError("No typeName parameter for %s" % str(self))75 self.typeName = typeName76 self.objectId = objectId77 self.objectKwds = objectKwds78 79 def assertDomainClassRegistered(self):80 if not self.registry.isDomainClassRegistered(self.typeName):81 message = "Domain class not registered: %s" % self.typeName82 self.raiseError(message)83 84 def getDomainClass(self):85 return self.registry.getDomainClass(self.typeName)86 87 def createRegister(self):88 self.assertDomainClassRegistered()89 objectClass = self.getDomainClass()90 return objectClass.createRegister()91 92 # todo: rename following <Action>DomainObject (e.g. "Create [a] domain object!")93 94 class DomainObjectList(DomainObjectCommand):95 96 def __init__(self, userQuery='', startsWith='', startsWithAttributeName='', **kwds):97 super(DomainObjectList, self).__init__(**kwds)98 self.userQuery= userQuery99 self.startsWith = startsWith100 self.startsWithAttributeName = startsWithAttributeName101 102 def execute(self):103 super(DomainObjectList, self).execute()104 domainObjectRegister = self.createRegister()105 if self.startsWith:106 if not self.startsWithAttributeName:107 self.startsWithAttributeName = domainObjectRegister.keyName108 selectedDomainObjects = domainObjectRegister.startsWith(109 value=self.startsWith,110 attributeName=self.startsWithAttributeName111 )112 self.results = [p for p in selectedDomainObjects]113 elif self.userQuery:114 selectedDomainObjects = domainObjectRegister.search(115 userQuery=self.userQuery116 )117 self.results = [p for p in selectedDomainObjects]118 else:119 self.results = [p for p in domainObjectRegister]120 121 122 class DomainObjectCreate(DomainObjectCommand):123 124 def execute(self):125 register = self.createRegister()126 objectKwds = self.objectKwds127 try:128 if self.objectId:129 self.object = register.create(self.objectId, **objectKwds)130 else:131 self.object = register.create(**objectKwds)132 except KforgeDomError, inst:133 message = "Can't create domain object: %s " % str(inst)134 self.raiseError(message)135 136 137 class DomainObjectRead(DomainObjectCommand):138 139 def execute(self):140 register = self.createRegister()141 objectKwds = self.objectKwds142 try:143 if self.objectId:144 self.object = register.read(self.objectId, **objectKwds)145 else:146 self.object = register.read(**objectKwds)147 except KforgeError, inst:148 self.raiseError(str(inst))149 150 151 # todo:152 class DomainObjectUpdate(DomainObjectCommand):153 pass154 155 156 # todo:157 class DomainObjectDelete(DomainObjectCommand):158 pass159 trunk/src/dm/command/accesscontrol.py
r108 r123 1 from dm.command import Command1 from dm.command.base import Command 2 2 from dm.exceptions import * 3 3 from dm.strategy import FindProtectionObject trunk/src/dm/command/captcha.py
r2 r123 1 from dm.command import DomainObjectCreate2 from dm.command import DomainObjectRead1 from dm.command.base import DomainObjectCreate 2 from dm.command.base import DomainObjectRead 3 3 4 4 class CaptchaCreate(DomainObjectCreate): trunk/src/dm/command/person.py
r108 r123 1 from dm.command import *1 from dm.command.base import * 2 2 import dm.re 3 3 import re trunk/src/dm/command/plugin.py
r2 r123 1 from dm.command import *1 from dm.command.base import * 2 2 import dm.re 3 3 import re trunk/src/dm/command/role.py
r2 r123 1 1 # todo: delete? 2 2 3 from dm.command import Command3 from dm.command.base import Command 4 4 5 5 class RoleCommand(Command): trunk/src/dm/command/state.py
r2 r123 1 from dm.command import Command1 from dm.command.base import Command 2 2 3 3 class StateCommand(Command): trunk/src/dm/db.py
r120 r123 48 48 debug = RequiredFeature('Debug') 49 49 logger = RequiredFeature('Logger') 50 51 dbdebug = False 50 52 51 53 class ConnectionFacade(object): … … 117 119 else: 118 120 record = records 119 if d ebug:121 if dbdebug and debug: 120 122 logger.debug('Found %s record from database.' % (className)) 121 123 return record … … 134 136 return True 135 137 if '__endsBefore__' in kwds: 138 return True 139 if '__dateCreatedAfter__' in kwds: 140 return True 141 if '__dateCreatedBefore__' in kwds: 142 return True 143 if '__lastModifiedAfter__' in kwds: 144 return True 145 if '__lastModifiedBefore__' in kwds: 136 146 return True 137 147 return False … … 172 182 else: 173 183 records = self.getRecordClass(className).select() 174 if d ebug:184 if dbdebug and debug: 175 185 logger.debug('Listed %s records from database.' % (className)) 176 186 return records … … 605 615 self.domainObject = obj 606 616 self.domainObject.record = self 607 if d ebug:617 if dbdebug and debug: 608 618 message = "Record returned newly instantiated %s." % self.getClassName() 609 619 logger.debug(message) … … 612 622 if not self.isCached(): 613 623 if not self.domainObject in loadedList: 614 if d ebug:624 if dbdebug and debug: 615 625 message = "Record loads existing %s instance with values." % self.getClassName() 616 626 logger.debug(message) 617 627 self.loadDomainObject(loadedList) 618 628 else: 619 if d ebug:629 if dbdebug and debug: 620 630 message = "Loaded %s record avoids loading loop." % self.getClassName() 621 631 logger.debug(message) 622 632 else: 623 if d ebug:633 if dbdebug and debug: 624 634 message = "Record returned %s with existing values." % self.getClassName() 625 635 logger.debug(message) … … 629 639 "Creates recorded domain object." 630 640 domainClass = self.getDomainClass() 631 if d ebug:641 if dbdebug and debug: 632 642 message = "Instantiating domain object from: %s" % domainClass 633 643 logger.debug(message) … … 647 657 "Maps values from record to domain object." 648 658 if sync: 649 if d ebug:659 if dbdebug and debug: 650 660 message = "Synchronising mapper values with RDBMS." 651 661 logger.debug(message) 652 662 self.sync() 653 663 elif sync: 654 if d ebug:664 if dbdebug and debug: 655 665 message = "Not synchronising mapper values with RDBMS." 656 666 logger.debug(message) 657 if d ebug:667 if dbdebug and debug: 658 668 message = "Loading domain object values from mapper." 659 669 logger.debug(message) … … 709 719 isChanged = True 710 720 if isChanged: 711 if d ebug:721 if dbdebug and debug: 712 722 message = "Updating RDBMS with %s mapper value." % ( 713 723 self.meta.domName … … 863 873 ) 864 874 sqlEqualsList.append(sqlEquals) 875 elif name == '__dateCreatedBefore__': 876 sqlSafeName = self.makeSqlName('date_created') 877 sqlEquals = "%s < %s" % ( 878 sqlSafeName, sqlSafeValue 879 ) 880 sqlEqualsList.append(sqlEquals) 881 elif name == '__dateCreatedAfter__': 882 sqlSafeName = self.makeSqlName('date_created') 883 sqlEquals = "%s > %s" % ( 884 sqlSafeName, sqlSafeValue 885 ) 886 sqlEqualsList.append(sqlEquals) 887 elif name == '__lastModifiedBefore__': 888 sqlSafeName = self.makeSqlName('last_modified') 889 sqlEquals = "%s < %s" % ( 890 sqlSafeName, sqlSafeValue 891 ) 892 sqlEqualsList.append(sqlEquals) 893 elif name == '__lastModifiedAfter__': 894 sqlSafeName = self.makeSqlName('last_modified') 895 sqlEquals = "%s > %s" % ( 896 sqlSafeName, sqlSafeValue 897 ) 898 sqlEqualsList.append(sqlEquals) 865 899 else: 866 900 sqlSafeName = self.makeSqlName(name) trunk/src/dm/dictionary.py
r113 r123 51 51 self[TIMEZONE] = '' 52 52 self[SKIP_EMAIL_SENDING] = '' 53 self[WWW_PORT] = '80' 53 54 54 55 def makeConfigFilePath(self): trunk/src/dm/dictionarywords.py
r120 r123 23 23 LOG_PATH = 'logging.log_file' 24 24 LOG_LEVEL = 'logging.level' 25 DOMAIN_NAME = 'domain_name' 25 26 AUTH_COOKIE_NAME = 'auth_cookie_name' 26 27 NO_AUTH_COOKIE_NAME = 'no_auth_cookie_name' … … 29 30 TIMEZONE = 'environ.tz' 30 31 SKIP_EMAIL_SENDING = 'skip_email_sending' 32 WWW_PORT = 'www.port' 31 33 trunk/src/dm/dom/base.py
r116 r123 5 5 6 6 debug = RequiredFeature('Debug') 7 domdebug = False 7 8 8 9 class DomainBase(object): … … 71 72 if self.isCached: 72 73 if key in self.cache: 73 if d ebug:74 if domdebug and debug: 74 75 message = "Cache hit for key: '%s'" % key 75 76 self.log.debug(message) 76 77 return self.readCache(key) 77 78 else: 78 if d ebug:79 if domdebug and debug: 79 80 message = "Cache miss for key: '%s'" % key 80 81 self.log.debug(message) 81 if d ebug:82 if domdebug and debug: 82 83 message = "Retrieving from %s record for key: '%s'" % (self, key) 83 84 if message == 'WeekEarmarkTemplate': … … 615 616 self.log.info(message) 616 617 618 def raiseApprove(self): 619 "Raises onApprove event." 620 self.onApprove() 621 message = "Approved %s: '%s'" % ( 622 self.__class__.__name__, 623 self.getRegisterKeyValue() 624 ) 625 self.log.info(message) 626 617 627 def raiseUndelete(self): 618 628 "Raises onUndelete event." … … 625 635 626 636 def raisePurge(self): 627 "Raises on Delete event."637 "Raises onPurge event." 628 638 self.onPurge() 629 639 … … 639 649 "Abstract handler for Delete object event." 640 650 self.notifyPlugins(self.__class__.__name__ + 'Delete', self) 651 652 def onApprove(self): 653 "Abstract handler for Approve object event." 654 self.notifyPlugins(self.__class__.__name__ + 'Approve', self) 641 655 642 656 def onUndelete(self): … … 668 682 if not('startsWithAttributeName' in kwds and kwds['startsWithAttributeName']): 669 683 kwds['startsWithAttributeName'] = self.startsWithAttributeName 670 if d ebug:684 if domdebug and debug: 671 685 className = self.registerClass.__name__ 672 686 message = "Creating '%s' register with kwds: %s" % (className, kwds) trunk/src/dm/dom/meta.py
r114 r123 442 442 choices = [] 443 443 associateRegister = self.getAssociatedObjectRegister(domainObject) 444 for associateObject in associateRegister.getSortedList(): 444 objectList = [] 445 if associateRegister != []: 446 objectList = associateRegister.getSortedList() 447 for associateObject in objectList: 445 448 key = associateRegister.getRegisterKey(associateObject) 446 449 if self.isKeyDomainObject(): trunk/src/dm/dom/plugin.py
r45 r123 9 9 "Registered plugin." 10 10 11 # todo: move down to KForge's definition of a plugin 11 12 services = HasManyPages('Service', 'name', 'project', pageKeys=getProjects) 12 13 trunk/src/dm/dom/state.py
r106 r123 16 16 self.getBehaviour().deleteObject(object) 17 17 18 def approveObject(self, object): 19 self.getBehaviour().approveObject(object) 20 18 21 def undeleteObject(self, object): 19 22 self.getBehaviour().undeleteObject(object) … … 27 30 28 31 def deleteObject(self, object): 32 pass 33 34 def approveObject(self, object): 29 35 pass 30 36 … … 63 69 object.destroySelf() 64 70 65 66 71 class PendingBehaviour(AbstractStateBehaviour): 72 73 def approveObject(self, object): 74 object.decacheItem() 75 object.state = self.states['active'] 76 object.save() 77 object.raiseApprove() 78 79 def deleteObject(self, object): 80 object.deleteAggregates() 81 object.raiseDelete() 82 object.decacheItem() 83 object.state = self.states['deleted'] 84 object.save() 85 86 def purgeObject(self, object): 87 message = 'A pending object cannot be purged: %s' % str(object) 88 raise dm.exceptions.KforgeDomError(message) 89 67 90 def getBehaviour(self): 68 91 if not self.behaviour: trunk/src/dm/dom/stateful.py
r106 r123 52 52 if isCompoundingRegister: 53 53 registerClass = self.__class__ 54 self.deleted = registerClass(typeName, isCompoundingRegister=False, **kwds) 54 self.pending = registerClass( 55 typeName, isCompoundingRegister=False, **kwds) 56 self.pending.requiredStateName = 'pending' 57 self.deleted = registerClass( 58 typeName, isCompoundingRegister=False, **kwds) 55 59 self.deleted.requiredStateName = 'deleted' 56 self.all = registerClass(typeName, isCompoundingRegister=False, **kwds) 60 self.all = registerClass( 61 typeName, isCompoundingRegister=False, **kwds) 57 62 self.all.requiredStateName = '' 58 63 … … 71 76 else: 72 77 super(StatefulObject, self).delete() 78 79 def approve(self): 80 if self.state: 81 self.state.approveObject(self) 73 82 74 83 def undelete(self): trunk/src/dm/strategy.py
r111 r123 1 1 from dm.ioc import RequiredFeature 2 3 moddebug = False 2 4 3 5 class BaseStrategy(object): 4 6 5 7 registry = RequiredFeature('DomainRegistry') 8 debug = RequiredFeature('Debug') 9 logger = RequiredFeature('Logger') 6 10 7 11 def __init__(self): 8 12 pass 13 14 15 class MakeProtectedNames(BaseStrategy): 16 17 def __init__(self, protectedObject): 18 super(MakeProtectedNames, self).__init__() 19 self.protectedObject = protectedObject 20 21 def make(self): 22 protectedNames = [] 23 if self.protectedObject.__class__ == type: 24 if moddebug and self.debug: 25 self.logger.debug('Making protected name for class: %s' % self.protectedObject) 26 className = self.protectedObject.__name__ 27 protectedNames.append(className) 28 else: 29 if moddebug and self.debug: 30 self.logger.debug('Making protected names for instance: %s' % self.protectedObject) 31 keyValue = self.protectedObject.id 32 className = self.protectedObject.__class__.__name__ 33 instanceName = className + "." + str(keyValue) 34 protectedNames.append(instanceName) 35 protectedNames.append(className) 36 if not protectedNames: 37 msg = "No protected names derived from protection object: %s" % ( 38 self.protectedObject 39 ) 40 raise Exception, msg 41 elif moddebug and self.debug: 42 self.logger.debug('Made protected names: %s' % protectedNames) 43 return protectedNames 9 44 10 45 … … 21 56 22 57 23 class MakeProtectedNames(BaseStrategy):58 class FindProtectionObjects(BaseStrategy): 24 59 25 60 def __init__(self, protectedObject): 26 super( MakeProtectedNames, self).__init__()61 super(FindProtectionObjects, self).__init__() 27 62 self.protectedObject = protectedObject 28 63 29 def make(self): 30 protectedNames = [] 31 if self.protectedObject.__class__ == type: 32 className = self.protectedObject.__name__ 33 protectedNames.append(className) 34 else: 35 keyValue = self.protectedObject.id 36 className = self.protectedObject.__class__.__name__ 37 instanceName = className + "." + str(keyValue) 38 protectedNames.append(instanceName) 39 protectedNames.append(className) 40 if not protectedNames: 41 msg = "No protected names derived from protection object: %s" % ( 42 self.protectedObject 64 def find(self): 65 if moddebug and self.debug: 66 self.logger.debug('Finding protection objects for: %s' % self.protectedObject) 67 makeNames = MakeProtectedNames(self.protectedObject) 68 protectedNames = makeNames.make() 69 protectionObjects = [] 70 for name in protectedNames: 71 if name in self.registry.protectionObjects: 72 protection = self.registry.protectionObjects[name] 73 protectionObjects.append(protection) 74 if not protectionObjects: 75 raise Exception, "No protection for %s (protected names: %s)" % ( 76 self.protectedObject, protectedNames 43 77 ) 44 raise Exception, msg 45 return protectedNames 78 return protectionObjects 46 79 47 80 … … 63 96 64 97 65 class FindProtectionObjects(BaseStrategy):66 67 def __init__(self, protectedObject):68 super(FindProtectionObjects, self).__init__()69 self.protectedObject = protectedObject70 71 def find(self):72 makeNames = MakeProtectedNames(self.protectedObject)73 protectedNames = makeNames.make()74 protectionObjects = []75 for name in protectedNames:76 if name in self.registry.protectionObjects:77 protection = self.registry.protectionObjects[name]78 protectionObjects.append(protection)79 if not protectionObjects:80 raise Exception, "No protection for %s (protected names: %s)" % (81 self.protectedObject, protectedNames82 )83 return protectionObjects84 85 86 98 class CreateProtectionObject(BaseStrategy): 87 99 trunk/src/dm/strategytest.py
r111 r123 27 27 28 28 self.protectedObject = self.registry.plugins['accesscontrol'] 29 self.failUnlessEqual(self.protectedObject.id, 1) 30 self.failUnlessEqual(self.protectedObject.name, 'accesscontrol') 29 31 makeName = MakeProtectedName(self.protectedObject) 30 32 protectedName = makeName.make() … … 71 73 findObject = FindProtectionObject(protectedObject) 72 74 protectionObject = findObject.find() 73 self.failUnlessEqual(protectionObject.name, 'Plugin .1')75 self.failUnlessEqual(protectionObject.name, 'Plugin') 74 76 75 77 def testProtectedDomainObjectClass(self): … … 92 94 findObjects = FindProtectionObjects(protectedObject) 93 95 protectionObjects = findObjects.find() 94 self.failUnlessEqual(len(protectionObjects), 2) 95 self.failUnlessEqual(protectionObjects[0].name, 'Plugin.1') 96 self.failUnlessEqual(protectionObjects[1].name, 'Plugin') 96 self.failUnlessEqual(len(protectionObjects), 1) 97 self.failUnlessEqual(protectionObjects[0].name, 'Plugin') 97 98 98 99 def testProtectedDomainObjectClass(self): trunk/src/dm/util/db.py
r113 r123 80 80 Initialises service database by creating initial domain object records. 81 81 """ 82 pass 82 initModelCommandClass = self.getInitModelCommandClass() 83 initModelCommand = initModelCommandClass() 84 initModelCommand.execute() 83 85 86 def getInitModelCommandClass(self): 87 commandSet = self.getApplicationCommandSet() 88 return commandSet['InitialiseDomainModel'] 89 90 def getApplicationCommandSet(self): 91 import dm.soleInstance 92 commandSet = dm.soleInstance.application.commands 93 return commandSet 94 trunk/src/dm/view/base.py
r113 r123 43 43 self._canUpdateSystem = None 44 44 self._canCreatePerson = None 45 self._canApprovePerson = None 45 46 self._canReadPerson = None 46 47 self._canUpdatePerson = None … … 138 139 return self.authoriseActionObject('Create', protectedObject) 139 140 141 def canApprove(self, protectedObject): 142 return self.authoriseActionObject('Approve', protectedObject) 143 140 144 def canRead(self, protectedObject): 141 145 return self.authoriseActionObject('Read', protectedObject) … … 173 177 self._canCreatePerson = self.canCreate(protectedObject) 174 178 return self._canCreatePerson 179 180 def canApprovePerson(self): 181 if self._canApprovePerson == None: 182 if self.person: 183 protectedObject = self.person 184 else: 185 protectedObject = self.getDomainClass('Person') 186 self._canApprovePerson = self.canApprove(protectedObject) 187 return self._canApprovePerson 175 188 176 189 def canReadPerson(self): … … 835 848 836 849 850 class AbstractPendingView(AbstractListView): 851 852 def getManipulatedObjectRegister(self): 853 r = super(AbstractPendingView, self).getManipulatedObjectRegister() 854 return r.pending 855 856 837 857 class AbstractSearchView(AbstractClassView): 838 858 … … 1012 1032 domainObject = self.getManipulatedDomainObject() 1013 1033 domainObject.delete() 1034 1035 1036 class AbstractApproveView(AbstractFormView): 1037 1038 def __init__(self, **kwds): 1039 super(AbstractApproveView, self).__init__(**kwds) 1040 self.formErrors = {} 1041 1042 def getInitialParams(self): 1043 initialParams = MultiValueDict() 1044 domainObject = self.getManipulatedDomainObject() 1045 domainObjectValueDict = domainObject.asDictValues() 1046 initialParams.update(domainObjectValueDict) 1047 return initialParams 1048 1049 def manipulateDomainObject(self): 1050 super(AbstractApproveView, self).manipulateDomainObject() 1051 domainObject = self.getManipulatedDomainObject() 1052 domainObject.approve() 1014 1053 1015 1054 trunk/src/dm/view/manipulator.py
r112 r123 60 60 self.fields = [] 61 61 self.buildFields() 62 if not fieldNames: 63 for field in self.fields: 64 self.fieldNames.append(field.field_name) 62 65 63 66 def buildFields(self): … … 217 220 return None 218 221 222 def update(self, data): 223 self.data = data 224 self.setNonAssociateListAttributes() 225 self.setAssociateListAttributes() 226 227 def setNonAssociateListAttributes(self): 228 for metaAttr in self.metaObject.attributes: 229 if not metaAttr.isAssociateList: 230 if metaAttr.name in self.fieldNames: 231 #if self.data.has_key(metaAttr.name): 232 # metaAttr.setAttributeFromMultiValueDict( 233 # self.domainObject, self.data 234 # ) 235 metaAttr.setAttributeFromMultiValueDict( 236 self.domainObject, self.data 237 ) 238 self.domainObject.save() 239 219 240 def setAssociateListAttributes(self): 220 241 for metaAttr in self.metaObject.attributes: … … 223 244 224 245 def setAssociateListAttribute(self, metaAttr): 225 if self.data.has_key(metaAttr.name): 226 metaAttr.setAttributeFromMultiValueDict( 227 self.domainObject, self.data 228 ) 229 230 def update(self, data): 231 self.data = data 232 self.setNonAssociateListAttributes() 233 self.setAssociateListAttributes() 234 235 def setNonAssociateListAttributes(self): 236 for metaAttr in self.metaObject.attributes: 237 if not metaAttr.isAssociateList: 238 if self.data.has_key(metaAttr.name): 239 metaAttr.setAttributeFromMultiValueDict( 240 self.domainObject, self.data 241 ) 242 self.domainObject.save() 243 246 if metaAttr.name in self.fieldNames: 247 if self.data.has_key(metaAttr.name): 248 metaAttr.setAttributeFromMultiValueDict( 249 self.domainObject, self.data 250 ) 251 244 252 def getAttributeField(self, attrName): 245 253 for field in self.fields:
