[Zope] Re: manage_AddProduct for ZPT

Maik Jablonski maik.jablonski@uni-bielefeld.de
Sun, 05 Jan 2003 12:24:15 +0100


beno wrote:
> At 11:43 AM 1/5/2003 +0100, you wrote:
> 
>> beno wrote:
>>
>>> Hi;
>>> I would like to do the equivalent of this:
>>> <dtml-call "manage_addProduct['OFSP'].manage_addFolder(id, title)">
>>> in ZPT to create a page on-the-fly. Can it be done?
>>> TIA,
>>> beno
>>
>>
>> Hi,
>>
>> this should do it for you:
>>
>> manage_addProduct['PageTemplates'].manage_addPageTemplate(id, 
>> title=None, text=None, REQUEST=None)
> 
> 
> So I try this in a ZPT page:
> 
> <p tal:replace="structure 
> python:path(manage_addProduct['PageTemplates'].manage_addPageTemplate(id, 
> title='testing', text=None, REQUEST=None))" />
> 
> but the error says *manage_addProduct is not defined*. What am I missing?
> TIA,
> beno

Your path(...) is not a valid TAL-path-expression. You should do 
something like:

<p tal:replace="structure
python: here.manage_addProduct['PageTemplates'].manage_addPageTemplate(id,
title='testing', text=None, REQUEST=None)" />

All in all your approach seems very strange to me!

I wouldn't mix business logic into a PageTemplate... This is hard to 
maintain and read. Factor it out into a python-script and you will be 
happier... especially in 4 month or so...;)

/mj