[Zope] - How do I publish this object?

Amos Latteier amos@aracnet.com
Tue, 08 Dec 1998 13:49:56 -0800


At 02:49 PM 12/8/98 -0500, Skip wrote:
>
>    James> Thank you for the help, but...this must be some new definition of
>    James> the word "easy" with which I was previously unfamiliar. :-)
>
>	[ several questions, some of which occurred to me, snipped ]
>
>My sentiments exactly.  It would appear that Principia and Zope traded off
>Bobo's simple object publishing model for a very nice way to manage
>hierarchical web sites.

It's true, for programmers, Zope is much more complex than Bobo. That's
because Zope is a large framework built on Bobo that tries to provide lots
of extra services.

If you still want Bobo's simplicity, it's still there. You can always just
use ZPublisher and forget all the other stuff. Zope is not right for all
problem domains.

That said, I belive that Zope offers a lot of cool things and that
depending on what you are trying to do, doing it within Zope's framework
can be a lot less total work than going at it with plain Bobo. 

>The extra complexity added under the covers looks
>like it will make it very difficult to convert existing CGI-based sites to
>Zope.  I have a site that uses 30-40 CGI scripts to do its business.  At
>this stage, converting them looks like it will be fairly difficult.  If I'm
>missing something, please fill me in.  If not, is there some simpler way to
>publish objects through Zope other than the current Product API?

The Product API is for creating a very specific type of web object--one
that can be managed through the web by Zope. You don't need this kind of
object for many all purposes.

Suppose you have 40 different web objects that you've developed in Bobo
over the last year. You want to plug them into Zope. It probably doesn't
make sense to productize too many of them. Rather, you probably just want
to add them to the object hierarchy somewhere and publish them like normal.
The easiest way to do this is with External Methods.

Here's an example of how you might do this:

"External method to plug a Bobo object into the Zope object hierarchy"
# first import your Bobo object or class

from myBoboModule import Spam

def add_spam(self,id):
    """This method is called by a folder to add a spam
    object to the folder. The spam object is not a
    Zope product, it is simply a normal Bobo object."
    spam=Spam(id) # or whatever to create your Bobo object
    if not hasattr(self,id):
        setattr(self,id,spam)
    return "Spam added to folder" 

Now your spam object is an attribute of the folder you called the External
Method on. You can publish it the same way you publish any Bobo object.

Make sense?

-Amos

P.S. If you want to plug a whole bunch of Bobo stuff into Zope you might
build a more flexible External Method or even a <gasp> Product to manage it.

P.P.S. If you're really sick you can use an External Method to attach a
textarea to exec and then start hacking away just like at the Python prompt!