Exemple #1
0
    def default_get(self, cr, uid, fields, context=None):
        pref_obj = self.pool.get('user.preference')
        pref_ids = pref_obj.browse(cr, uid ,context.get('rec_id',False), context=context)
        res = {}
        host = context.get('host')
        port = ''
        prefix = 'http://'
        if not config.get('xmlrpc'):
            if not config.get('netrpc'):
                prefix = 'https://'
                port = config.get('xmlrpcs_port', 8071)
            else:
                port = config.get('netrpc_port',8070)
        else:
            port = config.get('xmlrpc_port',8069)
        if not config.get_misc('webdav','enable',True):
            raise Exception("WebDAV is disabled, cannot continue")
        user_pool = self.pool.get('res.users')
        current_user = user_pool.browse(cr, uid, uid, context=context)
        #TODO write documentation
        res['description'] = self.__doc['other']
        if pref_ids:
            pref_ids = pref_ids[0]
            if pref_ids.device == 'iphone':
                url = host + ':' + str(port) + '/'+ pref_ids.service + '/' + cr.dbname + '/'+'calendars/'
            else :
                url = host + ':' + str(port) + '/'+ pref_ids.service + '/' + cr.dbname + '/'+'calendars/'+ 'users/'+ current_user.login + '/'+ pref_ids.collection.name+ '/'+ pref_ids.calendar.name

            res['description'] = self.__doc.get(pref_ids.device , self.__doc['other'])
        file = open(addons.get_module_resource('caldav','doc', 'caldav_doc.pdf'),'rb')
        res['caldav_doc_file'] = base64.encodestring(file.read())

        #res['doc_link'] = 'http://doc.openerp.com/'
        res['url'] = prefix+url
        return res
    def default_get(self, cr, uid, fields, context=None):
        pref_obj = self.pool.get('user.preference')
        pref_ids = pref_obj.browse(cr,
                                   uid,
                                   context.get('rec_id', False),
                                   context=context)
        res = {}
        host = context.get('host')
        if not config.get_misc('webdav', 'enable', True):
            raise Exception("WebDAV is disabled, cannot continue")
        user_pool = self.pool.get('res.users')
        current_user = user_pool.browse(cr, uid, uid, context=context)
        #TODO write documentation
        res['description'] = self.__doc['other']
        if pref_ids:
            pref_ids = pref_ids[0]
            if pref_ids.device == 'iphone':
                url = host + '/' + pref_ids.service + '/' + cr.dbname + '/' + 'calendars/'
            else:
                url = host + '/' + pref_ids.service + '/' + cr.dbname + '/' + 'calendars/' + 'users/' + current_user.login + '/' + pref_ids.collection.name + '/' + pref_ids.calendar.name

            res['description'] = self.__doc.get(pref_ids.device,
                                                self.__doc['other'])
        file = open(
            addons.get_module_resource('caldav', 'doc', 'caldav_doc.pdf'),
            'rb')
        res['caldav_doc_file'] = base64.encodestring(file.read())

        #res['doc_link'] = 'http://doc.openerp.com/'
        res['url'] = url
        return res
Exemple #3
0
def get_db_and_pool(db_name,
                    force_demo=False,
                    status=None,
                    update_module=False,
                    pooljobs=True,
                    languages=False):
    if not status:
        status = {}

    db = get_db_only(db_name)

    if db_name in pool_dic:
        pool = pool_dic[db_name]
    else:
        import addons
        import osv.osv
        import logging
        from tools import config

        log = logging.getLogger('pooler')
        allowed_res = config.get_misc('databases', 'allowed')
        if allowed_res:
            dbs_allowed = [x.strip() for x in allowed_res.split(' ')]
            if db_name not in dbs_allowed:
                log.critical('Illegal database requested: %s', db_name)
                raise AttributeError('Illegal database: %s' % db_name)

        log.info("Starting pooler of database: %s" % db_name)

        pool = osv.osv.osv_pool()
        pool_dic[db_name] = pool

        try:
            addons.load_modules(db,
                                force_demo,
                                status,
                                update_module,
                                languages=languages)
        except Exception:
            del pool_dic[db_name]
            log.exception("Could not load modules for %s" % db_name)
            raise

        cr = db.cursor()
        try:
            pool.init_set(cr, False)
            pool.get('ir.actions.report.xml').register_all(cr)
            cr.commit()
        finally:
            cr.close()

        if pooljobs:
            pool.get('ir.cron').restart(db.dbname)
        log.info('Successfuly loaded database \"%s\"' % db_name)
    return db, pool
 def _prepare_context(self, cr, uid, nctx, context=None):
     nctx.node_file_class = nodes.node_file
     # We can fill some more fields, but avoid any expensive function
     # that might be not worth preparing.
     nctx.extra_ctx['webdav_path'] = '/'+config.get_misc('webdav','vdir','webdav')
     usr_obj = self.pool.get('res.users')
     res = usr_obj.read(cr, uid, uid, ['login'])
     if res:
         nctx.extra_ctx['username'] = res['login']
     # TODO group
     return
Exemple #5
0
 def _prepare_context(self, cr, uid, nctx, context=None):
     nctx.node_file_class = nodes.node_file
     # We can fill some more fields, but avoid any expensive function
     # that might be not worth preparing.
     nctx.extra_ctx['webdav_path'] = '/'+config.get_misc('webdav','vdir','webdav')
     usr_obj = self.pool.get('res.users')
     res = usr_obj.read(cr, uid, uid, ['login'])
     if res:
         nctx.extra_ctx['username'] = res['login']
     # TODO group
     return
 def __init__(self, user=None, passwd=None, dbg=0, use_ssl=False, useragent=False, timeout=None):
     if use_ssl:
         self.host = config.get_misc('httpsd', 'interface', False)
         self.port = config.get_misc('httpsd', 'port', 8071)
         if not self.host:
             self.host = config.get('xmlrpcs_interface')
             self.port = config.get('xmlrpcs_port')
     else:
         self.host = config.get_misc('httpd', 'interface')
         self.port = config.get_misc('httpd', 'port', 8069)
         if not self.host:
             self.host = config.get('xmlrpc_interface')
             self.port = config.get('xmlrpc_port') or self.port
     if self.host == '0.0.0.0' or not self.host:
         self.host = '127.0.0.1'
     self.port = int(self.port)
     if not config.get_misc('webdav','enable',True):
         raise Exception("WebDAV is disabled, cannot continue")
     self.davpath = '/' + config.get_misc('webdav','vdir','webdav')
     self.user = user
     self.passwd = passwd
     self.dbg = dbg
     self.timeout = timeout or 5.0 # seconds, tests need to respond pretty fast!
     self.hdrs = {}
     if useragent:
         self.set_useragent(useragent)
 def __init__(self,
              user=None,
              passwd=None,
              dbg=0,
              use_ssl=False,
              useragent=False,
              timeout=None):
     if use_ssl:
         self.host = config.get_misc('httpsd', 'interface', False)
         self.port = config.get_misc('httpsd', 'port', 8071)
         if not self.host:
             self.host = config.get('xmlrpcs_interface')
             self.port = config.get('xmlrpcs_port')
     else:
         self.host = config.get_misc('httpd', 'interface')
         self.port = config.get_misc('httpd', 'port', 8069)
         if not self.host:
             self.host = config.get('xmlrpc_interface')
             self.port = config.get('xmlrpc_port') or self.port
     if self.host == '0.0.0.0' or not self.host:
         self.host = '127.0.0.1'
     self.port = int(self.port)
     if not config.get_misc('webdav', 'enable', True):
         raise Exception("WebDAV is disabled, cannot continue")
     self.davpath = '/' + config.get_misc('webdav', 'vdir', 'webdav')
     self.user = user
     self.passwd = passwd
     self.dbg = dbg
     self.timeout = timeout or 5.0  # seconds, tests need to respond pretty fast!
     self.hdrs = {}
     if useragent:
         self.set_useragent(useragent)