[Zope-dev] complex zope applications

Martijn Faassen M.Faassen@vet.uu.nl
Wed, 26 May 1999 16:46:35 +0200


Scott Lewis wrote:
[snip]
> what seems like a better structure is 3 tier: python business
> objects talk to (encapsulate) the database. zope controls the
> business objects. the main reason i switched to zope is that it
> seems like zope is set up for this.
> 
> before i jump into this, is there anyone who has done something
> similar? can you offer any advice or moral support? sorry for the
> broad questions, but i guess i'm looking for feedback at a higher
> level. over the next few months i'll have 1000s of more specific
> questions :)

Hm, I have experience talking to databases from Python via Python's
standard database interface (basically SQL, the particular backend I
used was ODBC). Python is a very nice language to deal with data like
this, I found. Python's list and dictionary datatypes are very useful.
Python also has a clean structure, so the Python part seems okay (unless
it is speed, though I have found it's quite capable so far).

How do you plan to use Python to talk to databases? Are you going to use
Zope or use the Python db-api? If you use Zope SQL methods you need to
talk through these methods from your Python. I don't have experience
with it but this is possible; the Z SQL methods can be treated as Python
methods from Python, basically.

Another tricky part would be 'business objects'. The simple way to
interface Zope with Python are external methods (written in Python). If
you get your business objects done with external methods, I'd recommend
this route. External methods are not 'business objects', however
('business methods', I suppose?), though of course you can package a
number of them together inside a Zope folder. (you can bundle them in a
subfolder which will be automatically acquired by other subfolders..this
way they remain manageable and don't pollute your root folder).

If you need actual objects (i.e. something with methods), you can go
various routes. One is to write a Zope product. This is quite a
challenge; I've tried it once before but got bogged down. Today I did
get a product working (basically by copying and pasting and removing
what I didn't need from another product, this seems to be the easiest
way). (cheer!). Just be aware you might run into some difficulties; one
needs to know quite a bit about the Zope API.

Another way in the future would be to use ZClasses. ZClasses are part of
the Zope 2.0 Alpha, but it'll take some time before there'll be a
production version of Zope featuring them. From what I understand of
ZClasses you can create a new Zope product from inside Zope with them
(basically by packaging DTML and external methods together).

Good luck and regards,

Martijn