From 305b48abe3195f3a7d93852637c79228885d01a2 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 12 Oct 2010 14:20:30 +0300 Subject: [PATCH] Document, calendar: Patch code from trunk-xrg branch several fixes that hadn't been backported or applied correctly. bzr revid: p_christ@hol.gr-20101012112030-snnb4fjkya4ndqkm --- .../security/ir.model.access.csv | 2 +- addons/caldav/caldav_node.py | 2 +- addons/caldav/calendar.py | 4 +- addons/document/__openerp__.py | 2 +- addons/document/content_index.py | 2 +- addons/document/nodes.py | 23 ++++++--- .../document_ftp/ftpserver/abstracted_fs.py | 1 - .../document_ftp/test/document_ftp_test3.yml | 48 +++++++++---------- addons/document_webdav/webdav_server.py | 9 +++- 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/addons/base_calendar/security/ir.model.access.csv b/addons/base_calendar/security/ir.model.access.csv index 0ae628fb720..aa269e9ff18 100644 --- a/addons/base_calendar/security/ir.model.access.csv +++ b/addons/base_calendar/security/ir.model.access.csv @@ -1,5 +1,5 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_calendar_attendee","calendar.attendee","model_calendar_attendee","base.group_user",1,1,1,0 +"access_calendar_attendee","calendar.attendee","model_calendar_attendee","base.group_user",1,1,1,1 "access_calendar_alarm","calendar.alarm","model_calendar_alarm","base.group_user",1,1,1,1 "access_res_alarm","res.alarm","model_res_alarm","base.group_user",1,1,1,1 "access_calendar_todo","calendar.todo","model_calendar_todo","base.group_user",1,1,1,1 diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index 2ddd5ffa49e..e1181726bbf 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -421,7 +421,7 @@ class res_node_calendar(nodes.node_class): self.calendar_id = hasattr(parent, 'calendar_id') and parent.calendar_id or False if res_obj: if not self.calendar_id: self.calendar_id = res_obj.id - pr = res_obj.perm_read()[0] + pr = res_obj.perm_read(context=context, details=False)[0] self.create_date = pr.get('create_date') self.write_date = pr.get('write_date') or pr.get('create_date') self.displayname = res_obj.name diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index ae9aa909642..9ca6b924e4d 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -335,8 +335,8 @@ class CalDAV(object): if cal_data.name.lower() in self.__attribute__: if cal_data.params.get('X-VOBJ-ORIGINAL-TZID'): self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value') - date_utc = cal_data.value.astimezone(pytz.utc) - self.ical_set(cal_data.name.lower(), date_utc, 'value') + date_local = cal_data.value.astimezone(_server_tzinfo) + self.ical_set(cal_data.name.lower(), date_local, 'value') continue self.ical_set(cal_data.name.lower(), cal_data.value, 'value') vals = map_data(cr, uid, self, context=context) diff --git a/addons/document/__openerp__.py b/addons/document/__openerp__.py index 16bbcd41c83..5741a7223e0 100644 --- a/addons/document/__openerp__.py +++ b/addons/document/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Integrated Document Management System', - 'version': '1.1', + 'version': '2.0', 'category': 'Generic Modules/Others', 'description': """This is a complete document management system: * User Authentication diff --git a/addons/document/content_index.py b/addons/document/content_index.py index e3b37914f8c..df2b12b5456 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -21,11 +21,11 @@ import logging import os import tempfile +from subprocess import Popen, PIPE class NhException(Exception): pass -from subprocess import Popen, PIPE class indexer(object): """ An indexer knows how to parse the content of some file. diff --git a/addons/document/nodes.py b/addons/document/nodes.py index a9b8b7167fc..67105e6bd05 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -66,6 +66,7 @@ class node_context(object): A context is a set of persistent data, which may influence the structure of the nodes. All other transient information during a data query should be passed down with function arguments. + """ cached_roots = {} node_file_class = None @@ -101,7 +102,8 @@ class node_context(object): def get_uri(self, cr, uri): """ Although this fn passes back to doc.dir, it is needed since - it is a potential caching point """ + it is a potential caching point. + """ (ndir, duri) = self._dirobj._locate_child(cr, self.uid, self.rootdir, uri, None, self) while duri: ndir = ndir.child(cr, duri[0]) @@ -495,7 +497,10 @@ class node_dir(node_database): self.write_date = dirr and (dirr.write_date or dirr.create_date) or False self.content_length = 0 self.unixperms = 040750 - self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody' + try: + self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody' + except Exception: + self.uuser = 'nobody' self.ugroup = mkdosname(dirr.company_id and dirr.company_id.name, default='nogroup') self.uidperms = dirr.get_dir_permissions() if dctx: @@ -692,7 +697,10 @@ class node_res_dir(node_class): self.write_date = dirr.write_date or dirr.create_date self.content_length = 0 self.unixperms = 040750 - self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody' + try: + self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody' + except Exception: + self.uuser = 'nobody' self.ugroup = mkdosname(dirr.company_id and dirr.company_id.name, default='nogroup') self.uidperms = dirr.get_dir_permissions() self.res_model = dirr.ressource_type_id and dirr.ressource_type_id.model or False @@ -1003,9 +1011,9 @@ class node_res_obj(node_class): uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) - res_obj = dirobj.pool.get(self.context.context['res_model']) + res_obj = dirobj.pool.get(self.res_model) - object2 = res_obj.browse(cr, uid, self.context.context['res_id']) or False + object2 = res_obj.browse(cr, uid, self.res_id) or False obj = dirobj.browse(cr, uid, self.dir_id) if obj and (obj.type == 'ressource') and not object2: @@ -1079,7 +1087,10 @@ class node_file(node_class): elif not parent.check_perms('w'): self.uidperms = 4 - self.uuser = (fil.user_id and fil.user_id.login) or 'nobody' + try: + self.uuser = (fil.user_id and fil.user_id.login) or 'nobody' + except Exception: + self.uuser = 'nobody' self.ugroup = mkdosname(fil.company_id and fil.company_id.name, default='nogroup') # This only propagates the problem to get_data. Better diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py index f69a0bbbaad..9c16e7dde55 100644 --- a/addons/document_ftp/ftpserver/abstracted_fs.py +++ b/addons/document_ftp/ftpserver/abstracted_fs.py @@ -363,7 +363,6 @@ class abstracted_fs(object): """Remove the specified directory.""" cr, node, rem = datacr assert node - cr = self.get_node_cr(node) node.rmcol(cr) cr.commit() diff --git a/addons/document_ftp/test/document_ftp_test3.yml b/addons/document_ftp/test/document_ftp_test3.yml index a3e9bd5cb40..a51f259f44e 100644 --- a/addons/document_ftp/test/document_ftp_test3.yml +++ b/addons/document_ftp/test/document_ftp_test3.yml @@ -5,10 +5,10 @@ from document_ftp import test_easyftp as te ftp = te.get_plain_ftp(timeout=1.0) - - I create a folder called '������������ ��������' in the server. + I create in the server a folder called 'Äïêéìáóôéêüò ÖÜêåëëïò' - !record {model: document.directory, id: dir_itests }: - name: '������������ ��������' + name: 'Äïêéìáóôéêüò ÖÜêåëëïò' parent_id: document.dir_root - And then I create another folder, under it, through FTP @@ -16,68 +16,68 @@ !python {model: ir.attachment}: | cr.commit() from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������') - ftp.mkd("�������� ��� ����") + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò') + ftp.mkd("ÖÜêåëëïò áðü êÜôù") - I check that this folder exists at the server - - !assert {model: document.directory, id: , search: "[('name','=','�������� ��� ����')]" }: + !assert {model: document.directory, id: , search: "[('name','=','ÖÜêåëëïò áðü êÜôù')]" }: - parent_id != False - - I login with FTP and check that '������������ ��������' is there + I login with FTP and check that 'Äïêéìáóôéêüò ÖÜêåëëïò' is there - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') - - I create a file named '������' into that folder + I create a file named 'ÄïêéìÞ' into that folder - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') - fdata = StringIO('������� �� utf-8') - ftp.storbinary('STOR ������.txt', fdata) + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') + fdata = StringIO('êåßìåíï ìå utf-8') + ftp.storbinary('STOR ÄïêéìÞ.txt', fdata) - - I remove the '������.txt' file + I remove the 'ÄïêéìÞ.txt' file - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') - ftp.delete('������.txt') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') + ftp.delete('ÄïêéìÞ.txt') - - I rename '�������� ��� ����' into '�����' + I rename 'ÖÜêåëëïò áðü êÜôù' into 'Üëëïò' - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������') - ftp.rename("�������� ��� ����", "�����") + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò') + ftp.rename("ÖÜêåëëïò áðü êÜôù", "Üëëïò") - - I place a file 'file �3' in '�����' + I place a file 'file Ö3' in 'Üëëïò' - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') - fdata = StringIO('�� ���� �������') - ftp.storbinary('STOR file �3.txt', fdata) + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') + fdata = StringIO('êé Üëëï êåßìåíï') + ftp.storbinary('STOR file Ö3.txt', fdata) - I rename the file into file+range(1..200) (large filename) - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') vuvuzela = 'b'+''.join('z' * 200)+'!' - ftp.rename("file �3.txt", vuvuzela) + ftp.rename("file Ö3.txt", vuvuzela) - I delete the file with the large name - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') vuvuzela = 'b'+''.join('z' * 200)+'!' ftp.delete(vuvuzela) diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index 7e4bb69fa0a..548c9539b96 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -81,7 +81,14 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler): def setup(self): self.davpath = '/'+config.get_misc('webdav','vdir','webdav') - self.baseuri = "http://%s:%d/"% (self.server.server_name, self.server.server_port) + addr, port = self.server.server_name, self.server.server_port + server_proto = getattr(self.server,'proto', 'http').lower() + try: + addr, port = self.request.getsockname() + except Exception, e: + self.log_error("Cannot calculate own address:" , e) + # Too early here to use self.headers + self.baseuri = "%s://%s:%d/"% (server_proto, addr, port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose) def copymove(self, CLASS):