當前位置: 首頁>>代碼示例>>Python>>正文


Python request.registry方法代碼示例

本文整理匯總了Python中openerp.http.request.registry方法的典型用法代碼示例。如果您正苦於以下問題:Python request.registry方法的具體用法?Python request.registry怎麽用?Python request.registry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openerp.http.request的用法示例。


在下文中一共展示了request.registry方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def generate(self, cr, uid, query=None, args={}, context=None):
        View = request.registry['ir.ui.view']
        views = View.search_read(cr, uid, [['page', '=', True]],
            fields=['xml_id','priority','write_date'], order='name', context=context)
        for view in views:
            xid = view['xml_id'].startswith('website.') and view['xml_id'][8:] or view['xml_id']
            # the 'page/homepage' url is indexed as '/', avoid aving the same page referenced twice
            # when we will have an url mapping mechanism, replace this by a rule: page/homepage --> /
            if xid=='homepage': continue
            if query and query.lower() not in xid.lower():
                continue
            record = {'loc': xid}
            if view['priority'] <> 16:
                record['__priority'] = min(round(view['priority'] / 32.0,1), 1)
            if view['write_date']:
                record['__lastmod'] = view['write_date'][:10]
            yield record 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:19,代碼來源:ir_http.py

示例2: page

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def page(self, page, **opt):
        values = {
            'path': page,
        }
        # /page/website.XXX --> /page/XXX
        if page.startswith('website.'):
            return request.redirect('/page/' + page[8:], code=301)
        elif '.' not in page:
            page = 'website.%s' % page

        try:
            request.website.get_template(page)
        except ValueError, e:
            # page not found
            if request.website.is_publisher():
                page = 'website.page_404'
            else:
                return request.registry['ir.http']._handle_exception(e, 404)

        return request.render(page, values) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:22,代碼來源:main.py

示例3: website_info

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def website_info(self):
        try:
            request.website.get_template('website.info').name
        except Exception, e:
            return request.registry['ir.http']._handle_exception(e, 404)
        irm = request.env()['ir.module.module'].sudo()
        apps = irm.search([('state','=','installed'),('application','=',True)])
        modules = irm.search([('state','=','installed'),('application','=',False)])
        values = {
            'apps': apps,
            'modules': modules,
            'version': openerp.service.common.exp_version()
        }
        return request.render('website.info', values)

    #------------------------------------------------------
    # Edit
    #------------------------------------------------------ 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:20,代碼來源:main.py

示例4: reset_template

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def reset_template(self, templates, redirect='/'):
        templates = request.httprequest.form.getlist('templates')
        modules_to_update = []
        for temp_id in templates:
            view = request.registry['ir.ui.view'].browse(request.cr, request.uid, int(temp_id), context=request.context)
            if view.page:
                continue
            view.model_data_id.write({
                'noupdate': False
            })
            if view.model_data_id.module not in modules_to_update:
                modules_to_update.append(view.model_data_id.module)

        if modules_to_update:
            module_obj = request.registry['ir.module.module']
            module_ids = module_obj.search(request.cr, request.uid, [('name', 'in', modules_to_update)], context=request.context)
            if module_ids:
                module_obj.button_immediate_upgrade(request.cr, request.uid, module_ids, context=request.context)
        return request.redirect(redirect) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:21,代碼來源:main.py

示例5: toc

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def toc(self, toc=None, **kwargs):
        cr, uid, context, toc_id = request.cr, request.uid, request.context, False
        if toc:
            sections = toc.child_ids
            forum = toc.forum_id
        else:
            toc_obj = request.registry['forum.documentation.toc']
            obj_ids = toc_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
            sections = toc_obj.browse(cr, uid, obj_ids, context=context)
            forum = sections and sections[0].forum_id or False
        value = {
            'toc': toc,
            'main_object': toc or forum,
            'forum': forum,
            'sections': sections,
        }
        return request.website.render("website_forum_doc.documentation", value) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:19,代碼來源:main.py

示例6: get_attribute_value_ids

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def get_attribute_value_ids(self, product):
        cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
        currency_obj = pool['res.currency']
        attribute_value_ids = []
        visible_attrs = set(l.attribute_id.id
                                for l in product.attribute_line_ids
                                    if len(l.value_ids) > 1)
        if request.website.pricelist_id.id != context['pricelist']:
            website_currency_id = request.website.currency_id.id
            currency_id = self.get_pricelist().currency_id.id
            for p in product.product_variant_ids:
                price = currency_obj.compute(cr, uid, website_currency_id, currency_id, p.lst_price)
                attribute_value_ids.append([p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, price])
        else:
            attribute_value_ids = [[p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, p.lst_price]
                for p in product.product_variant_ids]

        return attribute_value_ids 
開發者ID:Punto0,項目名稱:addons-fm,代碼行數:20,代碼來源:ir_qweb.py

示例7: to_python

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def to_python(self, value):
        m = re.match(self.regex, value)
        _uid = RequestUID(value=value, match=m, converter=self)
        record_id = int(m.group(2))
        if record_id < 0:
            # limited support for negative IDs due to our slug pattern, assume abs() if not found
            if not request.registry[self.model].exists(request.cr, _uid, [record_id]):
                record_id = abs(record_id)
        return request.registry[self.model].browse(
            request.cr, _uid, record_id, context=request.context) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:12,代碼來源:ir_http.py

示例8: get_view_translations

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def get_view_translations(self, cr, uid, xml_id, lang, field=['id', 'res_id', 'value', 'state', 'gengo_translation'], context=None):
        views = self.customize_template_get(cr, uid, xml_id, full=True, context=context)
        views_ids = [view.get('id') for view in views if view.get('active')]
        domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)]
        irt = request.registry.get('ir.translation')
        return irt.search_read(cr, uid, domain, field, context=context) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:8,代碼來源:ir_ui_view.py

示例9: index

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def index(self, **kw):
        page = 'homepage'
        try:
            main_menu = request.registry['ir.model.data'].get_object(request.cr, request.uid, 'website', 'main_menu')
        except Exception:
            pass
        else:
            first_menu = main_menu.child_id and main_menu.child_id[0]
            if first_menu:
                if first_menu.url and (not (first_menu.url.startswith(('/page/', '/?', '/#')) or (first_menu.url == '/'))):
                    return request.redirect(first_menu.url)
                if first_menu.url and first_menu.url.startswith('/page/'):
                    return request.registry['ir.http'].reroute(first_menu.url)
        return self.page(page) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:16,代碼來源:main.py

示例10: pagenew

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def pagenew(self, path, noredirect=False, add_menu=None):
        xml_id = request.registry['website'].new_page(request.cr, request.uid, path, context=request.context)
        if add_menu:
            model, id  = request.registry["ir.model.data"].get_object_reference(request.cr, request.uid, 'website', 'main_menu')
            request.registry['website.menu'].create(request.cr, request.uid, {
                    'name': path,
                    'url': "/page/" + xml_id[8:],
                    'parent_id': id,
                }, context=request.context)
        # Reverse action in order to allow shortcut for /page/<website_xml_id>
        url = "/page/" + re.sub(r"^website\.", '', xml_id)

        if noredirect:
            return werkzeug.wrappers.Response(url, mimetype='text/plain')
        return werkzeug.utils.redirect(url) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:17,代碼來源:main.py

示例11: customize_template_get

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def customize_template_get(self, xml_id, full=False):
        return request.registry["ir.ui.view"].customize_template_get(
            request.cr, request.uid, xml_id, full=full, context=request.context) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:5,代碼來源:main.py

示例12: get_view_translations

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def get_view_translations(self, xml_id, lang=None):
        lang = lang or request.context.get('lang')
        return request.registry["ir.ui.view"].get_view_translations(
            request.cr, request.uid, xml_id, lang=lang, context=request.context) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:6,代碼來源:main.py

示例13: set_translations

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def set_translations(self, data, lang):
        irt = request.registry.get('ir.translation')
        for view_id, trans in data.items():
            view_id = int(view_id)
            for t in trans:
                initial_content = t['initial_content'].strip()
                new_content = t['new_content'].strip()
                tid = t['translation_id']
                if not tid:
                    old_trans = irt.search_read(
                        request.cr, request.uid,
                        [
                            ('type', '=', 'view'),
                            ('res_id', '=', view_id),
                            ('lang', '=', lang),
                            ('src', '=', initial_content),
                        ])
                    if old_trans:
                        tid = old_trans[0]['id']
                if tid:
                    vals = {'value': new_content}
                    irt.write(request.cr, request.uid, [tid], vals)
                else:
                    new_trans = {
                        'name': 'website',
                        'res_id': view_id,
                        'lang': lang,
                        'type': 'view',
                        'source': initial_content,
                        'value': new_content,
                    }
                    if t.get('gengo_translation'):
                        new_trans['gengo_translation'] = t.get('gengo_translation')
                        new_trans['gengo_comment'] = t.get('gengo_comment')
                    irt.create(request.cr, request.uid, new_trans)
        return True 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:38,代碼來源:main.py

示例14: get_website_translations

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def get_website_translations(self, lang):
        module_obj = request.registry['ir.module.module']
        module_ids = module_obj.search(request.cr, request.uid, [('name', 'ilike', 'website'), ('state', '=', 'installed')], context=request.context)
        modules = [x['name'] for x in module_obj.read(request.cr, request.uid, module_ids, ['name'], context=request.context)]
        return WebClient().translations(mods=modules, lang=lang) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:7,代碼來源:main.py

示例15: publish

# 需要導入模塊: from openerp.http import request [as 別名]
# 或者: from openerp.http.request import registry [as 別名]
def publish(self, id, object):
        _id = int(id)
        _object = request.registry[object]
        obj = _object.browse(request.cr, request.uid, _id)

        values = {}
        if 'website_published' in _object._fields:
            values['website_published'] = not obj.website_published
        _object.write(request.cr, request.uid, [_id],
                      values, context=request.context)

        obj = _object.browse(request.cr, request.uid, _id)
        return bool(obj.website_published) 
開發者ID:osbzr,項目名稱:gooderp_org,代碼行數:15,代碼來源:main.py


注:本文中的openerp.http.request.registry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。