def url(_context, for_, path_expression=None, urldata=None, attribute_to_parent=None, parent_utility=None, rootsite=None): """browser:url directive handler.""" if (not attribute_to_parent and not parent_utility and not urldata): raise TypeError( 'Must provide attribute_to_parent, urldata or parent_utility.') if attribute_to_parent: if attribute_to_parent not in for_: raise AttributeError( 'The name "%s" is not in %s.%s' % (attribute_to_parent, for_.__module__, for_.__name__)) if path_expression is not None: compiled_path_expression = TrustedEngine.compile(path_expression) # Dead chicken for the namespace gods. rootsite_ = rootsite if urldata: CanonicalUrlData = urldata elif attribute_to_parent: class CanonicalUrlData(CanonicalUrlDataBase): _for = for_ _compiled_path_expression = compiled_path_expression rootsite = rootsite_ @property def inside(self): return getattr(self.context, attribute_to_parent) else: class CanonicalUrlData(CanonicalUrlDataBase): _for = for_ _compiled_path_expression = compiled_path_expression rootsite = rootsite_ @property def inside(self): return getUtility(parent_utility) factory = [CanonicalUrlData] provides = ICanonicalUrlData adapter(_context, factory, provides, [for_])
def url(_context, for_, path_expression=None, urldata=None, attribute_to_parent=None, parent_utility=None, rootsite=None): """browser:url directive handler.""" if (not attribute_to_parent and not parent_utility and not urldata): raise TypeError( 'Must provide attribute_to_parent, urldata or parent_utility.') if attribute_to_parent: if attribute_to_parent not in for_: raise AttributeError('The name "%s" is not in %s.%s' % (attribute_to_parent, for_.__module__, for_.__name__)) if path_expression is not None: compiled_path_expression = TrustedEngine.compile(path_expression) # Dead chicken for the namespace gods. rootsite_ = rootsite if urldata: CanonicalUrlData = urldata elif attribute_to_parent: class CanonicalUrlData(CanonicalUrlDataBase): _for = for_ _compiled_path_expression = compiled_path_expression rootsite = rootsite_ @property def inside(self): return getattr(self.context, attribute_to_parent) else: class CanonicalUrlData(CanonicalUrlDataBase): _for = for_ _compiled_path_expression = compiled_path_expression rootsite = rootsite_ @property def inside(self): return getUtility(parent_utility) factory = [CanonicalUrlData] provides = ICanonicalUrlData adapter(_context, factory, provides, [for_])
def clear(): Engine.__init__() _Engine(Engine) TrustedEngine.__init__() _TrustedEngine(TrustedEngine)
def registerType(name, handler): Engine.registerType(name, handler) TrustedEngine.registerType(name, handler)