newbie: Zope

Martijn Faassen m.faassen at vet.uu.nl
Tue Sep 5 15:28:50 EDT 2000


Nick Trout <nick at nil_spam_videosystem.co.uk> wrote:
>> 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?!

Yes, that's open source. If you want better documentation, it helps if 
you contribute some. :)

> 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.

What is it you're trying to do?

[snip]
>> 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.

I'm not quite sure what your question is here?

[snip]
>> 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.

Then you could go a step further and just generate HTML, right? Generating
DTML from Python seems not very useful, and quite complicated.

Anyway, you *can* use DTML to do all kinds of stuff besides sticking
object values into HTML, though I wouldn't *recommend* doing too
much in DTML, as it can became an ugly mess rather fast.

>> 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?

The idea is to separate presentation from content. DTML doing the presentation,
your Python code working with the content. DTML is really a bit more
pleasant than having to construct HTML in strings in Python, too.
(though Quixote looks like a good idea; I need to play with that)
 
>> 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?!

Yes, you can; many of Zope's default products and downloadable products 
are written in Python in the file system. If you want them to fit within
Zope's framework however you'll have to work and puzzle quite a bit,
as of course there's a lack of documentation (getting slowly better).

You can also use ZClasses that derive from your own Python base classes,
doing the presentation bits in DTML in the ZClass, and the rest in
Python. This may be the easiest and the best approach in many circumstances,
though it also has negative tradeoffs of its own (a bit harder to install).
The developer's guild on www.zope.org should have information on how
to do this.

Good luck!

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list