> -----Original Message-----
> From: Chris Beaven [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 23, 2005 6:27 PM
> To: [EMAIL PROTECTED]
> Cc: 'Ian Bicking'; zpt@zope.org
> Subject: Re: [ZPT] RE: DreamWeaver files -> ZPTs: How?
> 
> Ken Winter wrote:
> 
> >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
> >
> >
> >
> You just need to call the value returned by getattr:
> 
> return getattr(context, 'studentlist.htm')(container, container.REQUEST)
> 
> It's in the Zope Book ;)
> 
> Your attempt at calling was trying to call the string 'studentlist.htm'.
> You can't call a string (it's unlisted in the phone book).

Yessss!  For the record, the final version is:

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 getattr(context, 'studentlist.htm')(data=d)

Thanks to Ian and Chris for guiding me through this syntactic maze.

- Ken


_______________________________________________
ZPT mailing list
ZPT@zope.org
http://mail.zope.org/mailman/listinfo/zpt

Reply via email to