Hi; I have this in a page template: <html> <body> <table> <tr> <td tal:define="num python:here.scripts.getQuote"> <span metal:use-macro="here/en-us/quotes/?num/macros/quote" /><br /> <div align="center"> <span class="text"> <a href="quotes.pt" target="_top"><b>The quotes</b></a> </span> </div> </td> </tr> </table> </body> <html> Now, I thought that was the correct way to call the variable "num" (that is, with the question mark: "?num"). Apparently, I'm mistaken. I've even tried defining it this way: <td tal:define="num python:str(11)"> to make sure that num was properly assigned. What am I missing? Also, if I have a dir called "scripts" in which "getQuote" exists, and "scirpts" is in the path, shouldn't that notation work okay? TIA, Victor
--On 2. Januar 2008 14:44:24 -0400 Victor Subervi <victorsubervi@gmail.com> wrote:
<td tal:define="num python:here.scripts.getQuote">
As in nearly all other programming languages methods are called with parentheses - or?
<span metal:use-macro="here/en-us/quotes/?num/macros/quote" /><br />
Now, I thought that was the correct way to call the variable "num" (that is, with the question mark: "?num"). Apparently, I'm mistaken. I've even tried defining it this way:
Not sure if using the '?' will working within a TALES expression. It will at least work as the last item with an expression. However it will fail in general if 'num' is an integer. -aj
Victor Subervi wrote at 2008-1-2 14:44 -0400:
... <html> <body> <table> <tr> <td tal:define="num python:here.scripts.getQuote">
As Andreas already has pointed out, you probably need "getQuote()" rather than "getQuote" (as the name suggests, it is a method not a value).
<span metal:use-macro="here/en-us/quotes/?num/macros/quote" /><br />
"?var" in a path expression means: replace "?var" by the value of "var". Therefore, if "num" contains the right value, the above should work. -- Dieter
Thank you both. However, it still doesn't work :( I have replaced "getQuote" with "getQuote()", but to no avail. Other ideas? *Error Type: RuntimeError Error Value: external method could not be called because it is None* *TIA,* *Victor* On Jan 3, 2008 2:26 PM, Dieter Maurer <dieter@handshake.de> wrote:
Victor Subervi wrote at 2008-1-2 14:44 -0400:
... <html> <body> <table> <tr> <td tal:define="num python:here.scripts.getQuote">
As Andreas already has pointed out, you probably need "getQuote()" rather than "getQuote" (as the name suggests, it is a method not a value).
<span metal:use-macro="here/en-us/quotes/?num/macros/quote" /><br />
"?var" in a path expression means: replace "?var" by the value of "var".
Therefore, if "num" contains the right value, the above should work.
-- Dieter
Victor Subervi wrote at 2008-1-4 10:59 -0400:
Thank you both. However, it still doesn't work :( I have replaced "getQuote" with "getQuote()", but to no avail. Other ideas? *Error Type: RuntimeError Error Value: external method could not be called because it is None*
You see here how important it is to always provide full problem description. Usually, beside "Error Type" and "Error Value" the traceback, too, is very important. The error information above tells you that your problem is not the "?num" but your "External Method". Unfortunately, the information is not very precise. You need the following background information: When an "External Method" cannot be loaded (e.g. because its source is not found), then it is represented as "None". You get more information, when you visit the "External Method" in the ZMI and press "edit". -- Dieter
That was too wierd. I deleted the External Varible, then re-added it, and all worked well! Now, I just built this new server and transfered over the Data.fs files. Maybe that was the problem?? Thanks, Victor On Jan 5, 2008 3:11 PM, Dieter Maurer <dieter@handshake.de> wrote:
Victor Subervi wrote at 2008-1-4 10:59 -0400:
Thank you both. However, it still doesn't work :( I have replaced "getQuote" with "getQuote()", but to no avail. Other ideas? *Error Type: RuntimeError Error Value: external method could not be called because it is None*
You see here how important it is to always provide full problem description. Usually, beside "Error Type" and "Error Value" the traceback, too, is very important.
The error information above tells you that your problem is not the "?num" but your "External Method".
Unfortunately, the information is not very precise. You need the following background information:
When an "External Method" cannot be loaded (e.g. because its source is not found), then it is represented as "None".
You get more information, when you visit the "External Method" in the ZMI and press "edit".
-- Dieter
On Wed, Jan 02, 2008 at 02:44:24PM -0400, Victor Subervi wrote:
Hi; I have this in a page template:
<html> <body> <table> <tr> <td tal:define="num python:here.scripts.getQuote"> <span metal:use-macro="here/en-us/quotes/?num/macros/quote" /><br /> <div align="center"> <span class="text"> <a href="quotes.pt" target="_top"><b>The quotes</b></a> </span> </div> </td> </tr> </table> </body> <html>
Now, I thought that was the correct way to call the variable "num" (that is, with the question mark: "?num"). Apparently, I'm mistaken. I've even tried defining it this way:
I didn't see a followup on this post, so I thought I would add my ignorance to the discussion. first, I don't think you can assign a variable name to a python function using tal and then have tal 'call' the function. second, I think what you do want is the get the results of calling getQuote into the variable called 'num', and then use those results elsewhere. I think tal variables can all be first class python objects. If not, any standard python object works -- in other words, a list, tupple, string, dictionary, etc. If you have your own object, it will need to have an iterator method defined for it -- but then, I wouldn't know how to make the new class known to zope.
<td tal:define="num python:str(11)"> to make sure that num was properly assigned. What am I missing? Also, if I have a dir called "scripts" in which "getQuote" exists, and "scirpts" is in the path, shouldn't that notation work okay?
acquisition will find many things. What does getQuote return though?
TIA, Victor
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- David Bear phone: 602-496-0424 fax: 602-496-0955 College of Public Programs/ASU University Center Rm 622 411 N Central Phoenix, AZ 85007-0685 "Beware the IP portfolio, everyone will be suspect of trespassing"
participants (4)
-
Andreas Jung -
David Bear -
Dieter Maurer -
Victor Subervi