コード例 #1
0
ファイル: __init__.py プロジェクト: dumpvn/notify
def load_organisation_before_request():
    if '/static/' in request.url:
        _request_ctx_stack.top.organisation = None
        return
    if _request_ctx_stack.top is not None:
        _request_ctx_stack.top.organisation = None

        if request.view_args:
            org_id = request.view_args.get('org_id')

            if org_id:
                try:
                    _request_ctx_stack.top.organisation = organisations_client.get_organisation(org_id)
                except HTTPError as exc:
                    # if org id isn't real, then 404 rather than 500ing later because we expect org to be set
                    if exc.status_code == 404:
                        abort(404)
                    else:
                        raise
コード例 #2
0
 def from_id(cls, org_id):
     return cls(organisations_client.get_organisation(org_id))
コード例 #3
0
 def from_id(cls, org_id):
     if not org_id:
         return cls({})
     return cls(organisations_client.get_organisation(org_id))