newbie: Zope

Nick Trout nick at nil_spam_videosystem.co.uk
Tue Sep 5 12:04:10 EDT 2000


> The idea of the ZDP site is to help fill it. :) I believe there's also a
> zope.faqts.com that may be helpful.

Thats not very easy when I'm finding it difficult to learn Zope!! :-) Bit of
chicken and egg?! I'd like an expert to give me insight... Mind you noones
ever said Zope was easy. My biggest stumbling block is getting it do do
anything interesting /difficult with ZClasses due to DTML/Python interface.

> There are some very good Howto's out there, it's just a bit difficult
> to find them...

exactly.

> ZClasses without any base class (at least explicitly) can be used to
> store some simple properties. I believe the example in the developer's
> guide mentions a CD listing; each instance of such a ZClass would be
> a CD object. Folderish ZClasses could be used to organize your site;
> one way to do this in Zope is to put common methods in the root folder
> of the site; subfolders acquire this information. This does pollute the
> root folder, though, so another approach is to use a ZClass that behaves
> like a folder but adds some methods (such as a request for an index of
> subfolders, formatted as HTML, for instance).

Be nice if Zope actually listed the properties you picked up (or does it :-)
and gave you help on them.

> > There's not much info on interfacing with Python. And then the interface
is
> > DTML-ish?!
>
> Simple interfacing to Python isn't that hard. You can write an external
> method:
>
> def foo(self, arg):
>     return "the arg is: " + arg
>
> and call it like this:
>
> <dtml-var "foo('hey!')">
> Which'll get you this on your page:
>
> the arg is: hey!

So why use DTML at all?

Seems to me that DTML is only used so that you can substitute object values
into HTML. It provides a horrible unintuitive interface to Python. Why not
generate all of the DTML in Python and then just substitute simple objects.
i.e. DTML does *nothing* clever.

> You can also return lists, such as here:
>
> def get_a_list(self):
>     return [1, 2, 3, 4]
>
> And you can use this with dtml-in, for instance:
>
> <ul>
> <dtml-in "get_a_list()">
>   <li><dtml-var sequence-item></li>
> </dtml-in>
> </ul>

So why not return from get_a_list() ...?

 <ul>
   <li>1</li>
   <li>2</li>
   <li>3</li>
   <li>4</li>
 </ul>

Why the ugly DTML iterators? It seems like too much functionality has
shifted into DTML?

> Oh, any class, basically. To make an class persistent in Zope, do this:
>
> from Globals import Persistent
>
> class MyClass(Persistent):
>     ...
>
> This is in the intro document on the ZODB, by the way. :)

So I may as well use Python functionality and this and not use ZClasses at
all?!

> That's in the intro to the ZODB too, so I'll look it up for you:
> self._p_changed = 1

Ah, I did find this in the end.  :-)

>
> And the link again:
> >> http://starship.python.net/crew/amk/python/writing/zodb-zeo.html

Cheers,
Nick.







More information about the Python-list mailing list