[Zope-dev] Question to acquisition

Jim Fulton jim@digicool.com
Thu, 10 Jun 1999 11:28:41 +0000


Thomas Riedl wrote:
> 
> Hello Jim,
> 
> I've been able to overcome my problem, but - honestly - I still do
> not understand how and why it works this and breaks that way.
> 
> Just to sum up:
> I've a product, called SDB.
> It has a class SDB, whose instances are publisheable (right term?).
> This class inherits among others from Acquisition.Implicit.
> Still using Zope-1.10.2, SuSe-5.1, "python serve.py".
> 
> I've a DTML form which I want to parameterize and return upon
> python code actions, like if a 'change this' method is called, it
> 'returns' depending on its results an 'OK' button or a 'Go there, again!'
> button; let's call it 'sdb_button.dtml'.
> It also contains a line "<!--#var standard_html_header-->".
> 
> The class 'SDB' has a (callable) attribute
>         TEST=HTMLFile('sdb_button', globals(),
>                 <some argument defaults by keywords>)
> 
> It also has some method
>         def change_things(....):
>                 ...
>                 return self.TEST(
>                         self.aq_parent, # relevant stuff

Have you tried passing just self? If the object is an 
Implicit acquirer, then you shouldn't need to get aq_parent.

>                         <several arguments by keywords>
>                         )
> Now, if I call "http://...../instance1/TEST", I get what I want.

ZPublisher automatically passes self to test when calling TEST.
It does this, because DocumentTemplates have the argument 'self'
in their signatures.

> If I call ..../instance1/change_things, I get what I want, too.
> 
> But: If I leave out the 'self.aq_parent' argument, change_things() chokes
> on a key error since it doesn't know about standard_html_header.

Right.  Where else would it get standard_html_header?
 
> So, I work around my problem and insert self.aq_base, but I don't

You mean self.aq_parent, but self should do.

> understand why TEST works without and change_things doesn't.

Because ZPublisher passes self to TEST and change_thing neeeds to 
too.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.