acquisition failure puuzzle or maybe something else
Zope 2.9.X Python 2.4 Centos 4.4 Linux Firefox 2.0.0.5 (Linux and Win XP) I have a dtml method is a folder C and a folder setup / A B C scripts In the dtml method, there is a call to a script passing in a composed string made up of variables passed in through request inside of a dtml-let, <dtml-let someval="scripts.cleanfilename(cgivar1+'_'+cgivar2)" > --- methods that use someval --- </dtml-let> a pattern we have used in many places without a problem. In this particular case, Zope throws an error Traceback (most recent call last): File "/usr/local/src/zope/Zope2.9/lib/python/ZPublisher/Publish.py", line 115, in publish request, bind=1) File "/usr/local/src/zope/Zope2.9/lib/python/ZPublisher/mapply.py", line 88, in mapply if debug is not None: return debug(object,args,context) File "/usr/local/src/zope/Zope2.9/lib/python/ZPublisher/Publish.py", line 41, in call_object result=apply(object,args) # Type s<cr> to step into published object. File "/usr/local/src/zope/Zope2.9/lib/python/OFS/DTMLMethod.py", line 144, in __call__ r=apply(HTML.__call__, (self, client, REQUEST), kw) File "/usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_String.py", line 476, in __call__ try: result = render_blocks(self._v_blocks, md) File "/usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_In.py", line 630, in renderwob if self.elses: return render_blocks(self.elses, md) File "/usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_In.py", line 703, in renderwob try: append(render(section, md)) File "/usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_Let.py", line 75, in render else: d[name]=expr(md) File "/usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_Util.py", line 196, in eval return eval(code, d) File "<string>", line 1, in <expression> AttributeError: cleanfilename The failing line is (literally) <dtml-let sname="scripts.cleanfilename(user_lastname+'_'+user_firstname)" which is part of a <dtml-let> with several components. Now, the failing element is part of a method that fundamentally has a if-elif structure and the actual code fragment is embedded in a pair of nested <dtml-in> blocks which have internal <try>-<except>-<else> blocks, but that is all control structure and should not impact name/attribute resolution, or so I believe. A trace through the executing method shows the control flow is functioning as expected. Security settings appear to be correct--and the correct execution of simple test methods (see below) tend to support that conclusion. Moving the script into the same folder as the method (that is, moving it from the folder scripts to the folder C in the layout above) is a workaround, but it breaks our coding conventions. i Simple test methods in folder C <dtml-var standard_html_header> <dtml-let sss="scripts.cleanfilename('able baker charlie ')"> <dtml-var sss> </dtml-let> <dtml-var standard_html_footer> work fine and do not throw the attribute error. I suspect that this is a problem caused by some trivial error, but we've been unable to find it. Any help/suggestions as to how to resolve this puzzle would be appreciated.
----- Original Message ----- From: "Dennis Allison" <allison@shasta.stanford.edu> To: <zope@zope.org> Sent: Friday, July 27, 2007 1:18 PM Subject: [Zope] acquisition failure puuzzle or maybe something else
I have a dtml method is a folder C and a folder setup
/ A B C scripts
In the dtml method, there is a call to a script passing in a composed string made up of variables passed in through request inside of a dtml-let,
<dtml-let someval="scripts.cleanfilename(cgivar1+'_'+cgivar2)" > --- methods that use someval --- </dtml-let>
a pattern we have used in many places without a problem.
In this particular case, Zope throws an error File "<string>", line 1, in <expression> AttributeError: cleanfilename
The failing line is (literally)
<dtml-let sname="scripts.cleanfilename(user_lastname+'_'+user_firstname)"
What are the values of cgivar1 and cgivar2 when the error is thrown? (ie. does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - possible if someone enters a name with a character that will kill your code, such as o'neil) Jonathan
The values are validated and are simple strings. For our testing purpose they are things like 'aaa'. Also, if that were the problem, eval would have thrown a different error since it most likely evaluates the parameters before trying to bind the call. In our testing we have replaced the catenation with a static string but still get the error. On Fri, 27 Jul 2007, Jonathan wrote:
----- Original Message ----- From: "Dennis Allison" <allison@shasta.stanford.edu> To: <zope@zope.org> Sent: Friday, July 27, 2007 1:18 PM Subject: [Zope] acquisition failure puuzzle or maybe something else
I have a dtml method is a folder C and a folder setup
/ A B C scripts
In the dtml method, there is a call to a script passing in a composed string made up of variables passed in through request inside of a dtml-let,
<dtml-let someval="scripts.cleanfilename(cgivar1+'_'+cgivar2)" > --- methods that use someval --- </dtml-let>
a pattern we have used in many places without a problem.
In this particular case, Zope throws an error File "<string>", line 1, in <expression> AttributeError: cleanfilename
The failing line is (literally)
<dtml-let sname="scripts.cleanfilename(user_lastname+'_'+user_firstname)"
What are the values of cgivar1 and cgivar2 when the error is thrown? (ie. does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - possible if someone enters a name with a character that will kill your code, such as o'neil)
Jonathan
--
----- Original Message ----- From: "Dennis Allison" <allison@shasta.stanford.edu> To: "Jonathan" <dev101@magma.ca> Cc: <zope@zope.org> Sent: Friday, July 27, 2007 2:35 PM Subject: Re: [Zope] acquisition failure puuzzle or maybe something else
The values are validated and are simple strings. For our testing purpose they are things like 'aaa'. Also, if that were the problem, eval would have thrown a different error since it most likely evaluates the parameters before trying to bind the call. In our testing we have replaced the catenation with a static string but still get the error.
In your previous message you said: <snip> Simple test methods in folder C <dtml-var standard_html_header> <dtml-let sss="scripts.cleanfilename('able baker charlie ')"> <dtml-var sss> </dtml-let> <dtml-var standard_html_footer> work fine and do not throw the attribute error. </snip> Now you are saying that the static string does cause the error? To remove the acquisition issue: if you can get the cleanfilename routine to just return the input parameter (as a test, don't do anything else in cleanfilename) without error, then that means that you have a coding error somewhere within cleanfilename. Jonathan
On Fri, 27 Jul 2007, Jonathan wrote:
----- Original Message ----- From: "Dennis Allison" <allison@shasta.stanford.edu> To: <zope@zope.org> Sent: Friday, July 27, 2007 1:18 PM Subject: [Zope] acquisition failure puuzzle or maybe something else
I have a dtml method is a folder C and a folder setup
/ A B C scripts
In the dtml method, there is a call to a script passing in a composed string made up of variables passed in through request inside of a dtml-let,
<dtml-let someval="scripts.cleanfilename(cgivar1+'_'+cgivar2)" > --- methods that use someval --- </dtml-let>
a pattern we have used in many places without a problem.
In this particular case, Zope throws an error File "<string>", line 1, in <expression> AttributeError: cleanfilename
The failing line is (literally)
<dtml-let sname="scripts.cleanfilename(user_lastname+'_'+user_firstname)"
What are the values of cgivar1 and cgivar2 when the error is thrown? (ie. does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - possible if someone enters a name with a character that will kill your code, such as o'neil)
Jonathan
--
participants (2)
-
Dennis Allison -
Jonathan