[TurboGears2] Add a patch to remove ming/mongo support, for now
Luke Macken
lmacken at fedoraproject.org
Mon Apr 8 21:27:05 UTC 2013
commit d2268b1d0c06f73a7291d92c0799cd4e891287fb
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Apr 8 16:23:22 2013 -0400
Add a patch to remove ming/mongo support, for now
TurboGears2-no-ming.patch | 234 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 234 insertions(+), 0 deletions(-)
---
diff --git a/TurboGears2-no-ming.patch b/TurboGears2-no-ming.patch
new file mode 100644
index 0000000..34b0911
--- /dev/null
+++ b/TurboGears2-no-ming.patch
@@ -0,0 +1,234 @@
+diff -Naur TurboGears2-2.3.0dev.orig/setup.py TurboGears2-2.3.0dev/setup.py
+--- TurboGears2-2.3.0dev.orig/setup.py 2013-04-03 14:09:04.123676741 -0400
++++ TurboGears2-2.3.0dev/setup.py 2013-04-03 14:09:13.131799891 -0400
+@@ -34,7 +34,6 @@
+ 'simplegeneric',
+ 'Formencode',
+ 'routes',
+- 'tgming',
+ 'tw.forms',
+ 'tw2.forms'])
+
+diff -Naur TurboGears2-2.3.0dev.orig/tests/test_configuration.py TurboGears2-2.3.0dev/tests/test_configuration.py
+--- TurboGears2-2.3.0dev.orig/tests/test_configuration.py 2013-04-03 14:09:04.122676727 -0400
++++ TurboGears2-2.3.0dev/tests/test_configuration.py 2013-04-03 14:10:16.524721026 -0400
+@@ -373,47 +373,6 @@
+ self.config.use_sqlalchemy = False
+ config.pop('sqlalchemy.master.url')
+
+- def test_setup_ming_persistance(self):
+- if PY3: raise SkipTest()
+-
+- package = PackageWithModel()
+- conf = AppConfig(minimal=True, root_controller=None)
+- conf.package = package
+- conf.model = package.model
+- conf.use_ming = True
+- conf['ming.url'] = 'mim://'
+- conf['ming.db'] = 'inmemdb'
+-
+- app = conf.make_wsgi_app()
+- assert app is not None
+-
+- def test_setup_ming_persistance_with_url_alone(self):
+- if PY3: raise SkipTest()
+-
+- package = PackageWithModel()
+- conf = AppConfig(minimal=True, root_controller=None)
+- conf.package = package
+- conf.model = package.model
+- conf.use_ming = True
+- conf['ming.url'] = 'mim://inmemdb'
+-
+- app = conf.make_wsgi_app()
+- assert app is not None
+-
+- def test_setup_ming_persistance_advanced_options(self):
+- if PY3: raise SkipTest()
+-
+- package = PackageWithModel()
+- conf = AppConfig(minimal=True, root_controller=None)
+- conf.package = package
+- conf.model = package.model
+- conf.use_ming = True
+- conf['ming.url'] = 'mim://inmemdb'
+- conf['ming.connection.read_preference'] = 'PRIMARY'
+-
+- app = conf.make_wsgi_app()
+- assert app is not None
+-
+ def test_add_auth_middleware(self):
+ class Dummy:pass
+
+@@ -453,14 +412,6 @@
+
+ assert 'repoze.who.plugins' in app.get('/test')
+
+- def test_setup_ming_auth(self):
+- self.config.auth_backend = 'ming'
+-
+- self.config.setup_auth()
+- assert 'sa_auth' in config
+-
+- self.config.auth_backend = None
+-
+ def test_register_hooks(self):
+ def dummy(*args):
+ pass
+@@ -692,23 +643,6 @@
+ self.config.auth_backend = None
+ config.sa_auth = past_config_sa_auth
+
+- def test_ming_auth_middleware(self):
+- if PY3: raise SkipTest()
+-
+- self.config.auth_backend = 'ming'
+- self.config['sa_auth'] = {'authmetadata': ApplicationAuthMetadata(),
+- 'user_class':None,
+- 'cookie_secret':'12345',
+- 'authenticators':[('default', None)]}
+- self.config.add_auth_middleware(None, True)
+-
+- authenticators = [x[0] for x in self.config['sa_auth']['authenticators']]
+- assert 'cookie' in authenticators
+- assert 'mingauth' in authenticators
+-
+- self.config['sa_auth'] = {}
+- self.config.auth_backend = None
+-
+ @raises(KeyError)
+ def test_sqla_auth_middleware_no_backend(self):
+ #This is expected to raise error as no authenticators are specified for a custom backend
+diff -Naur TurboGears2-2.3.0dev.orig/tg/configuration/app_config.py TurboGears2-2.3.0dev/tg/configuration/app_config.py
+--- TurboGears2-2.3.0dev.orig/tg/configuration/app_config.py 2013-04-03 14:09:04.113676607 -0400
++++ TurboGears2-2.3.0dev/tg/configuration/app_config.py 2013-04-03 14:09:57.813450093 -0400
+@@ -160,7 +160,6 @@
+ self.enable_routing_args = False
+ self.disable_request_extensions = minimal
+
+- self.use_ming = False
+ self.use_sqlalchemy = False
+ self.use_transaction_manager = not minimal
+ self.commit_veto = None
+@@ -639,52 +638,10 @@
+ """Override this method to define how your application configures it's persistence model.
+ the default is to setup sqlalchemy from the cofiguration file, but you might choose
+ to set up a persistence system other than sqlalchemy, or add an additional persistence
+- layer. Here is how you would go about setting up a ming (mongo) persistence layer::
+-
+- class MingAppConfig(AppConfig):
+- def setup_persistence(self):
+- self.ming_ds = DataStore(config['mongo.url'])
+- session = Session.by_name('main')
+- session.bind = self.ming_ds
++ layer.
+ """
+ if self.use_sqlalchemy:
+ self.setup_sqlalchemy()
+- elif self.use_ming:
+- self.setup_ming()
+-
+- def setup_ming(self):
+- """Setup MongoDB database engine using Ming"""
+- try:
+- from ming import create_datastore
+- def create_ming_datastore(url, database, **kw):
+- if database and url[-1] != '/':
+- url += '/'
+- ming_url = url + database
+- return create_datastore(ming_url, **kw)
+- except ImportError: #pragma: no cover
+- from ming.datastore import DataStore
+- def create_ming_datastore(url, database, **kw):
+- return DataStore(url, database=database, **kw)
+-
+- def mongo_read_pref(value):
+- from pymongo.read_preferences import ReadPreference
+- return getattr(ReadPreference, value)
+-
+- datastore_options = coerce_config(config, 'ming.connection.', {'max_pool_size':asint,
+- 'network_timeout':asint,
+- 'tz_aware':asbool,
+- 'safe':asbool,
+- 'journal':asbool,
+- 'wtimeout':asint,
+- 'fsync':asbool,
+- 'ssl':asbool,
+- 'read_preference':mongo_read_pref})
+- datastore_options.pop('host', None)
+- datastore_options.pop('port', None)
+-
+- datastore = create_ming_datastore(config['ming.url'], config.get('ming.db', ''), **datastore_options)
+- config['pylons.app_globals'].ming_datastore = datastore
+- self.package.model.init_model(datastore)
+
+ def setup_sqlalchemy(self):
+ """Setup SQLAlchemy database engine.
+@@ -753,7 +710,7 @@
+
+ For the standard TurboGears App, this will set up the auth with SQLAlchemy.
+ """
+- if self.auth_backend in ("ming", "sqlalchemy"):
++ if self.auth_backend in ("sqlalchemy",):
+ self.setup_sa_auth_backend()
+
+ def setup_controller_wrappers(self):
+@@ -876,9 +833,6 @@
+ if self.auth_backend == "sqlalchemy":
+ from repoze.what.plugins.quickstart import setup_sql_auth
+ app = setup_sql_auth(app, skip_authentication=skip_authentication, **auth_args)
+- elif self.auth_backend == "ming":
+- from tgming import setup_ming_auth
+- app = setup_ming_auth(app, skip_authentication=skip_authentication, **auth_args)
+ else:
+ try:
+ pos = auth_args['authenticators'].index(('default', None))
+@@ -896,10 +850,6 @@
+ from tg.configuration.sqla.auth import create_default_authenticator
+ auth_args, sqlauth = create_default_authenticator(**auth_args)
+ authenticator = ('sqlauth', sqlauth)
+- elif self.auth_backend == "ming":
+- from tg.configuration.mongo.auth import create_default_authenticator
+- auth_args, mingauth = create_default_authenticator(**auth_args)
+- authenticator = ('mingauth', mingauth)
+ else:
+ authenticator = None
+
+@@ -1063,11 +1013,6 @@
+ from repoze.tm import TM
+ return TM(app, self.commit_veto)
+
+- def add_ming_middleware(self, app):
+- """Set up the ming middleware for the unit of work"""
+- import ming.orm.middleware
+- return ming.orm.middleware.MingMiddleware(app)
+-
+ def add_dbsession_remover_middleware(self, app):
+ """Set up middleware that cleans up the sqlalchemy session.
+
+@@ -1167,9 +1112,6 @@
+ self.DBSession = self.model.DBSession
+ app = self.add_dbsession_remover_middleware(app)
+
+- if self.use_ming:
+- app = self.add_ming_middleware(app)
+-
+ if config.get('make_body_seekable'):
+ app = maybe_make_body_seekable(app)
+
+diff -Naur TurboGears2-2.3.0dev.orig/tg/configuration/mongo/auth.py TurboGears2-2.3.0dev/tg/configuration/mongo/auth.py
+--- TurboGears2-2.3.0dev.orig/tg/configuration/mongo/auth.py 2013-04-03 14:09:04.113676607 -0400
++++ TurboGears2-2.3.0dev/tg/configuration/mongo/auth.py 1969-12-31 19:00:00.000000000 -0500
+@@ -1,6 +0,0 @@
+-# -*- coding: utf-8 -*-
+-from tgming.auth import MingAuthenticatorPlugin
+-
+-def create_default_authenticator(user_class, translations=None, **unused):
+- mingauth = MingAuthenticatorPlugin(user_class)
+- return unused, mingauth
+diff -Naur TurboGears2-2.3.0dev.orig/tg/configuration/mongo/__init__.py TurboGears2-2.3.0dev/tg/configuration/mongo/__init__.py
+--- TurboGears2-2.3.0dev.orig/tg/configuration/mongo/__init__.py 2013-04-03 14:09:04.113676607 -0400
++++ TurboGears2-2.3.0dev/tg/configuration/mongo/__init__.py 1969-12-31 19:00:00.000000000 -0500
+@@ -1 +0,0 @@
+-
+\ No newline at end of file
More information about the scm-commits
mailing list