[Zope] Help - Python

J M Cerqueira Esteves jmce@artenumerica.com
Wed, 24 Jan 2001 15:44:56 +0000


Olá :)

On Tue, Jan 23, 2001 at 08:56:34PM +0000, Paula Mangas wrote:
> I'm a newbie and i would like to know how can i create a DTMLDocument from
> a Python method.

Here is a short example of document creation (with a few other tips), 
assuming it's in a Python method with parameters (self, REQUEST):

#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 

# ...

# The following refers to folder  "/farm", in a virtual host 
# supported by SiteRoot.
farm = REQUEST.PARENTS[-2].farm
# `farm' now refers to the folder object.
# And this is a subfolder, "/farm/the_ducks"
the_ducks = farm.the_ducks
# This just reads the id for a new document from a submitted form,
# using a default value if no `duck_id' was sent.
id = REQUEST.get ('duck_id', 'new_duck_in_town')

duck_notes = ...
some_title = ...
some_colour = ...

# This creates the document (under "/farm/the_ducks"), assuming you have 
# defined some string, `duck_notes', holding the initial content for it:
the_ducks.manage_addProduct['OFSP'].manage_addDTMLDocument (id, 
                                                            file = duck_notes)
# This changes the document's title (it already had an empty one by default).
the_ducks[id].manage_changeProperties ({'title': some_title})
# And this adds a property of type `string'.
the_ducks[id].manage_addProperty ('colour', some_colour, 'string')
#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 

Look for some API documentation in Zope's internal help and on the Web.
Browsing Zope sources may also be most helpful...

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/