Question about the default view of a ZClass named index_html
Im trying to create a product for a simplified Content Management System based on Zope (i.e. even simpler than the Zope interface ;-) ). To do this, I want the equivalent of a DTML document, with a custom editing interface... I have created a new product, containing a ZClass which has the following base classes: ZObject, CatalogAwareBase, ZDTMLDocument. I'm doing OK with this, except that I can't figure out how to make a product instance use it's default 'View' method when it is named 'index_html'. If I call it index_html, the following URLs get me a zero sized reply of mime-type text/x-unknown-content-type. http://server/MyFolder/ http://server/MyFolder/index_html However, I can use the object as http://server/MyFolder/index_html/index_html And everything goes well.... Also, if I rename the object to something else, I don't have this problem. Anyone have a solution/workaround for this bug? Greetings, Michiel
The solution for this annoying bug, is to make your product inherit from Lalos excellent renderable base class ( http://www.zope.org/Members/lalo/Renderable-ZClass ) , and make a DTMLmethod called "render" containing <dtml-var index_html> The cause seems to be in the differentiation between zope/python using __call__ or __str__ behind the curtains when publishing zclasses.. -- Geir Bækholt web-developer/zopatista geirh@funcom.com funcom oslo | webdev-team <!-- PGPid : 0x90B47B20 --> on or about, Monday, August 13, 2001, we have reason to believe that Michiel Toneman wrote something along the lines of : MT> Im trying to create a product for a simplified Content Management System MT> based on Zope (i.e. even simpler than the Zope interface ;-) ). To do MT> this, I want the equivalent of a DTML document, with a custom editing MT> interface... MT> I have created a new product, containing a ZClass which has the MT> following base classes: ZObject, CatalogAwareBase, ZDTMLDocument. I'm MT> doing OK with this, except that I can't figure out how to make a product MT> instance use it's default 'View' method when it is named 'index_html'. MT> If I call it index_html, the following URLs get me a zero sized reply of MT> mime-type text/x-unknown-content-type. MT> http://server/MyFolder/ MT> http://server/MyFolder/index_html MT> However, I can use the object as MT> http://server/MyFolder/index_html/index_html MT> And everything goes well.... Also, if I rename the object to something MT> else, I don't have this problem. MT> Anyone have a solution/workaround for this bug? MT> Greetings, MT> Michiel
On Mon, 13 Aug 2001, Geir BXkholt wrote:
The solution for this annoying bug, is to make your product inherit from Lalos excellent renderable base class ( http://www.zope.org/Members/lalo/Renderable-ZClass ) , and make a DTMLmethod called "render" containing <dtml-var index_html>
The cause seems to be in the differentiation between zope/python using __call__ or __str__ behind the curtains when publishing zclasses..
Hi Geir, This worked like a charm for me! Thanks very much.... Ok, now off to finish my latest and greatest creation ;-) Greetings, Michiel Toneman -- Anthony's Law of Force: Don't force it; get a larger hammer.
Michiel Toneman writes:
... If I call it index_html, the following URLs get me a zero sized reply of mime-type text/x-unknown-content-type.
http://server/MyFolder/ http://server/MyFolder/index_html
However, I can use the object as
http://server/MyFolder/index_html/index_html This is an effect of the following ZPublisher code (from "ZPublisher.BaseRequest.BaseRequest.traverse"): # Check for method: if path: entry_name = path.pop() elif (method and hasattr(object,method) and entry_name != method and getattr(object, method) is not None): request._hacked_path=1 entry_name = method
It explicitely checks for "entry_name != method". This probably has the purpose to avoid infinite loops. In your case, "method" is "index_html". Dieter
On Mon, 13 Aug 2001, Dieter Maurer wrote:
Michiel Toneman writes:
... If I call it index_html, the following URLs get me a zero sized reply of mime-type text/x-unknown-content-type.
http://server/MyFolder/ http://server/MyFolder/index_html
However, I can use the object as
http://server/MyFolder/index_html/index_html This is an effect of the following ZPublisher code (from "ZPublisher.BaseRequest.BaseRequest.traverse"): # Check for method: if path: entry_name = path.pop() elif (method and hasattr(object,method) and entry_name != method and getattr(object, method) is not None): request._hacked_path=1 entry_name = method
It explicitely checks for "entry_name != method". This probably has the purpose to avoid infinite loops.
In your case, "method" is "index_html".
Hi Dieter Thanks for the explanation! I've tried the solution Geir B�kholt sent me (inheriting from the Renderable-ZClass product) which worked like a charm :-) I'd already started on a custom folderish ZClass to hack around the problem, but now I only need a small adjustment to my original Product (i.e. there has to be a render method, which only calls "<dtml-var index_html>". Thanks for your help! Greetings, Michiel Toneman -- Anthony's Law of Force: Don't force it; get a larger hammer.
participants (3)
-
Dieter Maurer -
Geir B�kholt -
Michiel Toneman