[Zope3-dev] Re: Creating new objects in a package

Peter Mayne PeterMayne at ap.spherion.com
Mon Sep 27 20:27:14 EDT 2004


Stephan Richter wrote:
> 
> There is no alternative to createObject() and as I stated in my previous 
> reply, this is quiet important. 

But there is an alternative: simply create the object and add it to the 
context's dictionary.

>>So, when *do* I need a factory?
> 
> You automatically use factories when dealing with ZCML-registered content 
> components. You need them when creating an object involves more than just 
> instantiating a class.

The book says (p53): "Factories, as the name suggests, exist merely to 
create other components and objects." There's no mention in that section 
of why I should use a factory when I could just create an object myself. 
It's possible that such information is scattered around the rest of the 
book, but it would be good to have it in one place.

Rhetorical (for now) question: when/why does creating an object involve 
more than just instantiating a class? I don't know Z3, so I really don't 
know what else is involved. There seems to be an assumption that I 
already know this, possibly because I'm supposed to be coming to Z3 from 
Z2, but that's not the case.

>>Arguably, this kind of stuff should come with the Z3 distribution.
>>On the other hand, I'm a developer, and I'm reading a 
>>developer's handbook, and (certainly in my case) it's a reasonable
>>assumption that I'm ignorant of Z3. Even after reading the book, I don't
>>see how I could write bugtracker's bug importer, because I still
>>wouldn't know how to create my own IBug objects.
> 
> I decided to skip the XML import/export chapter for the book, since I did not 
> want to make it too long. My assumption is that once you read all of the 
> book, you are familiar enough with the framework, that you can do such tasks.

By reading the relevant parts of the book, I managed to write all of my 
XML importer except for the part where I actually create the objects, 
which is what led to this thread. I still can't see how I could have 
figured out something so fundamental by reading the book. I think that's 
a pretty glaring omission.

>>How about a chapter called "Zope 3 API" which goes through some of the
>>basic non-framework subjects?
> 
> What would it be about?

How do I create objects? Factories vs simple Python object creation; 
when/why would I use one or the other. How do I traverse the database? 
How do I find things in the database? How can I do these things from a 
command line/script, so I don't have to click through a bunch of web 
pages to try things out? Glimpses of the API.

I don't know what else would be in it, because I don't know Z3. If I did 
know Z3, I probably wouldn't need the book. :-)

>>What the heck is IContained for? ... 
> 
> 
> I am pretty sure I explain IContained in chapter 7. 

There is one mention of IContained in the book, in section 28.3: "Since 
the principal source is stored inside an authentication service, we need 
to make it a IContained object." That doesn't really tell me much.

> For the 3.0 release we have not concentrated on the user and administrator 
> experience much at all. Therefore there are very few management tools at this 
> point. Therefore there is also no documentation for the few existing tools, 
> since major restructuring seems to be coming.

I've played with Z2 (and Plone) a little. I'm a very long way from being 
a Z2 expert, but it does seem rather unorganised. So far, Z3 looks like 
an excellent restart, so I'd prefer to concentrate my efforts on 
learning Z3. However, documentation is severely lacking, so it looks 
like yet another uphill battle.

Don't get me wrong: so far, the book is great. It concentrates on the 
framework, but that leaves out a lot of stuff. The few tutorials I've 
found also concentrate on the framework. This leaves huge gaps which I 
have to navigate through. That means I have to ask more questions. :-)

PJDM
-- 
Peter Mayne
Spherion Technology Solutions
Canberra, ACT, Australia
"You're given the form, but you have to write the sonnet yourself.
What you say is completely up to you." - Mrs. Whatsit



More information about the Zope3-dev mailing list