Issue 3107

Title
party_vcarddav is not working
Priority
bug
Status
resolved
Nosy list
ced, digitalsatori
Assigned to
ced
Keywords

Created on 2013-03-31.14:14:53 by digitalsatori, last changed 99 months ago by ced.

Files

File name Uploaded Type Details
changes.patch digitalsatori, 2013-03-31.14:16:09 text/plain view

Messages

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2013-04-06.12:24:57
Fixed with rev f9ea5904821c
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2013-04-01.22:54:11
For the remain issue, please test patch at review753002
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2013-04-01.22:48:49
list of ids instantiation fixed in rev da2399d811cf
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2013-04-01.22:44:30
Import fixed with rev b29b98443d15
Author: [hidden] (digitalsatori)
Date: 2013-03-31.16:39:27
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
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2013-03-31.14:18:20
Please give the information about why it is not working.
Author: [hidden] (digitalsatori)
Date: 2013-03-31.14:14:51
I'm able to make it functioning by modifying 3 lines of code.(please refer to
the patch file attached)

As I'm new to tryton, don't know whether my changes are valid. And, one question
here , why we need to make the string object 'data' to buffer object through
buffer(data) which actually cause the problem. 

I remove the conversion, the module works, but I don't know whether it is more
logical to change at the library pywebdav side.
History
Date User Action Args
2013-04-06 12:24:58cedsetstatus: testing -> resolved
messages: + msg12986
2013-04-01 22:54:11cedsetstatus: in-progress -> testing
messages: + msg12944
2013-04-01 22:48:50cedsetmessages: + msg12943
2013-04-01 22:44:30cedsetstatus: need-eg -> in-progress
assignedto: ced
messages: + msg12942
2013-03-31 16:39:28digitalsatorisetmessages: + msg12923
2013-03-31 14:18:21cedsetassignedto: ced -> (no value)
messages: + msg12922
keyword: - en, patch
2013-03-31 14:16:11digitalsatorisetfiles: + changes.patch
assignedto: ced
type: crash
nosy: + ced
2013-03-31 14:14:53digitalsatoricreate

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