[Zope] Python object lifecycle? (was Re: [Zope] Where to put business logic?
Robb Shecter
shecter@darmstadt.gmd.de
Fri, 18 Feb 2000 14:55:45 +0100
Steen Suder wrote:
> I know that this issue has been up before, at least partly.
>
I've been thinking about this...
>
> Is there an "unwritten" rule on where to put business logic in an Zope
> app?
Well, right now I'm thinking the answer might be, "in a Java servlet".
> What could the underlying motives be for choosing one or the another
> strategy?
>
Well, good design and experience suggests that web apps need a middle
layer.
Possible Solution: Make python classes that implement the business logic.
These classes get called as external methods.
I have some doubts about this, though. Zope hasn't been too stable for me,
and I have a fairly plain installation.
Also, I'm not sure if the behavior of the Python external objects are
really well defined. (Maybe I just haven't found it.) Here's what I mean:
With Java servlets, the lifetime of the objects is defined like this:
+ A servlet implements the methods init() and get().
+ The first time a request comes to the servlet, one instance is created,
and init() is called on it.
+ Then, on that and every other other request, that instance's get()
parameter is called, and is expected to produce the results to the client's
request.
Thus, servlets are long-lived objects. It's easy to do things like program
web agents that cache their data, make connections to databases, poll web
sources, and automatically rebuild those connections if the system goes
down and comes back up.
I'd like to check out doing this in Python, but I haven't seen the "life
cycle" of Python server objects explained.
-Robb