Roundup Tracker - Issues

Issue 995565

classification
ZRoundup doesn't work with file uploads
Type: Severity: normal
Components: Web interface Versions:
process
Status: closed fixed
:
: richard : fresh, njs, richard
Priority: normal :

Created on 2004-07-21 21:59 by njs, last changed 2004-11-05 04:40 by richard.

Messages
msg1397 Author: [hidden] (njs) Date: 2004-07-21 21:59
Running a tracker under ZRoundup (even the updated one
that fixes the bug I filed yesterday), file uploads
don't work.  Apparently something is expecting file
data to be passed as a string, but it's getting some
sort of Zope wrapper instead...

This is with the anydbm backend, though I suspect other
backends would see similar problems:

TypeError: argument must be string or read-only buffer,
not instance

/usr/lib/python2.1/site-packages/roundup/backends/blobfiles.py
in storefile(self=<back_anydbm instance at 92a514c>,
classname='file', nodeid='3', property=None,
content=<ZPublisher.HTTPRequest.FileUpload instance>)

/usr/lib/python2.1/site-packages/roundup/backends/back_anydbm.py
in create(self=<hyperdb.Class "file">,
**propvalues={'name': 'ZRoundup.py', 'type':
'text/x-python'})

/usr/lib/python2.1/site-packages/roundup/cgi/actions.py
in _createnode(self=<roundup.cgi.actions.EditItemAction
instance>, cn='file', props={'content':
<ZPublisher.HTTPRequest.FileUpload instance>, 'name':
'ZRoundup.py', 'type': 'text/x-python'})

/usr/lib/python2.1/site-packages/roundup/cgi/actions.py
in _editnodes(self=<roundup.cgi.actions.EditItemAction
instance>, all_props={('file', '-1'): {'content':
<ZPublisher.HTTPRequest.FileUpload instance>, 'name':
'ZRoundup.py', 'type': 'text/x-python'}, ('issue',
'1'): {}}, all_links=[('issue', '1', 'files', [('file',
'-1')]), ('issue', '1', 'messages', [('msg', '-1')])],
newids=None)

[...]

(oh, in case you're puzzled, it says ZRoundup.py
everywhere because the new version of that file was the
file I had lying around and used to test adding an
attachment...)
msg1398 Author: [hidden] (njs) Date: 2004-08-02 08:54
Logged In: YES 
user_id=765

Any ETA on this bug?  If not soon, any pointers on where to
look to fix it myself?   Thanks!
msg1399 Author: [hidden] (richard) Date: 2004-08-02 09:14
Logged In: YES 
user_id=6405

There is a potential contribution from another person which has 
significant impact on this bug. I'm awaiting a reply from them. 
msg1400 Author: [hidden] (fresh) Date: 2004-11-04 12:01
Logged In: YES 
user_id=24723

Using Roundup 0.7.8, this is still a problem for me.

The (edited by my) traceback I get is:

TypeError: argument 1 must be string or read-only buffer,
not instance
/usr/local/lib/python2.3/site-packages/roundup/backends/blobfiles.py
in storefile(self=<roundpsycopgsql 0x429c8b0c>,
classname='file', nodeid='3', property=None,
content=<ZPublisher.HTTPRequest.FileUpload instance>)
   85            
self.transactions.append((self.doStoreFile, (classname, nodeid,
   86                 property)))
   87         open(name, 'wb').write(content)
      global open = undefined, name =
'/roundup/simplistix/db/files/file/0/file3.tmp', global
write = undefined, content =
<ZPublisher.HTTPRequest.FileUpload instance>
msg1401 Author: [hidden] (fresh) Date: 2004-11-04 12:45
Logged In: YES 
user_id=24723

This patch works for me on 0.7.8's ZRoundup.py:

--- ZRoundup.py.original        Thu Nov  4 12:20:03 2004
+++ ZRoundup.py Thu Nov  4 13:00:21 2004
@@ -75,18 +75,14 @@
         self.value = value
         if hasattr(self.value, 'filename'):
             self.filename = self.value.filename
-            self.file = self.value
+            self.value = self.value.read()
 
 class FormWrapper:
     '''Make a Zope form dict look like a cgi.py one
     '''
     def __init__(self, form):
         self.form = form
-        self.value = []
     def __getitem__(self, item):
-        for entry in self.value:
-            if entry.name == item:
-                return entry
         entry = self.form[item]
         if isinstance(entry, type([])):
             entry = map(FormItem, entry)
@@ -99,16 +95,9 @@
         else:
             return default 
     def has_key(self, item):
-        for entry in self.value:
-            if entry.name == item:
-                return 1
         return self.form.has_key(item)
     def keys(self):
-        l = [e.name for e in self.value]
-        for name in self.form.keys():
-            if name not in l:
-                l.append(name)
-        return l
+        return self.form.keys()
 
 class ZRoundup(Item, PropertyManager, Implicit, Persistent):
     '''An instance of this class provides an interface
between Zope and
msg1402 Author: [hidden] (richard) Date: 2004-11-05 04:40
Logged In: YES 
user_id=6405

Patch applied in HEAD and maint-0-7, thanks!
msg1403 Author: [hidden] (fresh) Date: 2004-11-05 08:54
Logged In: YES 
user_id=24723

Just to note though: this patch is probably not a good thing
if you have very large files, since it'll read the whole
file into memory.

Mindyou, what kind of idiot puts very large files into an
issue tracker? right? ;-)
History
Date User Action Args
2004-07-21 21:59:12njscreate