|
a/Allura/allura/model/session.py |
|
b/Allura/allura/model/session.py |
|
... |
|
... |
2 |
from itertools import chain
|
2 |
from itertools import chain
|
3 |
|
3 |
|
4 |
from pylons import c
|
4 |
from pylons import c
|
5 |
|
5 |
|
6 |
from ming import Session
|
6 |
from ming import Session
|
|
|
7 |
from ming.datastore import ShardedDataStore
|
7 |
from ming.orm.base import state, session
|
8 |
from ming.orm.base import state, session
|
8 |
from ming.orm.ormsession import ThreadLocalORMSession, SessionExtension
|
9 |
from ming.orm.ormsession import ThreadLocalORMSession, SessionExtension
|
9 |
|
10 |
|
10 |
from allura.lib import search
|
11 |
from allura.lib import search
|
11 |
from allura.lib.custom_middleware import environ
|
12 |
from allura.lib.custom_middleware import environ
|
|
... |
|
... |
29 |
p = getattr(c, 'project', None)
|
30 |
p = getattr(c, 'project', None)
|
30 |
except TypeError:
|
31 |
except TypeError:
|
31 |
# running without MagicalC, inside a request (likely EasyWidgets)
|
32 |
# running without MagicalC, inside a request (likely EasyWidgets)
|
32 |
return None
|
33 |
return None
|
33 |
if p is None: return None
|
34 |
if p is None: return None
|
|
|
35 |
if p.database_uri:
|
|
|
36 |
return ShardedDataStore.get(p.database_uri).db
|
34 |
return getattr(self.main_session.bind.conn, p.database)
|
37 |
return getattr(self.main_session.bind.conn, p.database)
|
35 |
except (KeyError, AttributeError), ex:
|
38 |
except (KeyError, AttributeError), ex:
|
36 |
return None
|
39 |
return None
|
37 |
|
40 |
|
38 |
def _impl(self, cls):
|
41 |
def _impl(self, cls):
|