[Zope] zope zen needed...

J Cameron Cooper jccooper at jcameroncooper.com
Mon Sep 15 20:38:25 EDT 2003


>Can you explain *wrap it up in filesystem products* ...?
>
For a Python class to become a Zope object (in Zope 2, at least), it 
requires all sorts of decoration. At the least, it must inherit from 
certain Zope classes, provide a web interface, and make security 
declarations. What you can do is to write a class without all this, and 
then another one, with a slightly different name (customarily a 'Z' 
prefix) that inherits that class plus has all the Zope attachment points 
and signatures and whatnot. You'll also put in those bits of 
functionality that depend on the Zope API or behaviours.

This is sometimes counter-productive or useless; in products that are 
meant to modify Zope's behaviour, interact closely with the ZODB, or are 
small or trivial you'll probably want to just write one class/file. But 
often it gives you a nice separation that you can use to keep things 
clean or to break the code away from Zope.

>Maybe in doing so you will help me answer the following...
>
>...I made some external methods to access a database, make an object out of
>the results (result.column_names(), result.rows(), result.sql(), etc.)
>but can't seem to access this result object in the way I would have expected
>within the DTML of my pages. I little looking around in the archives
>suggested that external methods are not up to this task for security reasons
>and I have to make a *full-fledged Zope Product* if I want to access
>self-made objects in this manner - any further enlightnement on this...?
>  
>
I've never tried to return a naked object from an ExternalMethod. Seems like it might work, but I really can't say. If you can't do this, then you can certainly do it with Zope product that defines a (non-persistent?) object like you want.

If you're dealing with a relational database, Zope has a lot of facilities already for that. I'll assume there's some obstacle to using ZSQL objects and/ Zope Database Adaptors. If not, take a look there (especially at Pluggable Brains and the Result object): I've provided links on those in the past, so search the archives.

If you want to create a Python product, take a look at

the Zope Book
http://zope.org/Documentation/Books/ZopeBook/

Boring product
http://www.zope.org/Members/gtk/Boring

Zope Developer's Guide
http://www.zope.org/Documentation/Books/ZDG/current

maxm's tutorials
http://www.zope.org/Members/maxm/HowTo/minimal_01
http://www.zope.org/Members/maxm/HowTo/minimal_02

and especially mxmEasyProduct
http://www.zope.org/Members/maxm/HowTo/easyProduct

	--jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."





More information about the Zope mailing list