def edit(self, uid, email, real_name, password, newpass1, newpass2, status, role='user'):
        real_name, newpass1, newpass2 = real_name.strip(), newpass1.strip(), newpass2.strip()

        uid = int(uid)
        user = Backend('user').find(uid)
        if not user:
            raise exc.HTTPNotFound('user not found')

        me = ctx.request.user
        if me.uid == user.uid:
            if re.match(r'[A-Za-z0-9@#$%^&+=]{4,16}', newpass1):
                if password and newpass1 and newpass1 == newpass2:
                    user.password = newpass1
            elif newpass1:
                return {'status' : 'error', 'msg' : 'password: %s must be the [A-Za-z0-9_]{4,16} pattern' %(newpass1)}

            if len(email) > 7 and re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email):
                user_ = Backend('user').find_by_email(email)
                if user_ and user_.uid != user.uid:
                    return {'status' : 'error', 'msg' : 'email:%s is used' %(email)}
                else:
                    user.email = email


        if me.uid == 1 and user.uid != 1:
            if role in (ADMIN, USER):
                user.role = role
            if user.status != status and status in USER_STATUSES:
                user.status = status

        if re.match(r'^[A-Za-z0-9_ ]{4,16}$', real_name):
            if user.real_name != real_name:
                user.real_name = real_name

        Backend('user').save(user)
        return  {'status' : 'info', 'msg' : 'updated'}