def _registerPackage(module_, init_func=None): """Registers the given python package as a Zope 2 style product """ if not hasattr(module_, '__path__'): raise ValueError("Must be a package and the " \ "package must be filesystem based") app = Zope2.app() try: product = initializeProduct(module_, module_.__name__, module_.__path__[0], app) product.package_name = module_.__name__ if init_func is not None: newContext = ProductContext(product, app, module_) init_func(newContext) finally: try: import transaction transaction.commit() finally: app._p_jar.close()
def _registerPackage(module_, init_func=None): """Registers the given python package as a Zope 2 style product """ if not hasattr(module_, '__path__'): raise ValueError("Must be a package and the " \ "package must be filesystem based") registered_packages = getattr(Products, '_registered_packages', None) if registered_packages is None: registered_packages = Products._registered_packages = [] registered_packages.append(module_) # Delay the actual setup until the usual product loading time in # OFS.Application on versions of Zope that support this. # # Without this processing, we may get database write errors in # ZEO, when there's no connection with which to write an entry to # Control_Panel. We would also get multiple calls to initialize(). # # For older versions of Zope not aware of this variable, initialize # immediately as before to_initialize = getattr(Products, '_packages_to_initialize', None) if to_initialize is None: app = Zope2.app() try: try: product = initializeProduct(module_, module_.__name__, module_.__path__[0], app) product.package_name = module_.__name__ if init_func is not None: newContext = ProductContext(product, app, module_) init_func(newContext) except: raise else: transaction.commit() finally: app._p_jar.close() else: to_initialize.append(( module_, init_func, ))
def _registerPackage(module_, initFunc=None): """Registers the given python package as a Zope 2 style product """ if not hasattr(module_, '__path__'): raise ValueError("Must be a package and the " \ "package must be filesystem based") product = initializeProduct(module_, module_.__name__, module_.__path__[0], pythonproducts._zope_app) product.package_name = module_.__name__ if initFunc is not None: newContext = ProductContext(product, pythonproducts._zope_app, module_) initFunc(newContext)