[Zope] Re: manage_AddProduct for ZPT

beno zope@thewebsons.com
Sun, 05 Jan 2003 07:35:14 -0400


At 12:24 PM 1/5/2003 +0100, you wrote:
>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)" />

I tried that first...it didn't work. And yes, the above *does* work in 
other contexts.


>All in all your approach seems very strange to me!

I'm being fancy here and this is a luxury.


>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...;)

I'll go with that. Here's what I'm doing:

Redirect the browser to a script with a value such as *index.pt*
The script determines if *index.pt* exists. If it does not, it creates it 
and writes standardized content to the page template.
That page template then calls another page template that *does* exist which 
has the real content of the page.

Why? I build sites with inline frames. I want the content of the page to 
appear *both* in the inline frame *and* within a noframes tag to satisfy 
search engine spiders. I only want to write the content once. There is no 
need to write the calling page (*index.pt*) explicitly when I can do it 
programmatically. The page will be called from a navigation widget I create.

So...How do I build it?
TIA,
beno