Example #1
0
 def put(cls, uri, data, content_type, cache=None):
     from pywebdav.lib.errors import DAV_Forbidden
     from pywebdav.lib.utils import get_uriparentpath, get_urifilename
     object_name, object_id = cls._uri2object(get_uriparentpath(uri),
                                              cache=cache)
     if not object_name \
             or object_name == 'ir.attachment' \
             or not object_id:
         raise DAV_Forbidden
     pool = Pool()
     Attachment = pool.get('ir.attachment')
     object_name2, object_id2 = cls._uri2object(uri, cache=cache)
     if not object_id2:
         name = get_urifilename(uri)
         try:
             Attachment.create([{
                 'name':
                 name,
                 'data':
                 data,
                 'resource':
                 '%s,%s' % (object_name, object_id),
             }])
         except Exception:
             raise DAV_Forbidden
     else:
         try:
             Attachment.write(object_id2, {
                 'data': data,
             })
         except Exception:
             raise DAV_Forbidden
     return
Example #2
0
 def put(cls, uri, data, content_type, cache=None):
     from pywebdav.lib.errors import DAV_Forbidden
     from pywebdav.lib.utils import get_uriparentpath, get_urifilename
     object_name, object_id = cls._uri2object(get_uriparentpath(uri),
             cache=cache)
     if not object_name \
             or object_name == 'ir.attachment' \
             or not object_id:
         raise DAV_Forbidden
     pool = Pool()
     Attachment = pool.get('ir.attachment')
     object_name2, object_id2 = cls._uri2object(uri, cache=cache)
     if not object_id2:
         name = get_urifilename(uri)
         try:
             Attachment.create([{
                         'name': name,
                         'data': data,
                         'resource': '%s,%s' % (object_name, object_id),
                         }])
         except Exception:
             raise DAV_Forbidden
     else:
         try:
             Attachment.write(object_id2, {
                 'data': data,
                 })
         except Exception:
             raise DAV_Forbidden
     return
Example #3
0
def mk_prop_response(self, uri, good_props, bad_props, doc):
    res = _mk_prop_response(self, uri, good_props, bad_props, doc)
    parent_uri = get_uriparentpath(uri and uri.strip('/') or '')
    if not parent_uri:
        return res
    dbname, parent_uri = TrytonDAVInterface.get_dburi(parent_uri)
    # Disable groupdav attribute for iPhone
    # if  parent_uri in ('Calendars', 'Calendars/'):
    #     vc = doc.createElement('vtodo-collection')
    #     vc.setAttribute('xmlns', 'http://groupdav.org/')
    #     cols = res.getElementsByTagName('D:collection')
    #     if cols:
    #         cols[0].parentNode.appendChild(vc)
    return res
Example #4
0
def mk_prop_response(self, uri, good_props, bad_props, doc):
    res = _mk_prop_response(self, uri, good_props, bad_props, doc)
    parent_uri = get_uriparentpath(uri and uri.strip('/') or '')
    if not parent_uri:
        return res
    dbname, parent_uri = TrytonDAVInterface.get_dburi(parent_uri)
    #Disable groupdav attribute for iPhone
    #if  parent_uri in ('Calendars', 'Calendars/'):
    #    vc = doc.createElement('vtodo-collection')
    #    vc.setAttribute('xmlns', 'http://groupdav.org/')
    #    cols = res.getElementsByTagName('D:collection')
    #    if cols:
    #        cols[0].parentNode.appendChild(vc)
    return res
Example #5
0
 def mkcol(cls, uri, cache=None):
     from pywebdav.lib.errors import DAV_Forbidden
     from pywebdav.lib.utils import get_uriparentpath, get_urifilename
     if uri[-1:] == '/':
         uri = uri[:-1]
     object_name, object_id = cls._uri2object(get_uriparentpath(uri),
                                              cache=cache)
     if object_name != 'webdav.collection':
         raise DAV_Forbidden
     name = get_urifilename(uri)
     try:
         cls.create([{
             'name': name,
             'parent': object_id,
         }])
     except Exception:
         raise DAV_Forbidden
     return 201
Example #6
0
 def mkcol(cls, uri, cache=None):
     from pywebdav.lib.errors import DAV_Forbidden
     from pywebdav.lib.utils import get_uriparentpath, get_urifilename
     if uri[-1:] == '/':
         uri = uri[:-1]
     object_name, object_id = cls._uri2object(get_uriparentpath(uri),
             cache=cache)
     if object_name != 'webdav.collection':
         raise DAV_Forbidden
     name = get_urifilename(uri)
     try:
         cls.create([{
                     'name': name,
                     'parent': object_id,
                     }])
     except Exception:
         raise DAV_Forbidden
     return 201
Example #7
0
def mk_prop_response(self, uri, good_props, bad_props, doc):
    res = _mk_prop_response(self, uri, good_props, bad_props, doc)
    if not isinstance(uri, str):
        uri = uri.decode()
    parent_uri = get_uriparentpath(uri and uri.strip('/') or '')
    if not parent_uri:
        return res
    dbname, parent_uri = TrytonDAVInterface.get_dburi(parent_uri)
    if parent_uri in ('Calendars', 'Calendars/'):
        ad = doc.createElement('calendar')
        ad.setAttribute('xmlns', 'urn:ietf:params:xml:ns:caldav')
        # Disable groupdav attribute for iPhone
        # vc = doc.createElement('vevent-collection')
        # vc.setAttribute('xmlns', 'http://groupdav.org/')
        cols = res.getElementsByTagName('D:collection')
        if cols:
            cols[0].parentNode.appendChild(ad)
            # cols[0].parentNode.appendChild(vc)
    return res