Parsed XML Problem (we may need the best minds to solve this one :-)
Hi all, I'm calling an external method with this DMTL: <dtml-var "db2onehtml(_.getitem('test.xml'))"> Which works fine so long as I upload "test.xml" as a _file_. If I upload test.xml as Parsed XML I instead receive this error message: Error Type: TypeError Error Value: call of non-function (type string) <!-- Traceback (innermost last): File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/lib/zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: test) File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: test) File /usr/lib/zope/lib/python/OFS/DTMLDocument.py, line 189, in __call__ (Object: test) File /usr/lib/zope/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: test) File /usr/lib/zope/lib/python/DocumentTemplate/DT_Util.py, line 339, in eval (Object: db2onehtml(_.getitem('test.xml'))) (Info: db2onehtml) File <string>, line 0, in ? File /usr/lib/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 269, in __call__ (Object: db2onehtml) (Info: ((<ParsedXML instance at 88281c0>,), {}, None)) File /usr/lib/zope/Extensions/db2onehtml.py, line 29, in db2onehtml (Object: Traversable) TypeError: (see above) --> It appears Parsed XML items in the Zope database are not objects like files. http://www.zope.org//Wikis/DevSite/Projects/ParsedXML/ParsedXMLIsNotXMLObjec... I want to be able to treat Parsed XML as an object. I hope someone can give me a clue where to proceed. I also tried calling a python method which took the XML data from the Parsed XML and converted it to a string. I then tried feeding my external method with the string. But I just receive this error message: 'string' object has no attribute 'id' My Zope details: Zope 2.3.3 (source release, python 1.5.2, linux2) Python Version 1.5.2 (#0, Apr 10 2001, 10:03:44) [GCC 2.95.3 20010219 (prerelease)] System Platform linux2 ParsedXML (Installed product ParsedXML (ParsedXML 1.0)) Thanks everyone, Adam
+-------[ Adam Warner ]---------------------- | Hi all, | | I'm calling an external method with this DMTL: | | <dtml-var "db2onehtml(_.getitem('test.xml'))"> <dtml-var "db2onehtml(_.getitem('test.xml', 1))"> Try this as a quick off-the-top-of-my-head-might-work solution -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
On Tue, 2001-09-25 at 23:43, Andrew Kenneth Milton wrote:
+-------[ Adam Warner ]---------------------- | Hi all, | | I'm calling an external method with this DMTL: | | <dtml-var "db2onehtml(_.getitem('test.xml'))">
<dtml-var "db2onehtml(_.getitem('test.xml', 1))">
Try this as a quick off-the-top-of-my-head-might-work solution
Doesn't work. Same error message [call of non-function (type string)] Thanks for trying, Adam
On Wed, Sep 26, 2001 at 12:06:43AM +1200, Adam Warner wrote:
| I'm calling an external method with this DMTL: | | <dtml-var "db2onehtml(_.getitem('test.xml'))">
<dtml-var "db2onehtml(_.getitem('test.xml', 1))">
Try this as a quick off-the-top-of-my-head-might-work solution
Doesn't work. Same error message [call of non-function (type string)]
Would anyone of you be so kind and read some docs? To call a DTML object you need to pass a client (may be None), a namespace (also may be None) and a number (or zero number) of keyword parameters: <dtml-var "db2onehtml(_.None, _, test_xml=_.getitem('test.xml', 1))"> Inside db2onehtml the rendered test.xml will be available as string in the variable test_xml. If you want object instead of rendered string, use getitem("...", 0). Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
+-------[ Oleg Broytmann ]---------------------- | On Wed, Sep 26, 2001 at 12:06:43AM +1200, Adam Warner wrote: | > > | I'm calling an external method with this DMTL: | > > | | > > | <dtml-var "db2onehtml(_.getitem('test.xml'))"> | > > | > > <dtml-var "db2onehtml(_.getitem('test.xml', 1))"> | > > | > > Try this as a quick off-the-top-of-my-head-might-work solution | > | > Doesn't work. Same error message [call of non-function (type string)] | | Would anyone of you be so kind and read some docs? To call a DTML object | you need to pass a client (may be None), a namespace (also may be None) and | a number (or zero number) of keyword parameters: He's not calling a DTML Object, he's calling an external method. Perhaps before being so terse, you should read the whole question, the relevant part of which is ironically still in the reply. | <dtml-var "db2onehtml(_.None, _, test_xml=_.getitem('test.xml', 1))"> Actually he's calling .id() on the ParsedXML Object, and id is a string (but a function on File Objects, which is why it works on those) I've told him to use .getId(). He has other problems now, for which he will have to read some doco. -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
On Tue, Sep 25, 2001 at 11:43:12PM +1000, Andrew Kenneth Milton wrote:
He's not calling a DTML Object, he's calling an external method. Perhaps before being so terse, you should read the whole question, the relevant part of which is ironically still in the reply.
Sorry.
| <dtml-var "db2onehtml(_.None, _, test_xml=_.getitem('test.xml', 1))">
Actually he's calling .id() on the ParsedXML Object, and id is a string (but a function on File Objects, which is why it works on those)
I've told him to use .getId(). He has other problems now, for which he will have to read some doco.
So anyway I was right :( Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
Andrew has been exceptionally helpful by private email. There does indeed appear to errors in my external method that he helped uncover. The good news is that I can now call the external method and insert a premature return that does return the text of the Parsed XML object. This means I will be able to overcome the problems in my external method. Parsed XML objects not working but File objects working helped uncover problems in my external method. The XML data is indeed getting to the external method. Update: The final solution Andrew will be pleased to know was simplicity itself. Because I discovered that a "return inputdoc" returned the actual data not the filename (object) all I had to do was change inputdoc.data to inputdoc. And it turned out to be Andrew's final suggestion as well :-) "or you could try str(nameOfObject) ... which if you're lucky will return something other than <ParsedXML Instance at .....>" So again many thanks Andrew. The answer is now so obvious. The input data was already a string. So I couldn't extract the data from the string. When I was using a file it was necessary to extract the data from the file object. Oh and Oleg Broytmann my initial dtml was fine. That is: <dtml-var "db2onehtml(_.getitem('test.xml'))"> Still works as it did for file objects. Regards, Adam
participants (3)
-
Adam Warner -
Andrew Kenneth Milton -
Oleg Broytmann