StructuredDocument PUT_factory problem
I have a folder where I want to create StructuredDocuments via ange-ftp using emacs. I wrote a PUT_Factory external method to make StructuredDocument the default for text/plain or text/html PUTs, but I am getting an error when I try the constructor. I have added some extra stuff to see what is getting passed to the put factory, which I'll include below def PUT_factory( self, name, typ, body ): """ Override the default PUT method to make STX page the default type for ftp uploads """ from Products.StructuredDocument import StructuredDocument h = open('/home/jdhunter/tmp/zope.out', 'w') h.write('name = %s, typ= %s, \nbody = %s\n' % (name, typ, body)) if typ == 'text/plain' or typ=='text/html': try: ob = StructuredDocument( body, __name__=name ) except: h.write('Could not create STX') ob = None return ob return None Here is the output file ~/tmp/zope.out. Any idea why my PUT_Factory is failing? name = test3, typ= text/html, body = Structured Text - Introduction Structured text uses indentation and simple symbology to indicate the structure of a document. Elements of a Structured Text |-------------------------------------------| | A simple sample Table | |===========================================| | *emphasized* | **strong** | _underlined_ | |-------------------------------------------| | "Link to ZOPE":http://www.zope.org/ | |-------------------------------------------| Text enclosed in brackets [footnote] is treated as hyperlinks within the document. Three types of lists - Unordered lists with '-', '*', or 'o' 1 Ordered lists with digits Description -- A paragraph with a first line that contains some text, followed by some white-space and '--' is treated as a descriptive list element. Example code Sub-paragraphs of a paragraph that ends in '::' is treated as example code:: <html>...</html> .. [footnote] Here is the footnoote. Could not create STX
John Hunter writes:
... if typ == 'text/plain' or typ=='text/html': try: ob = StructuredDocument( body, __name__=name ) except: h.write('Could not create STX') ob = None return ob return None ... Output: ... Could not create STX Look at Python's "traceback" module (--> Python Library Reference). It contains the function "print_exc" that allows you to format the exception and put the result into a file. This will tell you the cause of the problem.
Dieter
"Dieter" == Dieter Maurer <dieter@handshake.de> writes:
Dieter> Look at Python's "traceback" module (--> Python Library Dieter> Reference). It contains the function "print_exc" that Dieter> allows you to format the exception and put the result into Dieter> a file. This will tell you the cause of the problem. Thanks, that's a handy one to know. They problem was that I was loading the module, not the class, with from Products.StructuredDocument import StructuredDocument I needed from Products.StructuredDocument.StructuredDocument import StructuredDocument The traceback gave it away Traceback (most recent call last): File "/usr/local/Zope/Extensions/PUT_STXPage.py", line 14, in PUT_factory ob = StructuredDocument( body, __name__=name ) TypeError: object of type 'module' is not callable Thanks, John Hunter
participants (2)
-
Dieter Maurer -
John Hunter