def _product_packages(): """Returns all product packages including the regularly defined zope2 packages and those without the Products namespace package. """ import Products packages = {} for x in dir(Products): m = getattr(Products, x) if isinstance(m, types.ModuleType): packages[x] = m for m in get_registered_packages(): packages[m.__name__] = m return packages
def initialize2(context): # allow for disabling PTS entirely by setting an environment variable. if bool(os.getenv('DISABLE_PTS')): log('Disabled by environment variable "DISABLE_PTS".', logging.WARNING) return cp = getattr(getattr(context, '_ProductContext__app', None), 'Control_Panel', None) # argh if cp is not None and cp_id in cp.objectIds(): cp_ts = getattr(cp, cp_id, None) # Clean up ourselves if cp_ts is not None: cp._delObject(cp_id) _remove_mo_cache(CACHE_PATH) # load translation files from all packages and products loaded = {} import Products packages = get_registered_packages() for package in packages: name = package.__name__ path = package.__path__[0] loaded[name] = True i18n_dir = os.path.join(path, 'i18n') if isdir(i18n_dir): _load_i18n_dir(i18n_dir) for product in get_products(): name = product[1] if name in IGNORED: continue basepath = product[3] fullname = 'Products.' + name # Avoid loading products registered as packages twice if loaded.get(fullname): continue loaded[fullname] = True i18n_dir = os.path.join(basepath, name, 'i18n') if isdir(i18n_dir): _load_i18n_dir(i18n_dir)
def get_packages(): """Returns a dict of package name to package path.""" result = {} packages = get_registered_packages() for package in packages: name = package.__name__ path = package.__path__[0] result[name] = path for product in get_products(): name = product[1] if name in IGNORED: continue basepath = product[3] fullname = "Products." + name # Avoid getting products registered as packages twice if result.get(fullname): continue result[fullname] = os.path.join(basepath, name) return result
def get_packages(): """Returns a dict of package name to package path.""" result = {} packages = get_registered_packages() for package in packages: name = package.__name__ path = package.__path__[0] result[name] = path for product in get_products(): name = product[1] if name in IGNORED: continue basepath = product[3] fullname = 'Products.' + name # Avoid getting products registered as packages twice if result.get(fullname): continue result[fullname] = os.path.join(basepath, name) return result