[Zope-dev] Intializing the objects formerly-known-as-RackMountables

Itamar Shtull-Trauring itamar@maxnm.com
Wed, 19 Jul 2000 12:42:15 +0300


I need to do initialize some properties of new instances of a DataSkin
subclass - ASPAccount.  However, I can't put this in __init__ since the
object hasn't been stored at that point.  

Doing self.__dict__['name'] = 'Rincewind' seems kinda ugly.  Maybe newItem
should by default call a function on newly created objects, say __init?  I
don't want to have to subclass Specialist (or in my case, LoginManager) each
time I want to this, since it's a *very* common action.  For example,


*** Specialists.py.orig	Wed Jul 19 12:37:32 2000
--- Specialists.py	Wed Jul 19 12:38:18 2000
***************
*** 37,43 ****
      def newItem(self, key=None):
          """Create a new item"""
          # Default use first rack
!         return self.rackList[0].__of__(self).newItem(key)
  
      def manage_refreshPlugIns(self, REQUEST=None):
          """Update plugin registries"""
--- 37,46 ----
      def newItem(self, key=None):
          """Create a new item"""
          # Default use first rack
!         obj =  self.rackList[0].__of__(self).newItem(key)
!         if hasattr(obj, '__init'):
!             obj.__init()
!         return obj
  
      def manage_refreshPlugIns(self, REQUEST=None):
          """Update plugin registries"""