Re: [Zope] index.html in Python Script?
Erik Myllymaki wrote: How do address a ZPT with a name like index.html in a Python Script? The following: request = container.REQUEST RESPONSE = request.RESPONSE if not request.has_key('next_state'): return container.index.html(context, request) returns: Error Type: AttributeError Error Value: index ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) Erik, I think its failing at the DOT between index and html. Try something like: return container['index.html'](context,request) David ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] index.html in Python Script?
thanks, and this seems to do what I want to: request = container.REQUEST RESPONSE = request.RESPONSE if not request.has_key('next_state'): return container['index.html'](context, request) Phillip Hutchings wrote: On 22/04/05, Erik Myllymaki <[EMAIL PROTECTED]> wrote: How do address a ZPT with a name like index.html in a Python Script? The following: request = container.REQUEST RESPONSE = request.RESPONSE if not request.has_key('next_state'): return container.index.html(context, request) The . is the python object referencing notation, so you can't have a property called 'index.html' addressable in the normal way. Use getattr instead. return getattr(container, 'index.html')(context, request) It's all in the Zope documentation. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] index.html in Python Script?
On 22/04/05, Erik Myllymaki <[EMAIL PROTECTED]> wrote: > How do address a ZPT with a name like index.html in a Python Script? > > The following: > > request = container.REQUEST > RESPONSE = request.RESPONSE > > if not request.has_key('next_state'): >return container.index.html(context, request) The . is the python object referencing notation, so you can't have a property called 'index.html' addressable in the normal way. Use getattr instead. return getattr(container, 'index.html')(context, request) It's all in the Zope documentation. -- Phillip Hutchings http://www.sitharus.com/ [EMAIL PROTECTED] / [EMAIL PROTECTED] ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )