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

Peter Mayne PeterMayne at ap.spherion.com
Thu Sep 23 21:23:12 EDT 2004


Philipp von Weitershausen wrote:
> Peter Mayne wrote:
> 
>> I'm using the MessageBoard package to experiment with.
>>
>> I'd like to pre-load some messages from a package script, but after 
>> reading various documentation (including the Zope3 book and tutorials) 
>> I can't figure out how to do something as basic as create and save new 
>> objects.
> 
> You could write an event subscriber that subscribes to 
> IDatabaseOpenedEvent and then operates on the database directly. But I 
> wouldn't do that.
> 
> I would do it much simpler and write (if not already provided) XML-RPC 
> or WebDAV views/filerepresentation adapters and bulk-load objects using 
> either a custom XML-RPC client script written in Python or whatever, or 
> even a simple WebDAV or FTP client.

That's way above the level I'm thinking of. Besides, using WebDAV/FTP 
brings up the problem of not having the faintest idea what to upload to 
create a Message-type object.

Stephan Richter wrote:
 >
 > I would probably use XML-RPC; it is the easiest to do.
 >
 > You could also use an XML-File import/export tool to do the upload of 
 > data. I have such code in the bug tracker application.

Crikey, that's easy. Exactly what I was looking for, thanks.

The Zope3 Developer's Handbook does a pretty good job of describing the 
framework (despite appearing to be somewhat out of date; is there a 
newer online version anywhere?), well done. However, it seems to skip 
simple things like this.

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?

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. On a hunch, a "grep -r rename" found 
zope.app.copypastemove.rename which does the trick, but the Handbook 
doesn't mention this anywhere. 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. :-)

A low-level fundamentals chapter in the Handbook would be very 
informative. 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)?

Despite the moaning, I'm all for Zope3. :-)

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