Message 12923

Author
digitalsatori
Date
2013-03-31.16:39:27
Message id
12923

Content

I'm testing on the latest version of trytond and party_vcarddav. The 
carddav client is 'cadaver'
Revision:           trytond: 3041:b7fde303acd4 ; 
party_vcard:110:8726038389a6

The first attempt to connect to Tryton's webdav server:
cadaver is able to connect to Webdav server and list all the database 
available. When trying to access carddav by issuing 'cd Contacts', the 
client got the following error:
Could not access /tryton1/Contacts/ (not WebDAV-enabled?):
207 Multi-Status

the server got this traceback:

ERROR:webdav:Exception:
Traceback (most recent call last):
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/protocols/webdav.py", 
line 307, in _get_dav_resourcetype
     res = Collection.get_resourcetype(dburi, cache=CACHE)
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/modules/party_vcarddav/webdav.py", 
line 156, in get_resourcetype
     from DAV.constants import COLLECTION, OBJECT
ImportError: No module named DAV.constants

changing DAV to pywebdav.lib solved the problem

The second attempt:
with the above chang, I can use cadaver cd into 'Contacts' directory and 
ls to show a list of 'vcf' files, But when trying 'cat xxxx.vcf', the 
client got the following error:
cat 175d6109-bdaf-4d9d-8630-18a8d0466db1.vcf
Displaying `/tryton1/Contacts/175d6109-bdaf-4d9d-8630-18a8d0466db1.vcf':
Failed: 500 Internal Server Error

the server traceback:

ERROR:webdav:Exception:
Traceback (most recent call last):
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/protocols/webdav.py", 
line 234, in get_data
     res = Collection.get_data(dburi, cache=CACHE)
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/modules/party_vcarddav/webdav.py", 
line 264, in get_data
     {'id': party_id, 'ids': [party_id]})
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/modules/party_vcarddav/party.py", 
line 292, in execute
     parties = Party(ids)
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/model/modelstorage.py", 
line 1168, in __init__
     super(ModelStorage, self).__init__(id, **kwargs)
   File 
"/home/tony/projects/tryton-repo/trytond/trytond/model/model.py", line 
544, in __init__
     id = int(id)
TypeError: int() argument must be a string or a number, not 'list'

It seems the model object won't accept list as its parameter, so I did 
the below change:
change the line 292 in party.py
from: parties = Party(ids)
to: parties = (Party(id) for id in ids)

and redo the cat xxx.vcf test, still got the following client error:
dav:/tryton1/Contacts/> cat 175d6109-bdaf-4d9d-8630-18a8d0466db1.vcf
Displaying `/tryton1/Contacts/175d6109-bdaf-4d9d-8630-18a8d0466db1.vcf':
Failed: Could not read response body: connection was closed by server

server traceback:

Exception happened during processing of request from 
('::ffff:127.0.0.1', 32964, 0, 0)
Traceback (most recent call last):
   File "/usr/lib/python2.7/SocketServer.py", line 582, in 
process_request_thread
     self.finish_request(request, client_address)
   File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
     self.handle()
   File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
     self.handle_one_request()
   File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in 
handle_one_request
     method()
   File 
"/usr/local/lib/python2.7/dist-packages/pywebdav/lib/WebDAVServer.py", 
line 277, in do_GET
     status_code = self._HEAD_GET(with_body=True)
   File 
"/usr/local/lib/python2.7/dist-packages/pywebdav/lib/WebDAVServer.py", 
line 262, in _HEAD_GET
     content_type, headers)
   File 
"/usr/local/lib/python2.7/dist-packages/pywebdav/lib/WebDAVServer.py", 
line 117, in send_body_chunks_if_http11
     self.send_body(DATA, code, msg, desc, ctype, headers)
   File 
"/usr/local/lib/python2.7/dist-packages/pywebdav/lib/WebDAVServer.py", 
line 110, in send_body
     self.wfile.write(DATA.read())
AttributeError: 'buffer' object has no attribute 'read'

The error implied that the pywebdav.WebDAVServer.py is trying to 'read' 
from a 'buffer' object, which didn't implement 'read' method.
It seems this problem can be tackled by 2 ways: change at pywebdav lib 
side or at the party_carddav module side.

I choose to change the line 297 in party.py from:
         return ('vcf', buffer(data), False, action_report.name)
to:
         return('vcf', data, False, action_report.name)

After this change, the cat test passed, the content of vcf was shown.

However, I'm not sure whether this change is valid, or we should do 
other way around to modify the code at the pywebdav side.

Best regards,

Tony Gu
History
Date User Action Args
2013-03-31 16:39:28digitalsatorisetrecipients: + ced
2013-03-31 16:39:28digitalsatorilinkissue3107 messages
2013-03-31 16:39:27digitalsatoricreate

Showing 10 items. Show all history (warning: this could be VERY long)