def resolve2(base, reference): return resolve_uri2(base, reference)
def get_namespace(self, context): root = context.root namespace = {'name': self.name, 'abspath': self.get_abspath(), 'price': self.get_price_namespace()} # Get basic informations namespace['href'] = context.get_link(self) for key in product_schema.keys(): if key=='data': continue namespace[key] = self.get_property(key) # Category namespace['category'] = { 'name': self.parent.name, 'href': context.get_link(self.parent), 'breadcrumb_title': self.parent.get_property('breadcrumb_title'), 'title': self.parent.get_title()} # Categorie XXX To remove namespace['categorie'] = self.parent.get_title() # Lang (usefull to show contextuel images) ws_languages = context.site_root.get_property('website_languages') accept = context.accept_language lang = accept.select_language(ws_languages) namespace['lang'] = lang # Manufacturer manufacturer = self.get_property('manufacturer') if manufacturer: manufacturer = root.get_resource(manufacturer) link = context.get_link(manufacturer) photo = manufacturer.get_property('photo') namespace['manufacturer'] = { 'name': manufacturer.name, 'link': link, 'photo': resolve_uri2(link, photo), 'title': manufacturer.get_title()} else: namespace['manufacturer'] = None # Data namespace['data'] = self.get_property('data') # Specific product informations model = self.get_product_model() if model: namespace.update(model.get_model_namespace(self)) else: namespace['specific_dict'] = {} namespace['specific_list'] = [] # Images namespace['cover'] = self.get_cover_namespace(context) namespace['images'] = self.get_images_namespace(context) namespace['has_more_than_one_image'] = len(namespace['images']) > 1 # Product is buyable namespace['is_buyable'] = self.is_buyable(context) # Cross selling namespace['cross_selling'] = self.get_cross_selling_namespace(context) # Authentificated ? ac = self.get_access_control() namespace['is_authenticated'] = ac.is_authenticated(context.user, self) # Configuration configuration = ConfigurationProperty() configuration.context = context configuration.resource = self namespace['configuration'] = configuration # Shop modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = self namespace['module'] = shop_module return namespace
def get_namespace(self, context): root = context.root namespace = { 'name': self.name, 'abspath': self.get_abspath(), 'price': self.get_price_namespace() } # Get basic informations namespace['href'] = context.get_link(self) for key in product_schema.keys(): if key == 'data': continue namespace[key] = self.get_property(key) # Category namespace['category'] = { 'name': self.parent.name, 'href': context.get_link(self.parent), 'breadcrumb_title': self.parent.get_property('breadcrumb_title'), 'title': self.parent.get_title() } # Categorie XXX To remove namespace['categorie'] = self.parent.get_title() # Lang (usefull to show contextuel images) ws_languages = context.site_root.get_property('website_languages') accept = context.accept_language lang = accept.select_language(ws_languages) namespace['lang'] = lang # Manufacturer manufacturer = self.get_property('manufacturer') if manufacturer: manufacturer = root.get_resource(manufacturer) link = context.get_link(manufacturer) photo = manufacturer.get_property('photo') namespace['manufacturer'] = { 'name': manufacturer.name, 'link': link, 'photo': resolve_uri2(link, photo), 'title': manufacturer.get_title() } else: namespace['manufacturer'] = None # Data namespace['data'] = self.get_property('data') # Specific product informations model = self.get_product_model() if model: namespace.update(model.get_model_namespace(self)) else: namespace['specific_dict'] = {} namespace['specific_list'] = [] # Images namespace['cover'] = self.get_cover_namespace(context) namespace['images'] = self.get_images_namespace(context) namespace['has_more_than_one_image'] = len(namespace['images']) > 1 # Product is buyable namespace['is_buyable'] = self.is_buyable(context) # Cross selling namespace['cross_selling'] = self.get_cross_selling_namespace(context) # Authentificated ? ac = self.get_access_control() namespace['is_authenticated'] = ac.is_authenticated(context.user, self) # Configuration configuration = ConfigurationProperty() configuration.context = context configuration.resource = self namespace['configuration'] = configuration # Shop modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = self namespace['module'] = shop_module return namespace