def getShop(self): """ """ object = self.context try: while object.meta_type != "EasyShop": if object.meta_type == "Plone Factory Tool": object = object.aq_parent else: object = object.aq_inner.aq_parent except AttributeError: # Next line is needed for the temporary products for payment and # shipping. As they have real context above code seems not to # work. But they have given the shop as context so we can give # it back here. See also: # - adapters/shop/payment/createTemporaryPaymentProduct # - adapters/shop/shipping/createTemporaryShippingProduct. # I'm not sure whether this is clean, I assume it is not. if IShop.providedBy(object.context): return object.context else: return None return object
def _getFormatter(self): """ """ obj = self.context while IShop.providedBy(obj) == False: try: return self.context.objectValues("Formatter")[0] except IndexError: pass obj = obj.aq_inner.aq_parent # For a shop try: return obj.objectValues("Formatter")[0] except IndexError: pass return None