[Zope-dev] Intializing the
objectsformerly-known-as-RackMountables
Phillip J. Eby
pje@telecommunity.com
Wed, 19 Jul 2000 09:44:55 -0500
At 05:41 PM 7/19/00 +0300, Itamar Shtull-Trauring wrote:
>
>class ASPAccount(LoginUser, MemberMixin):
>
> def __init__(self, id, title=''):
> LoginUser.__init__(self, id)
> self.__dict__['_currentPayment'] = None
> self.__dict__['debt'] = Payment.Debt(0.0)
> self.__dict__['debtInPayment'] = Payment.Debt(0.0)
> self.__dict__['services'] = ServicesManager.ServicesManager()
> self.__dict__['lastMonthlyPayDay'] = None
> # day in month on which we pay
> self.__dict__['payday'] = 15
> self.__dict__['log'] = ""
>
>
>> Also, it isn't necessary to subclass the specialist -- you don't have to
>> call your routine newItem(), after all. newUser() would be a better choice
>> of name for the method, it sounds like.
>
>Again, why should I fagment my class into multiple parts? I want it all to
>be in once place - it's more readable, easier to debug, easier to
>understand, and more portable.
>
If what you want is default values, then just put them in a DataSkin
property sheet in the ZClass. Or, if using a Python class, implement them
as class attributes named "class_default_for_X". E.g.:
class ASPAccount(LoginUser, MemberMixin):
class_default_for__currentPayment = None
class_default_for_payday = 15
class_default_for_log = ""
Of course, this is only useful for immutables.