def test_0001_cache_post_register(self): """ Cache registered after helper. """ helper = Helper() cache = EvelinkSqliteCache(':memory:') getSiteManager().registerUtility(cache, IEvelinkCache) # The API cache in the instances for the helper is still same. self.assertNotEqual(helper.eve.api.cache, cache) # Try this again. helper.eve.api.cache.put('dummy', 'test_value', 100) # As the cache utility is registered, data would not be here. self.assertEqual(helper.eve.api.cache.cache, {}) # the cached data will however be present here. self.assertEqual(cache.get('dummy'), 'test_value') api = API() self.assertEqual(api.cache, cache) self.assertTrue(hasattr(api.cache, 'connection'))
def _createContainer(self, container, name, root=None, createDir=False): # We need a context that can be traversed using absolute paths, # but the site manager acquired ones do not provide this. # # So we work around using getSite, but with the caveat that it # might not work because of how getSite may acquire the wrong # object because this method may be called under a different # context, which we will abort. if not getSiteManager(self) == getSiteManager(): raise Exception('Site manager does not match context') site = getSite() if root: folder = site.unrestrictedTraverse(str(root), None) if folder is None: # XXX exception type raise ValueError('Target root not found') # XXX check to make sure folder is folderish else: folder = site existed = folder.unrestrictedTraverse(name, None) if existed is not None: return False folder[name] = container(name) folder[name].reindexObject() if createDir: self.createDir(folder[name]) return True
def test_unregister_behavior(self): # Test taxonomy registration taxonomy = queryUtility(ITaxonomy, name='collective.taxonomy.test') self.assertIsNotNone(taxonomy) # Unregister behavior taxonomy.unregisterBehavior() # Test behavior registration behavior = queryUtility(IBehavior, name=taxonomy.getGeneratedName()) self.assertIsNone(behavior) # Test index creation pc = api.portal.get_tool('portal_catalog') self.assertNotIn('taxonomy_test', pc.indexes()) # Test indexer registration sm = getSiteManager() indexer = sm._adapter_registrations.get( ((IDexterityContent, IZCatalog), IIndexer, 'taxonomy_test'), None) self.assertIsNone(indexer) # Test querystring configuration registry = queryUtility(IRegistry) self.assertIsNotNone(registry) prefix = 'plone.app.querystring.field.taxonomy_test' self.assertRaises( KeyError, registry.forInterface, IQueryField, prefix=prefix) # noqa
def test_unregister_behavior(self): # Test taxonomy registration taxonomy = queryUtility(ITaxonomy, name="collective.taxonomy.test") self.assertIsNotNone(taxonomy) # Unregister behavior taxonomy.unregisterBehavior() # Test behavior registration behavior = queryUtility(IBehavior, name=taxonomy.getGeneratedName()) self.assertIsNone(behavior) # Test index creation pc = api.portal.get_tool("portal_catalog") self.assertNotIn("taxonomy_test", pc.indexes()) # Test indexer registration sm = getSiteManager() indexer = sm._adapter_registrations.get( ((IDexterityContent, IZCatalog), IIndexer, "taxonomy_test"), None ) self.assertIsNone(indexer) # Test querystring configuration registry = queryUtility(IRegistry) self.assertIsNotNone(registry) prefix = "plone.app.querystring.field.taxonomy_test" self.assertRaises( KeyError, registry.forInterface, IQueryField, prefix=prefix ) # noqa
def register(fti): """Helper method to: - register an FTI as a local utility - register a local factory utility - register an add view """ fti = aq_base(fti) # remove acquisition wrapper site = getUtility(ISiteRoot) site_manager = getSiteManager(site) portal_type = fti.getId() fti_utility = queryUtility(IDexterityFTI, name=portal_type) if fti_utility is None: site_manager.registerUtility(fti, IDexterityFTI, portal_type, info='plone.dexterity.dynamic') factory_utility = queryUtility(IFactory, name=fti.factory) if factory_utility is None: site_manager.registerUtility(DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic')
def getToolByName(obj, name, default=_marker): try: cache = localData.cache3 except: cache = {} if name in cache: tool = cache[name] if tool is not None: return tool if name in _tool_interface_registry: try: utility = getSiteManager().getUtility(_tool_interface_registry[name]) cache[name] = utility if hasattr(utility, '__of__') and aq_parent(utility) is None: utility = utility.__of__(obj) return utility except ComponentLookupError: pass try: tool = aq_get(obj, name, default, 1) except AttributeError: if default is _marker: raise cache[name] = tool return default else: if tool is _marker: raise AttributeError, name cache[name] = tool return tool
def get_queue(name): queue = component.queryUtility(IQueue, name) if queue is None: queue = Queue() sm = getSiteManager() sm.registerUtility(queue, provided=IQueue, name=name) return queue
def handleInstall(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return changes = False server = self.getContent() if server is None: sm = getSiteManager() server = self.serverFactory() sm.registerUtility(server, IMorreServer) changes = True changes = self.applyChanges(data) or changes try: updated = server.update() if changes or updated: self.status = self.successMessage elif not self.status: # only if this was not already applied. self.status = self.noChangesMessage except MorreServerError: self.status = _(u'There were errors with the update; ' 'details can be found in server logs.')
def test_register_behavior(self): # Test taxonomy registration taxonomy = queryUtility(ITaxonomy, name='collective.taxonomy.test') self.assertIsNotNone(taxonomy) # Test behavior registration behavior = queryUtility(IBehavior, name=taxonomy.getGeneratedName()) self.assertIsNotNone(behavior) # Test index creation pc = api.portal.get_tool('portal_catalog') self.assertIn('taxonomy_test', pc.indexes()) # Test indexer registration sm = getSiteManager() indexer = sm._adapter_registrations.get( ((IDexterityContent, IZCatalog), IIndexer, 'taxonomy_test'), None) self.assertIsNotNone(indexer) # Test querystring configuration registry = queryUtility(IRegistry) self.assertIsNotNone(registry) prefix = 'plone.app.querystring.field.taxonomy_test' records = registry.forInterface(IQueryField, prefix=prefix) # noqa self.assertIsNotNone(records)
def register(fti): """Helper method to: - register an FTI as a local utility - register a local factory utility - register an add view """ fti = aq_base(fti) # remove acquisition wrapper site = getUtility(ISiteRoot) site_manager = getSiteManager(site) portal_type = fti.getId() fti_utility = queryUtility(IDexterityFTI, name=portal_type) if fti_utility is None: site_manager.registerUtility( fti, IDexterityFTI, portal_type, info='plone.dexterity.dynamic' ) factory_utility = queryUtility(IFactory, name=fti.factory) if factory_utility is None: site_manager.registerUtility( DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic' )
def test_basic_workflow_not_setup(self): # Make sure this doesn't crap out. sm = getSiteManager() server = MockMorreServer() sm.registerUtility(server, IMorreServer) self._publishContent(self.portal.exposure['1']) self.assertIsNone(server._last_post)
def test_basic_workflow_index_and_deindex(self): # Make sure this doesn't crap out. sm = getSiteManager() server = MockMorreServer() server.index_on_wfstate = [u'published'] server.portal_http_host = u'127.0.0.1:8000' sm.registerUtility(server, IMorreServer) self._publishContent(self.portal.exposure['1']) self.assertEqual(server._last_post, { 'endpoint': '/morre/model_update_service/add_model', 'data': { 'url': u'http://127.0.0.1:8000/plone/exposure/1/file', 'modelType': 'CELLML', 'fileId': 'file', }, }) # retract it pw = getToolByName(self.portal, "portal_workflow") self.setRoles(('Manager',)) pw.doActionFor(self.portal.exposure['1'], "retract") self.setRoles(('Member', 'Authenticated',)) self.assertEqual(server._last_post, { 'endpoint': '/morre/model_update_service/delete_model', 'data': {'uID': '1'} })
def ftiModified(object, event): """When an FTI is modified, re-sync and invalidate the schema, if necessary. """ if not IDexterityFTI.providedBy(event.object): return fti = event.object portal_type = fti.getId() mod = {} for desc in event.descriptions: if IDexterityFTIModificationDescription.providedBy(desc): mod[desc.attribute] = desc.oldValue # If the factory utility name was modified, we may get an orphan if one # was registered as a local utility to begin with. If so, remove the # orphan. if 'factory' in mod: old_factory = mod['factory'] site = getUtility(ISiteRoot) site_manager = getSiteManager(site) # Remove previously registered factory, if no other type uses it. unregister_factory(old_factory, site_manager) # Register a new local factory if one doesn't exist already new_factory_utility = queryUtility(IFactory, name=fti.factory) if new_factory_utility is None: site_manager.registerUtility(DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic') # Determine if we need to invalidate the schema at all if 'behaviors' in mod \ or 'schema' in mod \ or 'model_source' in mod \ or 'model_file' in mod \ or 'schema_policy' in mod: # Determine if we need to re-sync a dynamic schema if (fti.model_source or fti.model_file) \ and ('model_source' in mod or 'model_file' in mod or 'schema_policy' in mod): schemaName = portalTypeToSchemaName(portal_type) schema = getattr(plone.dexterity.schema.generated, schemaName) model = fti.lookupModel() sync_bases = 'schema_policy' in mod syncSchema(model.schema, schema, overwrite=True, sync_bases=sync_bases) notify(SchemaInvalidatedEvent(portal_type))
def setUp(self): # XXX split this out into the setup decorator? self.testdir = tempfile.mkdtemp() self.repodir = join(self.testdir, "repodir") Sandbox.create(self.repodir, True) self.revs = [] sandbox = Sandbox(self.repodir, ctx="tip") self.path = dirname(__file__) self.filelist = ["file1", "file2", "file3"] self.nested_name = "nested/deep/dir/file" self.nested_file = "This is\n\na deeply nested file\n" self.files = [open(join(self.path, i)).read() for i in self.filelist] self.msg = "added some files" self.user = "******" self.date = str(datetime.date.today()) sandbox.add_file_content("file1", self.files[0]) sandbox.add_file_content("file2", self.files[0]) sandbox.commit("added1", "user1 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content("file1", self.files[1]) sandbox.commit("added2", "user2 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content("file2", self.files[1]) sandbox.add_file_content("file3", self.files[0]) sandbox.commit("added3", "user3 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) sandbox.add_file_content(self.nested_name, self.nested_file) sandbox.commit("added4", "user3 <*****@*****.**>") self.revs.append(Storage(self.repodir, ctx="tip").rev) self.fulllist = self.filelist + [self.nested_name] self.repo = Storage(self.repodir, ctx="tip") self.rev = self.repo.rev clearZCML() xmlconfig(open(join(pmr2.mercurial.__path__[0], "utility.zcml"))) # register custom utility that would have normally been done. sm = getSiteManager() sm.registerUtility(MercurialSettings(), IPMR2GlobalSettings) self.settings = zope.component.getUtility(IPMR2GlobalSettings) self.workspace = DummyWorkspace(self.repodir) util.extract_archive(self.testdir) self.pmr2hgtest = DummyWorkspace(join(self.testdir, "pmr2hgtest")) self.import1 = DummyWorkspace(join(self.testdir, "import1")) self.import2 = DummyWorkspace(join(self.testdir, "import2")) self.simple1 = DummyWorkspace(join(self.testdir, "simple1")) self.simple2 = DummyWorkspace(join(self.testdir, "simple2")) self.simple3 = DummyWorkspace(join(self.testdir, "simple3"))
def setUp(self): setUp(self) sm = getSiteManager() self.dk = DummyKeyManager() sm.registerUtility(self.dk, IAPIKeyManager) self.backend = zope.component.getUtility(ITrackerBackend) self.manager = TowerManager()
def handleBack(self, action): context = self.context.context quote = lambda x:urllib.quote(x.encode("utf-8")) self.request.response.redirect( u"%s/select_group?context=%s&title=%s" % ( absoluteURL(hooks.getSiteManager(), self.request), absoluteURL(context, self.request), quote(IZopeDublinCore(context).title or context.__name__)))
def get_queue(name): """Fix other people's missing docstrings.""" queue = component.queryUtility(IQueue, name) if queue is None: queue = Queue() sm = getSiteManager() sm.registerUtility(queue, provided=IQueue, name=name) return queue
def handleBack(self, action): context = self.context.context quote = lambda x: urllib.quote(x.encode("utf-8")) self.request.response.redirect( u"%s/select_group?context=%s&title=%s" % (absoluteURL(hooks.getSiteManager(), self.request), absoluteURL(context, self.request), quote(IZopeDublinCore(context).title or context.__name__)))
def ftiModified(object, event): """When an FTI is modified, re-sync and invalidate the schema, if necessary. """ if not IDexterityFTI.providedBy(event.object): return fti = event.object portal_type = fti.getId() mod = {} for desc in event.descriptions: if IDexterityFTIModificationDescription.providedBy(desc): mod[desc.attribute] = desc.oldValue # If the factory utility name was modified, we may get an orphan if one # was registered as a local utility to begin with. If so, remove the # orphan. if 'factory' in mod: old_factory = mod['factory'] site = getUtility(ISiteRoot) site_manager = getSiteManager(site) # Remove previously registered factory, if no other type uses it. unregister_factory(old_factory, site_manager) # Register a new local factory if one doesn't exist already new_factory_utility = queryUtility(IFactory, name=fti.factory) if new_factory_utility is None: site_manager.registerUtility( DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic' ) # Determine if we need to invalidate the schema at all if 'behaviors' in mod \ or 'schema' in mod \ or 'model_source' in mod \ or 'model_file' in mod \ or 'schema_policy' in mod: # Determine if we need to re-sync a dynamic schema if (fti.model_source or fti.model_file) \ and ('model_source' in mod or 'model_file' in mod or 'schema_policy' in mod): schemaName = portalTypeToSchemaName(portal_type) schema = getattr(plone.dexterity.schema.generated, schemaName) model = fti.lookupModel() sync_bases = 'schema_policy' in mod syncSchema(model.schema, schema, overwrite=True, sync_bases=sync_bases) notify(SchemaInvalidatedEvent(portal_type))
def test_0001_standard(self): sm = getSiteManager() sm.registerUtility(utility.TestLayerApplier(), ILayerApplier, name='testlayer') self.request['HTTP_ACCEPT'] = 'application/vnd.example.com-v1' self.assertFalse(utility.IExampleTestLayer.providedBy(self.request)) mark_layer(self.portal, self.event) self.assertTrue(utility.IExampleTestLayer.providedBy(self.request))
def test_0002_cache_pre_register(self): """ Cache registered before helper. """ cache = EvelinkSqliteCache(':memory:') getSiteManager().registerUtility(cache, IEvelinkCache) helper = Helper() # Now the cache is right away an instance of the sqlite cache # rather than the dynamic class. This may or may not be # desirable self.assertEqual(helper.eve.api.cache, cache) api = API() self.assertEqual(api.cache, cache) self.assertTrue(hasattr(api.cache, 'connection'))
def setUp(self): setUp(self) # specify backend here with backend arg when done init_test_db() self.backend = zope.component.getUtility(ITrackerBackend) self.manager = TowerManager() self.frontend = Json(self.backend) sm = getSiteManager() self.dk = DummyKeyManager() sm.registerUtility(self.dk, IAPIKeyManager)
def test_0002_multi(self): sm = getSiteManager() sm.registerUtility(utility.MultiTestLayerApplier(), ILayerApplier, name='multilayer') self.request['HTTP_ACCEPT'] = 'application/vnd.example.com.tests' mark_layer(self.portal, self.event) self.assertTrue(utility.ITestLayer1.providedBy(self.request)) self.assertTrue(utility.ITestLayer2.providedBy(self.request)) self.assertTrue(utility.ITestLayer3.providedBy(self.request))
def register_error_mail_router(self, error_class): sm = getSiteManager() MockMailRouter = Mock( return_value=False, side_effect=error_class('An error happened!')) MockMailRouter.getPhysicalPath = Mock( return_value='/plone/mockmailrouter') sm.registerUtility( name='mockmail', provided=IMailRouter, component=MockMailRouter)
def isOpinionExpressed(self, request, identifier=None): if identifier is None: identifier = self.identifier_factory.getIdentifierForCurrentRequest( request) else: identifier = self.identifier_factory.getIdentifierForUser( identifier) if identifier is None: raise ValueError("Couldn't identify user") else: site = getSiteManager() storage = self.optinoptout_storage(self, site, request) value = storage.getProcessingStatus(identifier) return value is not None
def _setValue(self, request, user, value): if user is not None: identifier = self.identifier_factory.getIdentifierForUser(user) else: identifier = self.identifier_factory.getIdentifierForCurrentRequest( request) if identifier is None: raise ValueError("Couldn't identify user") else: site = getSiteManager() storage = self.optinoptout_storage(self, site, request) if value: storage.consentToProcessing(identifier) else: storage.objectToProcessing(identifier)
def handleUninstall(self, action): data, errors = self.extractData() if errors: # No real need to check errors as the content is being # removed pass server = self.getContent() if server is None: self.status = _(u'Server was not installed') return sm = getSiteManager() sm.unregisterUtility(server, IMorreServer) self.status = _(u'Server uninstalled')
def isProcessingAllowed(self, request, identifier=None): """Return True if processing is allowed or False if not""" if identifier is None: identifier = self.identifier_factory.getIdentifierForCurrentRequest( request) else: identifier = self.identifier_factory.getIdentifierForUser( identifier) if identifier is None: raise ValueError("Couldn't identify user") else: site = getSiteManager() storage = self.optinoptout_storage(self, site, request) value = storage.getProcessingStatus(identifier) if value is None: value = self.lawful_basis.default return value
def unregister(fti, old_name=None): """Helper method to: - unregister the FTI local utility - unregister any local factory utility associated with the FTI - unregister any local add view associated with the FTI """ site = queryUtility(ISiteRoot) if site is None: return site_manager = getSiteManager(site) portal_type = old_name or fti.getId() notify(SchemaInvalidatedEvent(portal_type)) site_manager.unregisterUtility(provided=IDexterityFTI, name=portal_type) unregister_factory(fti.factory, site_manager)
def setUpZope(self, app, configurationContext): import slc.mailrouter self.loadZCML( 'configure.zcml', package=slc.mailrouter, ) try: import plone.app.contenttypes except ImportError: self.have_pacontenttypes = False else: self.have_pacontenttypes = True self.loadZCML( 'configure.zcml', package=plone.app.contenttypes, ) gsm = getSiteManager() from Products.CMFCore.interfaces import IFolderish from slc.mailrouter.interfaces import IMailImportAdapter from slc.mailrouter.adapters import FolderAdapter gsm.registerAdapter(FolderAdapter, required=(IFolderish, ), provided=IMailImportAdapter)
def setUpZope(self, app, configurationContext): import slc.mailrouter self.loadZCML( 'configure.zcml', package=slc.mailrouter, ) try: import plone.app.contenttypes except ImportError: self.have_pacontenttypes = False else: self.have_pacontenttypes = True self.loadZCML( 'configure.zcml', package=plone.app.contenttypes, ) gsm = getSiteManager() from Products.CMFCore.interfaces import IFolderish from slc.mailrouter.interfaces import IMailImportAdapter from slc.mailrouter.adapters import FolderAdapter gsm.registerAdapter( FolderAdapter, required=(IFolderish, ), provided=IMailImportAdapter)
def handleDelete(self, action): name = self.request.get('id') del self.context[name] url = u"%s/groups" % absoluteURL(getSiteManager(), self.request) self.request.response.redirect(url)
def registerHelper(helper=None): # set up the helper if helper is None: helper = DummyHelper() sm = getSiteManager() sm.registerUtility(helper, IAPIHelper)
def render(self): return u'<a href="%s">%s</a>' % (absoluteURL(getSiteManager(), self.request), self.title)
def _callFUT(self, context=None): from zope.component.hooks import getSiteManager return getSiteManager(context)
# -*- coding: utf-8 -*- import pkg_resources try: pkg_resources.get_distribution("plone.dexterity") except pkg_resources.DistributionNotFound: # No plone.dexterity available. pass else: # plone.dexterity is there and we need to register its utility. from plone.dexterity.schema import SchemaModuleFactory from zope.component.hooks import getSiteManager sm = getSiteManager() sm.registerUtility(factory=SchemaModuleFactory, name="plone.dexterity.schema.generated")
def registerBackend(backend=None): # The basic memory based backend. if backend is None: backend = SQLAlchemyBackend() sm = getSiteManager() sm.registerUtility(backend, ITrackerBackend)
def handleBack(self, action): self.request.response.redirect( u"%s/users" % absoluteURL(hooks.getSiteManager(), self.request))
class RedirectionTool(Persistent): '''blanc used for alias''' pass alias_module('Products.RedirectionTool.RedirectionTool.RedirectionTool', RedirectionTool) LOGGER.warn("Alias registered for missing: " "Products.RedirectionTool.RedirectionTool.RedirectionTool") try: # pylint: disable=ungrouped-imports from plone.dexterity.schema import SchemaModuleFactory from zope.component.hooks import getSiteManager SM = getSiteManager() SM.registerUtility(factory=SchemaModuleFactory, name="plone.dexterity.schema.generated") except Exception as err: LOGGER.exception(err) else: LOGGER.warn("Manually register plone.dexterity.schema.generated utility") # # Custom renames for zodbupdate # RENAME_DICT = { # 'mypackage.mymodule ClassName':'otherpackage.othermodule OtherClass' }
def siteManagerUnrestrictedTraverse(self, subpath): sm = getSiteManager(self) path = '../%s' % subpath return sm.unrestrictedTraverse(str(path), None)
def tearDown(self): server = queryUtility(IMorreServer) if server: sm = getSiteManager() sm.unregisterUtility(server, IMorreServer)
def uninstall_persistent_userdataschemaprovider(context): """ We need to get rid off a VERY persistent UserDataSchemaProvider. We tried to do this the 'nice' way, via unregisterUtility, and other unregister functionality of the SiteMangers, but it just did not work. Our UserDataSchemaProvider object kept popping up after removing the product. Resulting in fatal errors like these when hitting plone: TypeError: ('object.__new__(UserDataSchemaProvider) is not safe, use persistent.Persistent.__new__()', <function _reconstructor at 0x7ff92a4f4668>, (<class 'collective.smsauthenticator.userdataschema.UserDataSchemaProvider'>, <type 'object'>, None)) And of course a nice warning: WARNING OFS.Uninstalled Could not import class 'UserDataSchemaProvider' from module 'collective.smsauthenticator.userdataschema' We do the following: 1. Get the IUserDataSchemaProvider util 2. Get the IEnhancedUserDataSchema util (the same as #1, other interface) 3. Get the BaseComponent sitemanager (zope.component.registry) 4. Get the PersistentComponents sitemanger (five.localsitemanager.registry) 5. For each of thse sitemanagers: a. Loop over _adapters, delete anything related to our product, or userdata b. Loop over _subscribers, delete anything related to our product, or userdata c. Loop over _provided, delete anything related to our product, or userdata 6. Delete the utils from #1. and #2. """ from zope.component.hooks import getSiteManager # Get our util util = None try: util = getUtility(IEnhancedUserDataSchema) except ComponentLookupError: pass # Get plone.app.user util util2 = None try: util2 = getUtility(IUserDataSchemaProvider) except ComponentLookupError: pass # Get the sitemanagers involved components_sm = getSiteManager() base_sm = getSiteManager(context=context) # Loop over the sitemanagers for sm in [base_sm, components_sm]: uninstall_logger.info("Handeling {0}".format(sm)) # Get the lowlevel registry stuff. adapters = sm.utilities._adapters subscribers = sm.utilities._subscribers provided = sm.utilities._provided # Adapter looping for x in adapters[0].keys(): if x.__module__.find("smsauthenticator") != -1\ or x.__module__.find("userdata") != -1: del adapters[0][x] uninstall_logger.info("Removed adapter: {0}".format(x)) # Overwrite the adapters sm.utilities._adapters = adapters # Subscribers looping for x in subscribers[0].keys(): if x.__module__.find("smsauthenticator") != -1\ or x.__module__.find("userdata") != -1: del subscribers[0][x] uninstall_logger.info("Removed subscriber: {0}".format(x)) # Overwrite the subscribers sm.utilities._subscribers = subscribers # Provided looping for x in provided.keys(): if x.__module__.find("smsauthenticator") != -1\ or x.__module__.find("userdata") != -1: del provided[x] uninstall_logger.info("Removed provider: {0}".format(x)) # Overwrite the provided sm.utilities._provided = provided # Ensure this is commited import transaction transaction.commit() # Delete the utils. No idea if needed # But this works like this, so keeping it. if util: del util if util2: del util2 uninstall_logger.info("Done ..")