Adding an XMLDocument instance Programmatically
I am trying to write a python method which will programmatically create an instance of an (existing) XML document. (I am using Zope2.1.6 and XMLDocument 1.0a6) I am able to add an XML document by selecting the XMLDocument from the available objects ... so XMLDocument is installed correctly. Essentially I have taken the 'add' method of XMLDocument and tried to turn it into an external method. [I was able to successfully do this for the Parrot product so hopfully I am on the right track] I can' t seem to get beyond importing Document (cannot import name Document). Do I need to import other modules? Is this the best/only way to do this?? Appreciate any help. from Products.XMLDocument import Document def add(self, id, title='', file='', REQUEST=None, submit=None): """ Add a XML Document object with the contents of file. """ ob=Document() ob.title=title ob.id=id if file: ob.parse(file) id=self._setObject(id, ob) if REQUEST is not None: try: u=self.DestinationURL() except: u=REQUEST['URL1'] if submit==" Add and Edit ": u="%s/%s" % (u,quote(id)) REQUEST.RESPONSE.redirect(u+'/manage_main') return '' I appologize in advance if I have missed something obvious. Brad
I can' t seem to get beyond importing Document (cannot import name Document). Do I need to import other modules? Is this the best/only way to do this?? Appreciate any help.
from Products.XMLDocument import Document
I think you missed an 'XMLDocument'. from Products.XMLDocument.XMLDocument import Document That is: import the Document class from the XMLDocument module (file) in the XML package (directory) in the Products package. --jfarr "Perl is worse than Python because people wanted it worse." Larry Wall, 14 Oct 1998
participants (2)
-
Gaspard, Bradley S -
Jonothan Farr