Re: [Zope-dev] Question to acquisition
Oh no! Not me again! Will I make it into today's top ten troublemakers ?
globals() casts a pretty wide net and may catch all sorts of things you don't want to publish.
I vaguely understand. But OTOH, leaving it out makes things croak (like they don't find the DTML files and so on), and my understanding is too vague to know-what-to-supply as values.
I think that the docs describe what the first two (optional) arguments to a document template do:
- The first argument gets it's attributes included in the DTML namespace,
- The second argument gets it's keys included.
If you provide all the necessary values via attributes of the first argument or via keyword arguments, then there's no need to pass a second argument.
Hm, only ITS attributes, or automagically its inheri^H^H^H^H^H^H acquireable attributes, too?
I wasn't paying attention to this before. Don't do this. Don't put anything in an installed (ie Python) product, one with a mostly closed box.
I see.
Leaving out standard_html_header makes everything work.
sipping coffee while waiting... (wobble,gurgle)
The instance must be unable to acquire standard_html_header. You might try grabbing an instance from the Python prompt and seeing if it has a standard_html_header attribute. I assume that it doesn't.
This confronts me with a new problem:
From the Product directory I try:
tom@angua,SDB: PYTHONPATH=../..:. python ./__init__.py Traceback (innermost last): File "./__init__.py", line 1, in ? import SDB File "/usr/Zope/Zope-1.10.2-src/lib/python/Products/SDB/SDB.py", line 23, in ? class Sdb( File "/usr/Zope/Zope-1.10.2-src/lib/python/Products/SDB/SDB.py", line 42, in S db index_html=HTMLFile("sdb_index",_myglob_()); File "../../Globals.py", line 216, in __init__ elif type(_prefix) is not type(''): _prefix=package_home(_prefix) File "../../Globals.py", line 100, in package_home KeyError: SD
Also, installed products may not be helpful with acquisition. Try putting an instance in the Main Zope folder, or in a subfolder and see if you have the same problem.
According to your suggestions wrt our other thread I already did this. I use something like TEST=HTMLFile("sdb_button", globals()) which uses a standard_html_header DTML doc in my new 'Testing' Folder: it works, after being supplied with all its wanted parameters: http://......./Testing/Instance1/TEST?method=POST&action=XXX&value=YYY gives me the results I want (plus a steel blue background from the Header file); calling the 'document' from within my product code still breaks. I'm somewhat at a loss, since my insight into the relevant details is not THAT deep (though it grows with every single of our rounds). once again begging for help: tom -- MfG: Thomas Riedl =========================================================================== triedl@linuxland.de, (+49 89) 99 34 12 - 11, http://www.linuxland.de Stefan-George-Ring 24, 81929 München
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 <several arguments by keywords> ) Now, if I call "http://...../instance1/TEST", I get what I want. 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. So, I work around my problem and insert self.aq_base, but I don't understand why TEST works without and change_things doesn't. Any Zen to share, anyone? Lotsa yrs tom -- MfG: Thomas Riedl =========================================================================== triedl@linuxland.de, (+49 89) 99 34 12 - 11, http://www.linuxland.de Stefan-George-Ring 24, 81929 München
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.
Hi again, o Master of Delightful, Speedy And HELPING Answers ;-)
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.
Yes, I tried, and: Gag me with a spoon, it worked! Strange, I thought I had done almost this before sending my last email... Possibly, this way is different from my initial use like def garble(...): ... EEE=HTMLFile("sdb_button", globals()) return EEE(self, self.aq_parent, globals(), <keyword arguments>) plus/minus some permutations, which obviously did NOT what I deemed due. Well, THIS (now working) way I find your explanations and my expectations have met. Thankful beyond recognition :-) tom -- MfG: Thomas Riedl =========================================================================== triedl@linuxland.de, (+49 89) 99 34 12 - 11, http://www.linuxland.de Stefan-George-Ring 24, 81929 München
participants (2)
-
Jim Fulton -
Thomas Riedl