[ZPT] RE: DreamWeaver files -> ZPTs: How?
Ken Winter
ken at sunward.org
Mon May 23 17:54:27 EDT 2005
> -----Original Message-----
> From: Ian Bicking [mailto:ianb at colorstudy.com]
> Sent: Monday, May 23, 2005 5:13 PM
> To: ken at sunward.org
> Cc: 'Chris Beaven'; zpt at zope.org
> Subject: Re: [ZPT] RE: DreamWeaver files -> ZPTs: How?
>
> Ken Winter wrote:
> >>Instead of obj.mypage.html, use obj['mypage.html']
> >>
> >
> > I'm afraid this doesn't work. Here's the Python script, with the
> suggested
> > syntax in the last line:
> >
> > d = [{'person_id':p.person_id,\
> > 'first_name':p.first_name,\
> > 'middle_names':p.middle_names,\
> > 'last_name':p.last_name}\
> > for p in context.read_all_people()]
> > return context['studentlist.htm'](data=d)
> >
> > This gets the error message:
> >
> > Site Error
> > An error was encountered while publishing this resource.
> > Error Type: KeyError
> > Error Value: 'studentlist.htm'
> >
> > The same thing happens if I rename the ZPT as 'studentlist_htm" and use
> this
> > syntax. The only version that works is this:
> >
> > return context.studentlist_htm(data=d)
>
> This is the realm of things I don't understand well, but I think
> obj.value uses a somewhat different lookup algorithm (using Acquisition)
> than obj['value']. Try getattr(context, 'studentlist.htm').
The final line:
return getattr(context, 'studentlist.htm')
evokes a page containing nothing but:
<ZopePageTemplate at studentlist.htm>
This is at least not an error message! But I don't know how to get it to
render the page instead of just showing this little identifier, or whatever
it is.
Also, I don't know how to pass parameters with this syntax. The one that
comes the closest to working is:
return getattr(context, 'studentlist.htm'(data=d))
which evokes:
Site Error
An error was encountered while publishing this resource.
Error Type: TypeError
Error Value: 'str' object is not callable
Which at least implies that this syntax is recognized as an *attempt* to
call studentlist.htm!
Suggestions?
- Ken
More information about the ZPT
mailing list