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

Peter Mayne PeterMayne at ap.spherion.com
Tue Sep 28 20:45:47 EDT 2004


Stephan Richter wrote:
> 
> Okay, I'll add some more explanation there.

Excellent. My work here is done. :-)

> I just thought of the chapter that demonstrates adding objects manually, and 
> it does not even use factories. <grin> The XML-RPC chapter shows you how to 
> create a message using Python.

Ah, I haven't read that chapter because I currently have no need for 
XML-RPC.

Incidentally, why in deleteMessage() do you use 
"self.context.__delitem__(name)" instead of "del self.context[name]"? 
Using a "__" method seems a bit low level.

> In this case I did not need the factory, since 
> I do not care about security. Note that I still have to create the 
> ObjectCreatedEvent for the object, so that subscribers to this event have a 
> chance to do their work as well. This is really important. The workflow 
> manager listens to this event and adds the workflow to the message, once it 
> is created.
> 
> Here is another great advantage of factories. Factories are Python path 
> independent. For example, if you use a the MessageBoard in your application 
> and you use the class directly, then you are screwed, if I move the package 
> to another location in the Python path and you will have to correct your 
> import. If you use the factory instead, you have to make no changes to the 
> code, since the factory id will not change.

Excellent stuff. Please add it to the book.

>>How do I traverse the database?
> 
> That's a ZODB issue. At first I wanted to document the ZODB a bit too, but 
> eventually decided against it, since it is a huge task and worth another 
> small book. There is plenty ZODB documentation out there.

Fair enough.
> 
> If you talk about the Zope 3 application traversal framework, I agree I 
> neglected this a bit. But it would be a couple sentences only, since 
> traversal is usually done for you by the publisher.

A couple of sentences is better than nothing.

>>How do I find things in the database?
> 
> What do you mean by "find"?

At the moment I'm trying to reproduce the Archetype Reference attribute 
functionality. I'd like to show the user a list of existing objects of a 
particular type, from a particular context. IFind seems to be what I 
want here, which I found by guessing "find" and using grep -r.

>>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? 
> 
> I provided you a way in the book using XML-RPC and FTP. Low-level Python 
> inspection of the ZODB is left for ZODB to document.

I'll expand on this in another thread,

>>Glimpses of the API. 
> 
> 
> I believe I cover the most common API calls and features for an application 
> developer. There are bits and pieces that I do not cover, but I hate books 
> with a thousand pages.

Why? The more information, the better. :-)

>>>>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.
> 
> Not true, though I meant to write chapter 13.
> http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/contentobject.html

I was using an older version of the book. Still only one extra sentence, 
though. :-)

> Of course, nothing is very complete at this point. It will take some exposure 
> of the software to see what people really need to know. While writing the 
> book I have asked people numerous times of what they think is missing from 
> the book and have commonly added chapters based on their recommendation. I am 
> hesitant to do so now, since the book has been delivered to the publisher 
> already. However, I am open to suggestions for the 3.1 edition.

Again, fair enough.

>>That means I have to ask more questions. :-) 
> 
> No problem, as long as you document the answers and your experience in one 
> form or another publically, for example in a small how-to.

No problem.

Thanks for your answers.

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