Rearrange some imports to ensure rattail.db.model
comes last
this is necessary for Continuum versioning
This commit is contained in:
parent
db0eaf8eb0
commit
7340ef1f9b
|
@ -34,8 +34,7 @@ import sqlalchemy as sa
|
|||
import rattail.db
|
||||
from rattail.config import make_config
|
||||
from rattail.exceptions import ConfigurationError
|
||||
from rattail.db.util import get_engines
|
||||
from rattail.db.continuum import configure_versioning
|
||||
from rattail.db.config import get_engines, configure_versioning
|
||||
from rattail.db.types import GPCType
|
||||
|
||||
import formalchemy as fa
|
||||
|
@ -44,8 +43,6 @@ from pyramid.authentication import SessionAuthenticationPolicy
|
|||
|
||||
import tailbone.db
|
||||
from tailbone.auth import TailboneAuthorizationPolicy
|
||||
from tailbone.forms import renderers
|
||||
from tailbone.forms.alchemy import TemplateEngine
|
||||
|
||||
|
||||
def make_rattail_config(settings):
|
||||
|
@ -125,6 +122,9 @@ def make_pyramid_config(settings):
|
|||
"""
|
||||
Make a Pyramid config object from the given settings.
|
||||
"""
|
||||
from tailbone.forms.alchemy import TemplateEngine
|
||||
from tailbone.forms import renderers
|
||||
|
||||
config = Configurator(settings=settings, root_factory=Root)
|
||||
|
||||
# Configure user authentication / authorization.
|
||||
|
|
|
@ -28,8 +28,6 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
import logging
|
||||
|
||||
from rattail.db import model
|
||||
from rattail.db.auth import has_permission, authenticated_role
|
||||
from rattail.util import prettify, NOTSET
|
||||
|
||||
from zope.interface import implementer
|
||||
|
@ -70,6 +68,8 @@ def session_timeout_for_user(user):
|
|||
"""
|
||||
Returns the "max" session timeout for the user, according to roles
|
||||
"""
|
||||
from rattail.db.auth import authenticated_role
|
||||
|
||||
roles = user.roles + [authenticated_role(Session())]
|
||||
timeouts = [role.session_timeout for role in roles
|
||||
if role.session_timeout is not None]
|
||||
|
@ -88,6 +88,9 @@ def set_session_timeout(request, timeout):
|
|||
class TailboneAuthorizationPolicy(object):
|
||||
|
||||
def permits(self, context, principals, permission):
|
||||
from rattail.db import model
|
||||
from rattail.db.auth import has_permission
|
||||
|
||||
for userid in principals:
|
||||
if userid not in (Everyone, Authenticated):
|
||||
if context.request.user and context.request.user.uuid == userid:
|
||||
|
|
|
@ -28,8 +28,6 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
import formalchemy as fa
|
||||
|
||||
from rattail.db import model
|
||||
|
||||
|
||||
def AssociationProxyField(name, **kwargs):
|
||||
"""
|
||||
|
@ -45,6 +43,7 @@ def AssociationProxyField(name, **kwargs):
|
|||
self.renderer.deserialize())
|
||||
|
||||
def value(model):
|
||||
from rattail.db import model
|
||||
return getattr(model, name, None)
|
||||
|
||||
kwargs.setdefault('value', value)
|
||||
|
|
Loading…
Reference in a new issue