def update(self): form = self.request.form if form.get("form.button.UpdateContentTypes", None) is not None: types = form.get("types", None) if types is not None: if type(types).__name__ == "str": types = [types] context = aq_inner(self.context) portal = getToolByName(context, "portal_url").getPortalObject() IPortal(portal).cart_properties.content_types = types catalog = getToolByName(context, "portal_catalog") brains = catalog(portal_type=types) if len(brains) != 0: objects = [] for brain in brains: obj = brain.getObject() if not IPotentiallyAddableToCart.providedBy(obj): alsoProvides(obj, IPotentiallyAddableToCart) objects.append(obj) # addables = catalog( # object_provides = IAddableToCart.__identifier__, # ) addables = [brain.getObject() for brain in catalog(object_provides=IAddableToCart.__identifier__)] # objs = [ad.getObject() for ad in addables if ad in brains] objs = [ad.getObject() for ad in addables if ad in objects] if len(objs) != 0: for obj in objs: noLongerProvides(obj, [IAddableToCart, IPotentiallyAddableToCart])
def addable_to_cart(self): context = aq_inner(self.context) return IPotentiallyAddableToCart.providedBy( context) and IAddableToCart.providedBy(context)
def potentially_addable_but_not_addable_to_cart(self): context = aq_inner(self.context) return IPotentiallyAddableToCart.providedBy( context) and not IAddableToCart.providedBy(context)
def addable_to_cart(self): context = aq_inner(self.context) return IPotentiallyAddableToCart.providedBy(context) and IAddableToCart.providedBy(context)
def potentially_addable_but_not_addable_to_cart(self): context = aq_inner(self.context) return IPotentiallyAddableToCart.providedBy(context) and not IAddableToCart.providedBy(context)