[MERGE] From trunk (second time)

bzr revid: cto@openerp.com-20121217145921-6pk1jrktppezuq13
This commit is contained in:
Cecile Tonglet 2012-12-17 15:59:21 +01:00
commit 331fdf8675
7 changed files with 77 additions and 30 deletions

View File

@ -20,13 +20,9 @@
##############################################################################
import logging
_logger = logging.getLogger(__name__)
import webdav
import webdav_server
import document_webdav
try:
import webdav
import webdav_server
import document_webdav
except ImportError:
_logger.info('document_webdav disabled please install PyWebDAV from http://code.google.com/p/pywebdav/downloads/detail?name=PyWebDAV-0.9.4.tar.gz&can=2&q=/')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -24,16 +24,24 @@ import sql_db
import os
import time
import errno
import re
import openerp
from openerp import netsvc
import urlparse
try:
from pywebdav.lib.constants import COLLECTION # , OBJECT
from pywebdav.lib.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from pywebdav.lib.iface import dav_interface
from pywebdav.lib.davcmd import copyone, copytree, moveone, movetree, delone, deltree
except ImportError:
from DAV.constants import COLLECTION #, OBJECT
from DAV.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from DAV.iface import dav_interface
from DAV.davcmd import copyone, copytree, moveone, movetree, delone, deltree
from DAV.constants import COLLECTION #, OBJECT
from DAV.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from DAV.iface import dav_interface
import urllib
from DAV.davcmd import copyone, copytree, moveone, movetree, delone, deltree
from cache import memoize
from openerp.tools import misc
@ -355,7 +363,8 @@ class openerp_dav_handler(dav_interface):
return self.parent.get_baseuri(self) + '/'.join(ajoin)
@memoize(4)
def db_list(self):
def _all_db_list(self):
"""return all databases who have module document_webdav installed"""
s = netsvc.ExportService.getService('db')
result = s.exp_list()
self.db_name_list=[]
@ -364,7 +373,7 @@ class openerp_dav_handler(dav_interface):
try:
db = sql_db.db_connect(db_name)
cr = db.cursor()
cr.execute("SELECT id FROM ir_module_module WHERE name = 'document' AND state='installed' ")
cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_webdav' AND state='installed' ")
res=cr.fetchone()
if res and len(res):
self.db_name_list.append(db_name)
@ -375,6 +384,15 @@ class openerp_dav_handler(dav_interface):
cr.close()
return self.db_name_list
def db_list(self, uri):
# import pudb;pudb.set_trace()
u = urlparse.urlsplit(uri)
h = u.hostname
d = h.split('.')[0]
r = openerp.tools.config['dbfilter'].replace('%h', h).replace('%d',d)
dbs = [i for i in self._all_db_list() if re.match(r, i)]
return dbs
def get_childs(self,uri, filters=None):
""" return the child objects as self.baseuris for the given URI """
self.parent.log_message('get children: %s' % uri)
@ -382,7 +400,7 @@ class openerp_dav_handler(dav_interface):
if not dbname:
if cr: cr.close()
res = map(lambda x: self.urijoin(x), self.db_list())
res = map(lambda x: self.urijoin(x), self.db_list(uri))
return res
result = []
node = self.uri2object(cr, uid, pool, uri2[:])

View File

@ -20,6 +20,9 @@
#
##############################################################################
import logging
_logger = logging.getLogger(__name__)
import xml.dom.minidom
domimpl = xml.dom.minidom.getDOMImplementation()
from xml.dom.minicompat import StringTypes
@ -29,10 +32,14 @@ import urllib
from openerp.osv import osv
from openerp.tools.translate import _
from DAV import utils
from DAV.propfind import PROPFIND
from DAV.report import REPORT
try:
from pywebdav.lib import utils
from pywebdav.lib.propfind import PROPFIND
from pywebdav.lib.report import REPORT
except ImportError:
from DAV import utils
from DAV.propfind import PROPFIND
from DAV.report import REPORT
from openerp import tools

View File

@ -38,7 +38,16 @@ import logging
from openerp import netsvc
from dav_fs import openerp_dav_handler
from openerp.tools.config import config
from DAV.WebDAVServer import DAVRequestHandler
try:
from pywebdav.lib.WebDAVServer import DAVRequestHandler
from pywebdav.lib.utils import IfParser, TagList
from pywebdav.lib.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from pywebdav.lib.propfind import PROPFIND
except ImportError:
from DAV.WebDAVServer import DAVRequestHandler
from DAV.utils import IfParser, TagList
from DAV.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from DAV.propfind import PROPFIND
from service import http_server
from service.websrv_lib import FixSendError, HttpOptions
from BaseHTTPServer import BaseHTTPRequestHandler
@ -47,10 +56,7 @@ import urllib
import re
import time
from string import atoi
from openerp import addons
from DAV.utils import IfParser, TagList
from DAV.errors import DAV_Error, DAV_Forbidden, DAV_NotFound
from DAV.propfind import PROPFIND
import addons
# from DAV.constants import DAV_VERSION_1, DAV_VERSION_2
from xml.dom import minidom
from redirect import RedirectHTTPHandler
@ -71,7 +77,7 @@ def OpenDAVConfig(**kw):
return Config()
class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
class DAVHandler(DAVRequestHandler, HttpOptions, FixSendError):
verbose = False
protocol_version = 'HTTP/1.1'
@ -88,7 +94,20 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
self._logger.debug(message)
def handle(self):
self._init_buffer()
"""Handle multiple requests if necessary."""
self.close_connection = 1
try:
self.handle_one_request()
while not self.close_connection:
self.handle_one_request()
except Exception as e:
try:
self.log_error("Request timed out: %r \n Trying old version of HTTPServer", e)
self._init_buffer()
except Exception as e:
#a read or a write timed out. Discard this connection
self.log_error("Not working neither, closing connection\n %r", e)
self.close_connection = 1
def finish(self):
pass
@ -99,6 +118,7 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
return res
def setup(self):
DAVRequestHandler.setup(self)
self.davpath = '/'+config.get_misc('webdav','vdir','webdav')
addr, port = self.server.server_name, self.server.server_port
server_proto = getattr(self.server,'proto', 'http').lower()

View File

@ -53,6 +53,7 @@ ClientAction (ir.actions.client)
- ``compose_placeholder`` : Message to display on the textareaboxes.
- ``show_link`` : Display partner (authors, followers...) on link or not
- ``compose_as_todo`` : The root composer mark automatically the message as todo
- ``readonly`` : Read only mode, hide all action buttons and composer
Fields
+++++++

View File

@ -1414,6 +1414,7 @@ openerp.mail = function (session) {
* @param {String} [no_message] Message to display when there are no message
* @param {Boolean} [show_link] Display partner (authors, followers...) on link or not
* @param {Boolean} [compose_as_todo] The root composer mark automatically the message as todo
* @param {Boolean} [readonly] Read only mode, hide all action buttons and composer
*/
init: function (parent, action) {
this._super(parent, action);
@ -1435,6 +1436,7 @@ openerp.mail = function (session) {
'view_inbox': false,
'message_ids': undefined,
'compose_as_todo' : false,
'readonly' : false,
}, this.action.params);
this.action.params.help = this.action.help || false;
@ -1507,6 +1509,9 @@ openerp.mail = function (session) {
if (this.node.attrs.placeholder) {
this.node.params.compose_placeholder = this.node.attrs.placeholder;
}
if (this.node.attrs.readonly) {
this.node.params.readonly = this.node.attrs.readonly;
}
this.domain = this.node.params && this.node.params.domain || [];
},

View File

@ -20,7 +20,7 @@
mail.compose_message when focus on textarea
-->
<t t-name="mail.compose_message">
<div t-if="widget.show_composer" t-attf-class="oe_msg oe_msg_composer #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''}">
<div t-if="widget.show_composer and !widget.options.readonly" t-attf-class="oe_msg oe_msg_composer #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''}">
<div class="oe_msg_left">
<img class="oe_msg_icon" alt="User img" t-attf-src="#{widget.avatar}"/>
</div>
@ -38,7 +38,7 @@
</div>
</div>
</div>
<div t-if="widget.show_compact_message and !widget.show_composer" t-attf-class="oe_msg oe_msg_composer_compact #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''}">
<div t-if="widget.show_compact_message and !widget.show_composer and !widget.options.readonly" t-attf-class="oe_msg oe_msg_composer_compact #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''}">
<textarea t-if="widget.options.compose_placeholder" class="field_text oe_compact" t-att-placeholder="widget.options.compose_placeholder"/>
<textarea t-if="!widget.options.compose_placeholder and !widget.options.view_mailbox" class="field_text oe_compact" placeholder="Write to the followers of this document..."/>
<textarea t-if="!widget.options.compose_placeholder and widget.options.view_mailbox" class="field_text oe_compact" placeholder="Share with my followers..."/>
@ -211,7 +211,7 @@
</div>
<div class="oe_msg_center">
<div class='oe_msg_icons'>
<div class='oe_msg_icons' t-if="!widget.options.readonly">
<span class='oe_read' t-if="widget.options.show_read"><a title="Done" class="oe_e">W</a></span>
<span class='oe_unread' t-if="widget.is_favorite and widget.options.show_unread"><a title="Set back to Todo" class="oe_e">v</a></span>
<span class='oe_unread' t-if="!widget.is_favorite and widget.options.show_unread"><a title="Set back to Inbox" class="oe_e">v</a></span>
@ -236,8 +236,8 @@
<span t-if="widget.author_id and !widget.options.show_link"><t t-raw="widget.author_id[1]"/></span>
<span class='oe_subtle'></span>
<span t-att-title="widget.date"><t t-raw="widget.timerelative"/></span>
<span class='oe_subtle'></span>
<t t-call="mail.thread.message.vote"/>
<span t-if="!widget.options.readonly" class='oe_subtle'></span>
<t t-if="!widget.options.readonly" t-call="mail.thread.message.vote"/>
</div>
</div>
</div>