[Zope] upload without form as ExtDocument...how???

Vineet.Ahuja@de.abb.com Vineet.Ahuja@de.abb.com
Tue, 9 Oct 2001 16:30:53 +0200


Dear all,

I am trying to upload an extDocument which is located on my system without
using the form but only using an external python script.(I am doing it
because I have about 500 msworld files and i want to create a loop in
test.py.(and I dont want to use Form)Please Help me!

test.py:-
def testext(self):
    f = open ("vin.doc","rb")
    dataread=f.read()
    fname='myvineet123'
    self.manage_addProduct['ExtDocument'].manage_addExtDocument(id=fname,
title='t2', file=dataread)
    f.close()
    return dataread



Above is my external python script.And I am calling the external method in
the script below:-

testpy.py:-
for object in context.objectValues(['Folder']):
   if object.hasProperty('visible') and object.visible:
       context.testext(object)

Now as I run testpy.py from zope i get the following error message:-
Error Type: TypeError
Error Value: open() argument 1 must be string without null bytes, not
string


Traceback (innermost last):
  File C:\zopewebs\lib\python\ZPublisher\Publish.py, line 223, in
publish_module
  File C:\zopewebs\lib\python\ZPublisher\Publish.py, line 187, in publish
  File C:\zopewebs\lib\python\Zope\__init__.py, line 226, in
zpublisher_exception_hook
    (Object: LockableItem)
  File C:\zopewebs\lib\python\ZPublisher\Publish.py, line 171, in publish
  File C:\zopewebs\lib\python\ZPublisher\mapply.py, line 160, in mapply
    (Object: testpy)
  File C:\zopewebs\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: testpy)
  File C:\zopewebs\lib\python\Shared\DC\Scripts\Bindings.py, line 324, in
__call__
    (Object: testpy)
  File C:\zopewebs\lib\python\Shared\DC\Scripts\Bindings.py, line 354, in
_bindAndExec
    (Object: testpy)
  File C:\zopewebs\lib\python\Products\PythonScripts\PythonScript.py, line
363, in _exec
    (Object: testpy)
    (Info: ({'script': <PythonScript instance at 019A79D8>, 'context':
<Folder instance at 019D6D00>, 'container': <Folder instance at 019D6D00>,
'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 3, in testpy
    (Object: guarded_getattr)
  File C:\zopewebs\lib\python\Products\ExternalMethod\ExternalMethod.py,
line 274, in __call__
    (Object: testext)
    (Info: ((<Folder instance at 0122A5A8>,), {}, None))
  File C:\zopewebs\Extensions\test.py, line 5, in testext
    (Object: LockableItem)
  File C:\zopewebs\lib\python\Products\ExtDocument\ExtDocument.py, line 41,
in manage_addExtDocument
    (Object: LockableItem)
  File C:\zopewebs\lib\python\Products\ExtFile\ExtFile.py, line 371, in
manage_file_upload
    (Object: CatalogAware)
  File C:\zopewebs\lib\python\Products\ExtFile\ExtFile.py, line 466, in
_copy
    (Object: CatalogAware)
TypeError: (see above)

Can you kindly tell me where i am going wrong??
Best Regards,
Vineet Ahuja