def createDirectDelivery(): mailerObject = _get_mailer(mailer) delivery = DirectMailDelivery(mailerObject) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name)
def resourceHandler(name, layer, checker, factory, file, context_info): if factory is not None: factory = ResourceFactoryWrapper(factory, checker, name) else: ext = os.path.splitext(os.path.normcase(file))[1][1:] factory_factory = queryUtility(IResourceFactoryFactory, ext, FileResourceFactory) factory = factory_factory(file, checker, name) handler('registerAdapter', factory, (layer,), Interface, name, context_info)
def registerPagelets(required, newClass, provides, name, info): handler('registerAdapter', newClass, required, IPagelet, name, info) for iface in provides: if iface is IPagelet: continue if IPageletType.providedBy(iface): handler('registerAdapter', newClass, required, iface, '', info)
def registerTypedPagelets(required, newClass, type, name, _context): for tp in type: iface = queryUtility(IPageletType, tp) if iface is None: try: iface = _context.resolve(tp) except Exception, err: pass handler('registerAdapter', newClass, required, iface,name,_context.info)
def createDirectDelivery(): mailerObject = queryUtility(IMailer, mailer) if mailerObject is None: raise ConfigurationError("Mailer %r is not defined" % mailer) delivery = DirectMailDelivery(mailerObject) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name)
def createDirectDelivery(): mailerObject = queryUtility(IMailer, mailer) if mailerObject is None: raise ConfigurationError("Mailer %r is not defined" %mailer) delivery = DirectMailDelivery(mailerObject) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name)
def package(name, type, title, order, layer, library, require): global _libraries, _packages sm = getGlobalSiteManager() # create marker interface marker = _libraries.get((library, type)) if marker is None: uid = str(random.randint(0, 9999999)) marker = InterfaceClass('IPackage%s'%uid, (interface.Interface,), __doc__='Package: %s' %name, __module__='zojax.resourcepackage') _libraries[(library, type)] = marker # check if package already registered packageInfo = None for (_layer, _library, _type), _packageInfo in _packages.items(): if _library == library and layer.isOrExtends(_layer) and _type == type: packageInfo = _packageInfo if packageInfo is not None: # register library if library: lib = sm.queryUtility(ILibrary, name=library) if lib is None: lib = Library(library) handler('registerUtility', lib, ILibrary, library) lib.add(name, require) return # create package package = getUtility(IPackageFactory, type)(name, order, title) interface.directlyProvides(package, marker) factory = Factory(package) # register resource sm.registerAdapter(factory, (layer, ), interface.Interface, name) sm.registerAdapter(factory, (layer, ), IPackage, name) # register package info packageInfo = PackageInfo(library, layer, marker, package) _packages[(layer, library, type)] = packageInfo # register library if library: lib = sm.queryUtility(ILibrary, name=library) if lib is None: lib = Library(library) handler('registerUtility', lib, ILibrary, library) lib.add(name, require)
def resourceHandler(name, layer, checker, file, type, info): if type: factory = getUtility(IResourceFactoryType, name=type) else: type = os.path.splitext(os.path.normcase(name))[1][1:] factory = queryUtility(IResourceFactoryType, name=type) if factory is None: factory = getUtility(IResourceFactoryType) factory = factory(file, checker, name) handler('registerAdapter', factory, (layer,), interface.Interface, name, info)
def createQueuedDelivery(): delivery = QueuedMailDelivery(queuePath) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name) mailerObject = _get_mailer(mailer) if processorThread: thread = QueueProcessorThread() thread.setMailer(mailerObject) thread.setQueuePath(queuePath) thread.start()
def createQueuedDelivery(): delivery = QueuedMailDelivery(queuePath) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name) mailerObject = queryUtility(IMailer, mailer) if mailerObject is None: raise ConfigurationError("Mailer %r is not defined" % mailer) if processorThread: thread = QueueProcessorThread() thread.setMailer(mailerObject) thread.setQueuePath(queuePath) thread.start()
def createQueuedDelivery(): delivery = QueuedMailDelivery(queuePath) if permission is not None: delivery = _assertPermission(permission, IMailDelivery, delivery) handler('registerUtility', delivery, IMailDelivery, name) mailerObject = queryUtility(IMailer, mailer) if mailerObject is None: raise ConfigurationError("Mailer %r is not defined" %mailer) if processorThread: thread = QueueProcessorThread() thread.setMailer(mailerObject) thread.setQueuePath(queuePath) thread.start()
def setDefaultSkin(name, info=''): """Set the default skin. >>> from zope.interface import directlyProvides >>> from zope.app.testing import ztapi >>> class Skin1: pass >>> directlyProvides(Skin1, IBrowserSkinType) >>> ztapi.provideUtility(IBrowserSkinType, Skin1, 'Skin1') >>> setDefaultSkin('Skin1') >>> adapters = component.getSiteManager().adapters Lookup the default skin for a request that has the >>> adapters.lookup((IBrowserRequest,), IDefaultSkin, '') is Skin1 True """ skin = component.getUtility(IBrowserSkinType, name) handler('registerAdapter', skin, (IBrowserRequest,), IDefaultSkin, '', info),
def setDefaultSkin(name, info=''): """Set the default skin. >>> from zope.interface import directlyProvides >>> from zope.app.testing import ztapi >>> class Skin1: pass >>> directlyProvides(Skin1, IBrowserSkinType) >>> ztapi.provideUtility(IBrowserSkinType, Skin1, 'Skin1') >>> setDefaultSkin('Skin1') >>> adapters = component.getSiteManager().adapters Lookup the default skin for a request that has the >>> adapters.lookup((IBrowserRequest,), IDefaultSkin, '') is Skin1 True """ skin = component.getUtility(IBrowserSkinType, name) handler('registerAdapter', skin, (IBrowserRequest, ), IDefaultSkin, '', info),
def resourceInclude(name, layer, library, type, path, file, filetype, standalone, kw): sm = getGlobalSiteManager() for (_layer, _library, _type), packageInfo in _packages.items(): if _library == library and layer.isOrExtends(_layer) and _type == type: factory = getUtility(IPackageResourceFactory, type) global _idx _idx = _idx + 1 kw['order'] = _idx kw['standalone'] = standalone resourceFactory = None if file: if filetype: rfactory = queryUtility(IResourceFactoryType, name=filetype) else: filetype = os.path.splitext(os.path.normcase(name))[1][1:] rfactory = queryUtility(IResourceFactoryType, name=filetype) if rfactory is None: rfactory = getUtility(IResourceFactoryType) checker = NamesChecker(allowed_names, CheckerPublic) resourceFactory = rfactory(file, checker, name) handler('registerAdapter', resourceFactory, (layer,), interface.Interface, name) resource = factory(name, path, resourceFactory, **kw) sm.registerAdapter( resource, (layer, packageInfo.marker), IPackageResource, name) return raise ConfigurationError()
def setDefaultJSONRPCSkin(name, info=''): """Set the default skin.""" skin = zope.component.getUtility(interfaces.IJSONRPCSkinType, name=name) handler('registerAdapter', skin, (interfaces.IJSONRPCRequest, ), IDefaultSkin, '', info),
def _callFUT(self, *args, **kw): from zope.component.zcml import handler return handler(*args, **kw)
def setDefaultJSONRPCSkin(name, info=''): """Set the default skin.""" skin = zope.component.getUtility(interfaces.IJSONRPCSkinType, name=name) handler('registerAdapter', skin, (interfaces.IJSONRPCRequest,), IDefaultSkin, '', info),