[Zope-dev] Experiments with ORMapping

Cees de Groot cg@cdegroot.com
12 May 2001 00:05:14 +0200


Phillip J. Eby <pje@telecommunity.com> said:
>For example, if I am an ISP, and I want to implement an 
>"active" flag on an "account" object, I would like changing it to 
>automatically go out and add or remove routing entries and password entries 
>on my servers when I update the record through my Zope interface (web, 
>SOAP, or whatever).  Could you make a ZODB "Storage" object that supported 
>this?  Maybe.  But from an architectural standpoint it would be rather 
>messy - akin to writing OO code with giant "switch" statements.
>

class Account(Persistent):
    def disable(self):
	map(lambda s: s.end(), self.subscriptions)
	self.enabled = 0

I don't see a switch statement there. Granted, some jerk could come in
and code "account.enabled = 0" somewhere in his code, but that jerk
would soon be looking for other employment ;-). I do think that this
won't happen very often: instance variables in Python are very implicit,
you have to hunt the class code to find them. Instance methods are very
explicit, and therefore more likely to be found first.

(mostly everything an ISP customer orders is a kind of subscription. A
subscription has a start event, a repeat event, and an end event (or
state, or whatever you want to call it). Example webhosting: start event
is 'create Apache config', repeat event is 'send out yearly invoice'
(probably in the base class), end event is 'archive website and remove
from Apache config').

Funny you came up with this example. I run an ISP and have spent the last
couple of days thinking about just this stuff :-)