class node_calendar_res_col(nodes.node_res_obj):
    """ Calendar collection, as a dynamically created node
    
    This class shall be used instead of node_calendar_collection, when the
    node is under dynamic ones.
    """
    DAV_PROPS = dict_merge2(nodes.node_res_obj.DAV_PROPS,
            { "http://calendarserver.org/ns/" : ('getctag',), } )
    DAV_M_NS = dict_merge2(nodes.node_res_obj.DAV_M_NS,
            { "http://calendarserver.org/ns/" : '_get_dav', } )

    def _file_get(self,cr, nodename=False):
        return []

    def _child_get(self, cr, name=False, parent_id=False, domain=None):
        dirobj = self.context._dirobj
        uid = self.context.uid
        ctx = self.context.context.copy()
        ctx.update(self.dctx)
        where = [('collection_id','=',self.dir_id)]
        ext = False
        if name and name.endswith('.ics'):
            name = name[:-4]
            ext = True
        if name:
            where.append(('name','=',name))
        if not domain:
            domain = []
        where = where + domain
        fil_obj = dirobj.pool.get('basic.calendar')
        ids = fil_obj.search(cr,uid,where,context=ctx)
        res = []
        # TODO: shall we use any of our dynamic information??
        for cal in fil_obj.browse(cr, uid, ids, context=ctx):
            if (not name) or not ext:
                res.append(node_calendar(cal.name, self, self.context, cal))
            if self.context.get('DAV-client', '') in ('iPhone', 'iCalendar'):
                # these ones must not see the webcal entry.
                continue
            if cal.has_webcal and (not name) or ext:
                res.append(res_node_calendar(cal.name+'.ics', self, self.context, cal))
            # May be both of them!
        return res

    def _get_ttag(self, cr):
        return 'calen-dir-%d' % self.dir_id

    def _get_dav_getctag(self, cr):
        dirobj = self.context._dirobj
        uid = self.context.uid
        ctx = self.context.context.copy()
        ctx.update(self.dctx)
        where = [('collection_id','=',self.dir_id)]
        bc_obj = dirobj.pool.get('basic.calendar')
        
        res = get_last_modified(bc_obj, cr, uid, where, context=ctx)
        return _str2time(res)
Exemple #2
0
 def get_propnames(self, uri):
     props = self.PROPS
     self.parent.log_message('get propnames: %s' % uri)
     cr, uid, pool, dbname, uri2 = self.get_cr(uri)
     if not dbname:
         if cr: cr.close()
         # TODO: maybe limit props for databases..?
         return props
     node = self.uri2object(cr, uid, pool, uri2)
     if node:
         props = dict_merge2(props, node.get_dav_props(cr))
     cr.close()
     return props
 def get_propnames(self, uri):
     props = self.PROPS
     self.parent.log_message('get propnames: %s' % uri)
     cr, uid, pool, dbname, uri2 = self.get_cr(uri)
     if not dbname:
         if cr: cr.close()
         # TODO: maybe limit props for databases..?
         return props
     node = self.uri2object(cr, uid, pool, uri2)
     if node:
         props = dict_merge2(props, node.get_dav_props(cr))
     cr.close()
     return props
from document_webdav import nodes
from document.nodes import _str2time, nodefd_static
import logging
from orm_utils import get_last_modified
_logger = logging.getLogger(__name__)

try:
    from tools.dict_tools import  dict_merge2
except ImportError:
    from document.dict_tools import  dict_merge2

# TODO: implement DAV-aware errors, inherit from IOError

# Assuming that we have set global properties right, we mark *all* 
# directories as having calendar-access.
nodes.node_dir.http_options = dict_merge2(nodes.node_dir.http_options,
            { 'DAV': ['calendar-access',] })

class node_calendar_collection(nodes.node_dir):
    DAV_PROPS = dict_merge2(nodes.node_dir.DAV_PROPS,
            { "http://calendarserver.org/ns/" : ('getctag',), } )
    DAV_M_NS = dict_merge2(nodes.node_dir.DAV_M_NS,
            { "http://calendarserver.org/ns/" : '_get_dav', } )

    def _file_get(self,cr, nodename=False):
        return []

    def _child_get(self, cr, name=False, parent_id=False, domain=None):
        dirobj = self.context._dirobj
        uid = self.context.uid
        ctx = self.context.context.copy()
        ctx.update(self.dctx)
from document_webdav import nodes
from document.nodes import _str2time, nodefd_static
import logging
from orm_utils import get_last_modified

try:
    from tools.dict_tools import  dict_merge2
except ImportError:
    from document.dict_tools import  dict_merge2

# TODO: implement DAV-aware errors, inherit from IOError

# Assuming that we have set global properties right, we mark *all* 
# directories as having calendar-access.
nodes.node_dir.http_options = dict_merge2(nodes.node_dir.http_options,
            { 'DAV': ['calendar-access',] })

class node_calendar_collection(nodes.node_dir):
    DAV_PROPS = dict_merge2(nodes.node_dir.DAV_PROPS,
            { "http://calendarserver.org/ns/" : ('getctag',), } )
    DAV_M_NS = dict_merge2(nodes.node_dir.DAV_M_NS,
            { "http://calendarserver.org/ns/" : '_get_dav', } )

    def _file_get(self,cr, nodename=False):
        return []

    def _child_get(self, cr, name=False, parent_id=False, domain=None):
        dirobj = self.context._dirobj
        uid = self.context.uid
        ctx = self.context.context.copy()
        ctx.update(self.dctx)