예제 #1
0
파일: shop.py 프로젝트: Easyshop/Easyshop
    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
예제 #2
0
    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
예제 #3
0
파일: format.py 프로젝트: Easyshop/Easyshop
    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        
예제 #4
0
    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