How to use the zope.component.getMultiAdapter function in Zope

To help you get started, we’ve selected a few Zope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github socialplanning / opencore / migrations / unmake-sites.py View on Github external
app=makerequest(app)

from zope.component import getMultiAdapter
from zope.interface import Interface

try:
    portal = sys.argv[1]
except IndexError:
    portal = 'openplans'

app_view = getMultiAdapter((app, app.REQUEST), Interface,
                           name='manage_site.html')
app_view.unmakeSite()

portal = getattr(app, portal)
portal_view = getMultiAdapter((portal, portal.REQUEST), Interface,
                              name='manage_site.html')
portal_view.unmakeSite()

transaction.get().note('Unmade app and portal as local sites')
transaction.commit()
github ned14 / Easyshop / easyshop.checkout / easyshop / checkout / browser / order_preview.py View on Github external
"""
        return []
        
        cart = self._getCart()        

        if cart is None: 
            return []

        cm = ICurrencyManagement(self.context)
        discounts = []
        
        for cart_item in IItemManagement(cart).getItems():
            discount = IDiscountsCalculation(cart_item).getDiscount()

            if discount is not None:
                value = getMultiAdapter((discount, cart_item)).getPriceForCustomer()
                discounts.append({
                    "title" : discount.Title(),
                    "value" : cm.priceToString(value, prefix="-"),
                })
        
        return discounts
github OneGov / plonetheme.onegov / plonetheme / onegov / portlets / navigation.py View on Github external
def __init__(self, context, request, view, manager, data):
        self.context = context
        self.request = request
        self.parent = aq_parent(aq_inner(context))
        self.data = data
        plone = getMultiAdapter((context, request), name="plone")
        self.is_default_page = plone.isDefaultPageInFolder()
        in_factory = IFactoryTempFolder.providedBy(
            self.parent)
        if in_factory:
            self.parent = aq_parent(aq_parent(aq_inner(self.parent)))
        elif self.is_default_page:
            self.parent = aq_parent(aq_inner(self.parent))

        registry = getUtility(IRegistry)
        self.displayed_types = registry['plone.displayed_types']
        # TODO: What does "registry['plone.displayed_types']" return if no displayed types are configured?
        self.view_action_types = registry['plone.types_use_view_action_in_listings']
github plone / Products.CMFPlone / browser / ploneview.py View on Github external
if options is None:
            options = {}
        if view is None:
            view = self

        show_portlets = not options.get('no_portlets', False)
        def_actions = options.get('actions', None)

        # XXX: Can't store data as attributes directly because it will
        # insert the view into the acquisition chain. Someone should
        # come up with a way to prevent this or get rid of the globals
        # view altogether

        tools = getMultiAdapter((context, self.request), name=u'plone_tools')
        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')
        context_state = getMultiAdapter((context, self.request), name=u'plone_context_state')

        self._data['utool'] = utool = tools.url()
        self._data['portal'] = portal = portal_state.portal()
        self._data['portal_url'] =  portal_state.portal_url()
        self._data['mtool'] = mtool = tools.membership()
        self._data['atool'] = atool = tools.actions()
        self._data['putils'] = putils = getToolByName(context, "plone_utils")
        self._data['acl_users'] = getToolByName(context, 'acl_users')
        self._data['wtool'] = wtool = tools.workflow()
        self._data['ifacetool'] = tools.interface()
        self._data['syntool'] = tools.syndication()
        self._data['portal_title'] = portal_state.portal_title()
        self._data['object_title'] = context_state.object_title()
        self._data['checkPermission'] = checkPermission = mtool.checkPermission
        self._data['member'] = portal_state.member()
        self._data['membersfolder'] =  mtool.getMembersFolder()
github collective / stxnext.staticdeployment / src / stxnext / staticdeployment / app / util.py View on Github external
if PLONE_RESOURCE_INSTALLED and isinstance(obj, FilesystemFile):
                if not obj.request:
                    obj.request = new_req
                    return obj().read()

            if PLONE_APP_BLOB_INSTALLED and IBlobWrapper.providedBy(obj):
                return obj.data

            if PLONE_NAMEDFILE_INSTALLED and \
                INamed.providedBy(obj):
                return obj.data

            if IBaseObject.providedBy(obj) or isinstance(obj, PloneSite) or \
                DEXTERITY_INSTALLED and IDexterityContent.providedBy(obj):
                default_page_helper = getMultiAdapter((obj, self.request),
                        name='default_page')
                def_page_id = default_page_helper.getDefaultPage()
                if def_page_id:
                    def_page = obj[def_page_id]
                    return self._render_obj(def_page)

                view_name = obj.getLayout()
                view = queryMultiAdapter((obj, new_req), name=view_name)
                if view_name == 'language-switcher':
                    lang = new_req.get('LANGUAGE')
                    def_page = getattr(obj, lang, None)
                    if def_page:
                        return self._render_obj(def_page)
                if view:
                    try:
                        return view.context()
github plone / Products.CMFPlone / Products / CMFPlone / browser / navigation.py View on Github external
def breadcrumbs(self):
        context = aq_inner(self.context)
        request = self.request
        container = utils.parent(context)

        name, item_url = get_view_url(context)

        if container is None:
            return ({'absolute_url': item_url,
                     'Title': utils.pretty_title_or_id(context, context), },
                   )

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        # Some things want to be hidden from the breadcrumbs
        if IHideFromBreadcrumbs.providedBy(context):
            return base

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)

        rootPath = getNavigationRoot(context)
        itemPath = '/'.join(context.getPhysicalPath())

        # don't show default pages in breadcrumbs or pages above the navigation root
        if not utils.isDefaultPage(context, request) and not rootPath.startswith(itemPath):
            base += ({'absolute_url': item_url,
                      'Title': utils.pretty_title_or_id(context, context), },
github zopefoundation / z3c.form / src / z3c / form / object.py View on Github external
def toFieldValue(self, value):
        """field value is an Object type, that provides field.schema"""
        if value is interfaces.NO_VALUE:
            return self.field.missing_value

        if self.widget.subform is None:
            #creepy situation when the widget is hanging in nowhere
            obj = self.createObject(value)
        else:
            if self.widget.subform.ignoreContext:
                obj = self.createObject(value)
            else:
                dm = zope.component.getMultiAdapter(
                    (self.widget.context, self.field), interfaces.IDataManager)
                try:
                    obj = dm.get()
                except KeyError:
                    obj = self.createObject(value)
                except AttributeError:
                    obj = self.createObject(value)

        if obj is None or obj == self.field.missing_value:
            #if still None create one, otherwise following will burp
            obj = self.createObject(value)

        obj = self.field.schema(obj)

        names = []
        for name in zope.schema.getFieldNames(self.field.schema):
github plone / Products.CMFPlone / browser / ploneview.py View on Github external
def keyFilteredActions(self, actions=None):
        context_state = getMultiAdapter((aq_inner(self.context), self.request), name=u'plone_context_state')
        return context_state.keyed_actions()
github plone / plone.app.portlets / plone / app / portlets / browser / kss.py View on Github external
def _render_column(self, info, view_name):
        ksscore = self.getCommandSet('core')
        selector = ksscore.getCssSelector('div#portletmanager-' + info['manager'].replace('.', '-'))

        context = aq_inner(self.context)
        request = aq_inner(self.request)
        view = getMultiAdapter((context, request), name=view_name)
        # view can have been customized TTW, see #11409
        if isinstance(view, TTWViewTemplateRenderer):
            view = view._getView()

        manager = getUtility(IPortletManager, name=info['manager'])

        request['key'] = info['key']

        request['viewname'] = view_name
        renderer = getMultiAdapter((context, request, view, manager), IPortletManagerRenderer)
        renderer.update()
        ksscore.replaceInnerHTML(selector, renderer.__of__(context).render())
        return self.render()
github socialplanning / opencore / opencore / browser / base.py View on Github external
def piv(self):
        view = getMultiAdapter((self.context, self.request), name='project_info')
        return view.__of__(aq_inner(self.context))