Example #1
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals, division

from weiyu.db.mapper import mapper_hub
from weiyu.db.mapper.base import Document

from ..utils.stringop import escape_lucene
from .passwd import Password

USER_STRUCT_ID = 'luohua.user'
mapper_hub.register_struct(USER_STRUCT_ID)


class User(Document):
    struct_id = USER_STRUCT_ID

    def __init__(self, data):
        # 使用解码后的形式作为数据
        # 这里调用 dict 的构造函数在 CPython 下有 overhead, 不过在 profile
        # 之前还是算了吧, 不太值得优化
        # 虽说留着没什么问题... 但看上去很不优雅. 那么换用更批量一点的形式
        # super(User, self).__init__(**self.decode(data))
        self.update(self.decode(data))

    def chkpasswd(self, psw):
        '''进行密码验证。'''
Example #2
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals, division

from weiyu.db.mapper import mapper_hub
from weiyu.db.mapper.base import Document

from ..utils.stringop import escape_lucene
from .passwd import Password

USER_STRUCT_ID = 'luohua.user'
mapper_hub.register_struct(USER_STRUCT_ID)


class User(Document):
    struct_id = USER_STRUCT_ID

    def __init__(self, data):
        # 使用解码后的形式作为数据
        # 这里调用 dict 的构造函数在 CPython 下有 overhead, 不过在 profile
        # 之前还是算了吧, 不太值得优化
        # 虽说留着没什么问题... 但看上去很不优雅. 那么换用更批量一点的形式
        # super(User, self).__init__(**self.decode(data))
        self.update(self.decode(data))

    def chkpasswd(self, psw):
        '''进行密码验证。'''
Example #3
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals, division

from weiyu.db.mapper import mapper_hub
from weiyu.db.mapper.base import Document

from ..utils.stringop import escape_lucene

ROLE_STRUCT_ID = 'luohua.role'
mapper_hub.register_struct(ROLE_STRUCT_ID)


class Role(Document):
    struct_id = ROLE_STRUCT_ID

    def __init__(self, data):
        # 使用解码后的形式作为数据
        # 这里调用 dict 的构造函数在 CPython 下有 overhead, 不过在 profile
        # 之前还是算了吧, 不太值得优化
        # 虽说留着没什么问题... 但看上去很不优雅. 那么换用更批量一点的形式
        # super(User, self).__init__(**self.decode(data))
        self.update(self.decode(data))

    def __contains__(self, key):
        return self.hascap(key)
Example #4
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals, division

from weiyu.db.mapper import mapper_hub
from weiyu.db.mapper.base import Document

from ..utils.stringop import escape_lucene

ROLE_STRUCT_ID = 'luohua.role'
mapper_hub.register_struct(ROLE_STRUCT_ID)


class Role(Document):
    struct_id = ROLE_STRUCT_ID

    def __init__(self, data):
        # 使用解码后的形式作为数据
        # 这里调用 dict 的构造函数在 CPython 下有 overhead, 不过在 profile
        # 之前还是算了吧, 不太值得优化
        # 虽说留着没什么问题... 但看上去很不优雅. 那么换用更批量一点的形式
        # super(User, self).__init__(**self.decode(data))
        self.update(self.decode(data))

    def __contains__(self, key):
        return self.hascap(key)