[Product-Developers] Re: Content creation during install

Maurits van Rees m.van.rees at zestsoftware.nl
Wed Apr 29 20:43:43 UTC 2009


Dave Turvene, on 2009-04-29:
> Maurits van Rees <m.van.rees at ...> writes:
>
>> 
>> Dave Turvene, on 2009-04-17:
>> > My question: what is the current thinking on programmatic content
>> > creation during product install?
>> 
>> What I usually do is create a browser view, called for example
>> @@initial_content_creation, that you call manually on the Plone Site.
>> Then put some lines in there that do things like create a document:
>> 
>> context.invokeFactory('Document', id='doc', title='Hello world.',
>>                       text='It is good to see you.')
>> 
>> Good places to look for how to create things programmatically are
>> tests, for example the tests in Products.CMFPlone itself.
>
> Nice.  In this case you use the BrowserView subclass as a general
> purpose logic mechanism.  Do you include a page template to show
> status?  I see the benefit of using this to isolate the creation
> logic but might get confused if there is no actual "view"
> behavior for the browser view.

Well, I would create a page template with a form.  Calling the browser
view shows that form.  Submitting the form calls the browser view,
does its thing, and either shows the page again with a portal status
messages returns a simple string to report success or failure.  I
usually add some logging in any case so I can see in the logs what
happened.

-- 
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]





More information about the Product-Developers mailing list