[Zope-dev] How do I call an HTMLFile in context provided by a path?

Itai Tavor itai@optusnet.com.au
Thu, 12 Apr 2001 09:58:04 +1000


Dieter Maurer wrote:

>Itai Tavor writes:
>  > I have a method that receives a path:
>  > '/MyApp/SomeSpecialist/some_id/edit_html'  and has to call edit_html
>  > in the context of some_id. If edit_html is a DTML Method, I can do
>  > this:
>  >
>  >      obj = REQUEST.traverse(path)
>I would use "restrictedTraverse" instead of "REQUEST.traverse"
>as it uses less magic.

Thanks for the tip... I thought restrictedTraverse is slower because 
it has to do security checks?

>  >      ...
>  >
>  > But when edit_html is an HTMLFile in a Python Product, obj.aq_parent
>  > doesn't work.
>Why not?

It causes this exception:

Error Type: AttributeError
Error Value: edit_htmlaq_parent

>
>This would mean that either your product is not derived
>from ExtensionClass.Base or that "HTMLFile" is not derived
>from "Acquisition.Implicit".

My product inherit does have implicit acquisition. But HTMLFile 
doesn't - that's the whole problem. Replacing HTMLFile with DTMLFile 
solves the problem, as DTMLFile derives from Acquisition.Explicit.

Thanks for pointing me in the right direction.

P.S Now that aq_parent is working... why can't I do absolute_url() on 
DTMLFiles :-(
-- 
--
Itai Tavor                      -- "Je sautille, donc je suis."    --
itai@optusnet.com.au            --               - Kermit the Frog --
-- "What he needs now is understanding... and a confederate victory" --
-- Dr. Jacobi, Twin Peaks         --