예제 #1
0
파일: site.py 프로젝트: CMGS/ymir
    def on_put(self, req, resp):
        params = json.load(req.stream)
        if not params or not params.get('name'):
            raise falcon.HTTPBadRequest(config.HTTP_400, 'invalid params')

        token = uuid.uuid4().hex
        name = params.get('name')

        try:
            site = create(token, name)
        except Exception:
            logger.exception('create')
            raise falcon.HTTPInternalServerError(config.HTTP_500, 'create site failed')

        resp.status = falcon.HTTP_201
        resp.stream = ijson.dump({'token': site.token})
예제 #2
0
파일: test.py 프로젝트: CMGS/ymir
def setup():
    import tests
    import config
    for k in dir(config):
        value = getattr(tests, k, None)
        if not value:
            continue
        setattr(config, k, value)

    from models.site import Site, Block
    from query.site import create
    Site.create_table(fail_silently=True)
    Block.create_table(fail_silently=True)
    global site
    from tests.base import TEST_TOKEN
    site = create(TEST_TOKEN, 'test')