##// END OF EJS Templates
auth: use our own simpler hybrid property....
marcink -
r1961:4409087f default
parent child Browse files
Show More
@@ -28,9 +28,9 b' import logging'
28 import time
28 import time
29 import traceback
29 import traceback
30 import warnings
30 import warnings
31 import functools
31
32
32 from pyramid.threadlocal import get_current_registry
33 from pyramid.threadlocal import get_current_registry
33 from sqlalchemy.ext.hybrid import hybrid_property
34
34
35 from rhodecode.authentication.interface import IAuthnPluginRegistry
35 from rhodecode.authentication.interface import IAuthnPluginRegistry
36 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
36 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
@@ -52,6 +52,31 b" VCS_TYPE = 'vcs'"
52 HTTP_TYPE = 'http'
52 HTTP_TYPE = 'http'
53
53
54
54
55 class hybrid_property(object):
56 """
57 a property decorator that works both for instance and class
58 """
59 def __init__(self, fget, fset=None, fdel=None, expr=None):
60 self.fget = fget
61 self.fset = fset
62 self.fdel = fdel
63 self.expr = expr or fget
64 functools.update_wrapper(self, fget)
65
66 def __get__(self, instance, owner):
67 if instance is None:
68 return self.expr(owner)
69 else:
70 return self.fget(instance)
71
72 def __set__(self, instance, value):
73 self.fset(instance, value)
74
75 def __delete__(self, instance):
76 self.fdel(instance)
77
78
79
55 class LazyFormencode(object):
80 class LazyFormencode(object):
56 def __init__(self, formencode_obj, *args, **kwargs):
81 def __init__(self, formencode_obj, *args, **kwargs):
57 self.formencode_obj = formencode_obj
82 self.formencode_obj = formencode_obj
@@ -27,8 +27,8 b' rhodecode.tests.auth_external_test'
27 import logging
27 import logging
28 import traceback
28 import traceback
29
29
30 from rhodecode.authentication.base import RhodeCodeExternalAuthPlugin
30 from rhodecode.authentication.base import (
31 from sqlalchemy.ext.hybrid import hybrid_property
31 RhodeCodeExternalAuthPlugin, hybrid_property)
32 from rhodecode.model.db import User
32 from rhodecode.model.db import User
33 from rhodecode.lib.ext_json import formatted_json
33 from rhodecode.lib.ext_json import formatted_json
34
34
General Comments 0
You need to be logged in to leave comments. Login now