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


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to