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

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Sep 24 06:24:32 EDT 2004


On Thursday 23 September 2004 21:23, Peter Mayne wrote:
> I was experimenting with the createObject() method described in section
> 9.4, which seemed to be recommended. If creating an object is this easy,
> why bother with createObject() and factories?

First of all, factories are often not just the class. In fact, they commonly 
are not the class. Often they are a function that puts a security proxy 
around the object, once it is created. See the 'zope:content' directive 
handler to see what I am talking about.

> Having now just created a new object, I've tried to rename it:
>
>          msg = self.context['msg1']
>          del self.context['msg1']
>          self.context['msg2'] = msg
>
> which didn't work.

Mmmh, this should have worked, since it calls all the necessary code. 

> On a hunch, a "grep -r rename" found  zope.app.copypastemove.rename which 
does the trick, 

You see, the book fulfilled its goal. It empowered you enough so that you can 
find and understand things yourself.

> but the Handbook doesn't mention this anywhere. 

Right. I do not think programming-based copy and move are such common 
operations that it is worth mentioning in the book.

> Even sadder, rename() doesn't even have a 
> docstring. (Yes, I know it's obvious in this case, but its the principle
> of the thing. :-)

The documentation of rename is really in the ObjectMover class. But please 
feel free to add some documentation to the rename() function itself for 
clarity.

> A low-level fundamentals chapter in the Handbook would be very
> informative.

Could you list a set of topics that you would consider fundamental? I think 
part C & D talk about the fundamental steps already.

> Or is there somewhere else that this kind of stuff is 
> documented, along with things like "how do I pack my Data.fs": do I
> really have to write my own Application Control (chapter 35)?

It is correct that I originally developed this control for the book. However, 
it was also intended to go into the Zope core as soon as I was done, where it 
is now. I just believe in using useful and real-world examples to show how 
something can be accomplished.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-dev mailing list