cubicweb/server/utils.py
changeset 11129 97095348b3ee
parent 11091 29aebc1edd29
parent 11057 0b59724cb3f2
child 11767 432f87a63057
equal deleted inserted replaced
11128:9b4de34ad394 11129:97095348b3ee
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    28 from six import PY2, text_type
    28 from six import PY2, text_type
    29 from six.moves import input
    29 from six.moves import input
    30 
    30 
    31 from passlib.utils import handlers as uh, to_hash_str
    31 from passlib.utils import handlers as uh, to_hash_str
    32 from passlib.context import CryptContext
    32 from passlib.context import CryptContext
       
    33 
       
    34 from logilab.common.deprecation import deprecated
    33 
    35 
    34 from cubicweb.md5crypt import crypt as md5crypt
    36 from cubicweb.md5crypt import crypt as md5crypt
    35 
    37 
    36 
    38 
    37 class CustomMD5Crypt(uh.HasSalt, uh.GenericHandler):
    39 class CustomMD5Crypt(uh.HasSalt, uh.GenericHandler):
    74     except ValueError: # e.g. couldn't identify hash
    76     except ValueError: # e.g. couldn't identify hash
    75         pass
    77         pass
    76     # wrong password
    78     # wrong password
    77     return b''
    79     return b''
    78 
    80 
    79 
    81 @deprecated('[3.22] no more necessary, directly get eschema.eid')
    80 def eschema_eid(cnx, eschema):
    82 def eschema_eid(cnx, eschema):
    81     """get eid of the CWEType entity for the given yams type. You should use
    83     """get eid of the CWEType entity for the given yams type.
    82     this because when schema has been loaded from the file-system, not from the
    84 
    83     database, (e.g. during tests), eschema.eid is not set.
    85     This used to be necessary because when the schema has been loaded from the
       
    86     file-system, not from the database, (e.g. during tests), eschema.eid was
       
    87     not set.
    84     """
    88     """
    85     if eschema.eid is None:
       
    86         eschema.eid = cnx.execute(
       
    87             'Any X WHERE X is CWEType, X name %(name)s',
       
    88             {'name': text_type(eschema)})[0][0]
       
    89     return eschema.eid
    89     return eschema.eid
    90 
    90 
    91 
    91 
    92 DEFAULT_MSG = 'we need a manager connection on the repository \
    92 DEFAULT_MSG = 'we need a manager connection on the repository \
    93 (the server doesn\'t have to run, even should better not)'
    93 (the server doesn\'t have to run, even should better not)'