auth: use our own simpler hybrid property.
- we shouldn't relly on sqlalchemy internal method, it has a different purpose.
This commit is contained in:
parent
c17e166f5f
commit
93908a0f84
2 changed files with 28 additions and 3 deletions
|
|
@ -28,9 +28,9 @@ import logging
|
|||
import time
|
||||
import traceback
|
||||
import warnings
|
||||
import functools
|
||||
|
||||
from pyramid.threadlocal import get_current_registry
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
|
||||
from rhodecode.authentication.interface import IAuthnPluginRegistry
|
||||
from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
|
||||
|
|
@ -52,6 +52,31 @@ VCS_TYPE = 'vcs'
|
|||
HTTP_TYPE = 'http'
|
||||
|
||||
|
||||
class hybrid_property(object):
|
||||
"""
|
||||
a property decorator that works both for instance and class
|
||||
"""
|
||||
def __init__(self, fget, fset=None, fdel=None, expr=None):
|
||||
self.fget = fget
|
||||
self.fset = fset
|
||||
self.fdel = fdel
|
||||
self.expr = expr or fget
|
||||
functools.update_wrapper(self, fget)
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
if instance is None:
|
||||
return self.expr(owner)
|
||||
else:
|
||||
return self.fget(instance)
|
||||
|
||||
def __set__(self, instance, value):
|
||||
self.fset(instance, value)
|
||||
|
||||
def __delete__(self, instance):
|
||||
self.fdel(instance)
|
||||
|
||||
|
||||
|
||||
class LazyFormencode(object):
|
||||
def __init__(self, formencode_obj, *args, **kwargs):
|
||||
self.formencode_obj = formencode_obj
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ rhodecode.tests.auth_external_test
|
|||
import logging
|
||||
import traceback
|
||||
|
||||
from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from rhodecode.authentication.base import (
|
||||
RhodeCodeExternalAuthPlugin, hybrid_property)
|
||||
from rhodecode.model.db import User
|
||||
from rhodecode.lib.ext_json import formatted_json
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue