def load_extensions(): """Load all available extensions. This is tipically called during application start up, and follows this sequence: * New available extensions are installed * Previously installed exceptions that are no longer available are uninstalled * All installed and enabled extensions are initialized """ with _extensions_lock: for entry_point in iter_entry_points("woost.extensions"): extension_type = entry_point.load() extension = extension_type.instance # Create an instance of each new extension if extension is None: def create_extension_instance(): extension = extension_type() extension.insert() transaction(create_extension_instance, max_attempts=5, desist=lambda: extension_type.instance is not None) # Load enabled extensions elif extension.enabled: extension.load()
def install(self): if not self.installed: def install_extension(): self._install() self.installing() self.installed = True transaction(install_extension, desist=lambda: self.installed)
def apply_args(self, args): self.action = args.action self.reset = args.reset self.errors = args.errors self.verbose = args.verbose if args.languages: self.languages = [ (None if lang == "neutral" else lang) for lang in args.languages ] if len(args.content) == 1 and args.content[0][0] == "export": self.export = args.content[0][1] if args.destination: sys.stderr.write( "Can't specify --destination when executing an existing " "export operation\n" ) sys.exit(1) if self.languages: sys.stderr.write( "Can't specify --languages when executing an existing " "export operation\n" ) sys.exit(1) if args.pending: sys.stderr.write( "Can't specify --pending when executing an existing " "export operation\n" ) sys.exit(1) else: if args.destination is None: args.destination = Configuration.instance.x_staticpub_default_dest if args.destination is None: args.destination = Destination.select()[0] if args.destination is None: sys.stderr.write("No destination available\n") sys.exit(1) if self.action == "export": try: self.export = transaction( self._create_export_from_args, action_args=(args,) ) except EmptyExport: pass elif self.action == "list": self.tasks = self._get_tasks_from_args(args)
def begin(self): def create_export(): with changeset_context(app.user): export = Export.new() export.destination = self.destination export.user = app.user for action, publishable, language in self.iter_tasks(): export.add_task(action, publishable, language) return export export = transaction(create_export) export.execute_in_subprocess() return export
def _load(self): from woost.extensions.locations import location, strings if self.should_update(): transaction(self.sync_locations, desist=lambda: not self.should_update())
def login(self, data): user = transaction(self.process_user_data, (data,)) app.authentication.set_user_session(user) return user
def load(): if should_update(): transaction(sync_locations, desist=lambda: not should_update())