def on_delete(self, req, resp):
        """
        DEVELOPMENT ONLY!

        Delete the account, and all the files belong to this account
        """
        logging.debug('in account delete')
        resp_dict = {}

        try:
            username = req.get_header('username') or ''
            password = req.get_header('password') or ''
            # email = req.get_header('email') or 'email'
            # params = req.get_param_as_list()
            # logging.debug('params:%s'%params)
            logging.debug('username:%s, password:%s' %
                (username, password))
        except:
            raise falcon.HTTPBadRequest('bad req',
                'when read from req, please check if the req is correct.')

        try:
            # user = AccountModel.get(AccountModel.username==username,
            #                             AccountModel.password==password)
            user = AccountModel.auth(username, password)
            logging.debug('delete after auth user')

            conn = swiftclient.client.Connection(self.conf.auth_url,
                            user.keystone_tenant+':'+user.keystone_username,
                                  user.password,
                                  auth_version=self.conf.auth_version)
            # for container in self.conf.services:
            #     conn.delete_container(username+'_'+container)
            logging.debug('delete after con swift user')

            keystonewrap.delete_user(user.keystone_tenant,
                    user.keystone_username,
                    user.keystone_password)
            logging.debug('after delete keytone user')
            q = AccountModel.delete().where(AccountModel.username==username,
                    AccountModel.password==password)
            q.execute()
            resp_dict['info'] = 'user:%s deleted successfully' % username
            resp_dict['username'] = username
            resp.status = falcon.HTTP_200

        except:
            logging.debug('in delete user Exception')
            resp_dict['info'] = 'delete user:%s not successfully' % username
            resp.status = falcon.HTTP_400
        resp.body = json.dumps(resp_dict, encoding='utf-8',
            sort_keys=True, indent=4)
    def on_put(self, req, resp):
        """
        :param req.header.username: the username
        :param req.header.password: password
        :param req.header.email: email

        :returns: a json contains info of the operation, if the register is
            success or failed
        """
        logging.debug('in account put')
        resp_dict = {}

        try:
            username = req.get_header('username') or ''
            password = req.get_header('password') or ''
            email = req.get_header('email') or 'email'
            # params = req.get_param_as_list()
            # logging.debug('params:%s'%params)
            logging.debug('username:%s, password:%s, email:%s' %
                (username, password, email))
        except:
            raise falcon.HTTPBadRequest('bad req',
                'when read from req, please check if the req is correct.')

        try:
            logging.debug('in account put create')

            with database.atomic():
                # AccountModel.create(username=username,
                #     password=password,
                #     email=email,
                #     join_date=str(datetime.datetime.now())+' GMT+8',
                #     account_level=0,
                #     swift_tenant='test',
                #     swift_username=username,
                #     swift_password=password)
                new_user = AccountModel.create(username=username,
                    password=password,
                    email=email,
                    join_date=str(datetime.datetime.now())+' GMT+8',
                    account_level=0,
                    keystone_tenant=self.conf.account,
                    keystone_username=username,
                    keystone_password=password,
                    disk_container=username+'_'+self.conf.disk_container,
                    keystone_info='')
                logging.debug('in account put create database.atomic')

            # conn = swiftclient.client.Connection(self.conf.auth_url,
            #                       self.conf.account_username,
            #                       self.conf.password,
            #                       auth_version=self.conf.auth_version or 1)
            keystone_info = swiftwrap.create_user(new_user.keystone_tenant,
                new_user.keystone_username,
                new_user.keystone_password,
                new_user.account_level)
            logging.debug('keystone_info:%s' % keystone_info)
            q = AccountModel.update(keystone_info=keystone_info).where(
                AccountModel.username == username,
                AccountModel.password == password)
            q.execute()
            resp_dict['info'] = 'successfully create user:%s' % username
            resp_dict['username'] = username
            resp.status = falcon.HTTP_201
        except KeystoneUserCreateException:
            logging.error('in restapi KeystoneUserCreateException!')
            q = AccountModel.delete().where(AccountModel.username==username,
                    AccountModel.password==password)
            q.execute()
            resp_dict['info'] = 'create user failed, did not create user:%s' % username
            resp.status = falcon.HTTP_500
            resp.body = json.dumps(resp_dict, encoding='utf-8')
        except peewee.IntegrityError:
            logging.warning('in account put create except')

            # `username` is a unique column, so this username already exists,
            # making it safe to call .get().
            old_user = AccountModel.get(AccountModel.username == username)
            logging.warning('user exists...')
            resp_dict['info'] = 'user exists, did not create user:%s' % username
            resp.status = falcon.HTTP_409
            try:
                change_user = AccountModel.get(AccountModel.username==username,
                                AccountModel.password==password)
            except:
                logging.debug('change user data failed...')
        except:
            logging.error('restapi_keystone put account Exception!')
            q = AccountModel.delete().where(AccountModel.username==username,
                    AccountModel.password==password)
            q.execute()
            resp_dict['info'] = 'create user failed, did not create user:%s' % username
            resp.status = falcon.HTTP_400
            resp.body = json.dumps(resp_dict, encoding='utf-8')
        resp.body = json.dumps(resp_dict, encoding='utf-8')