コード例 #1
0
 def _response_body (self, resource, request, response) :
     debug    = getattr (resource.top, "DEBUG", False)
     req_data = request.req_data
     result   = {}
     self.errors = GTW.RST.Errors ()
     username, password = self._credentials_validation \
         (resource, request, debug = debug)
     if self.errors :
         from _TFL.formatted_repr import formatted_repr as formatted
         result ["errors"]    = self.errors
         response.status_code = 400
         resource.send_error_email \
             ( request
             , "RAT Authorization error"
             , None
             , "Errors:\n%s" % (formatted (self.errors), )
             )
     else :
         account = self.account
         cn      = resource.pid
         scope   = account.home_scope
         data    = account.name \
             if resource.use_name_for_cookie else str (account.pid)
         token   = GTW.RST.Signed_Token.REST_Auth \
             ( request, account = account, data = data)
         rat     = result [cn] = token.value
         kw      = dict \
             ( resource.cookie_kw
             , max_age = resource.session_ttl
             , secure  = request.is_secure
             )
         response.set_secure_cookie (cn, rat, ** kw)
     return result
コード例 #2
0
 def _register_submit_error_callback (self, resource, request, response, scope, fv, result) :
     from _TFL.formatted_repr import formatted_repr as formatted
     errors    = pyk.decoded \
         ("\n\n".join (formatted (e) for e in fv.errors))
     message = "\n\n-----------------\n\n".join \
         (( self._regatta_registration_formatted   (resource, scope, fv)
          , errors
          , self._regatta_registration_changed_msg (resource, scope, fv)
         ))
     self._send_registration_email \
         ( resource, request, response, scope, fv, result, message
         , "*** failed ***"
         )
コード例 #3
0
ファイル: SRM.py プロジェクト: JPilarr/tapyr
 def _register_submit_error_callback (self, resource, request, response, scope, fv, result) :
     from _TFL.formatted_repr import formatted_repr as formatted
     errors    = pyk.decoded \
         ("\n\n".join (formatted (e) for e in fv.errors))
     message = "\n\n-----------------\n\n".join \
         (( self._regatta_registration_formatted   (resource, scope, fv)
          , errors
          , self._regatta_registration_changed_msg (resource, scope, fv)
         ))
     self._send_registration_email \
         ( resource, request, response, scope, fv, result, message
         , "*** failed ***"
         )
コード例 #4
0
ファイル: HTTP_Method.py プロジェクト: Tapyr/tapyr
    def __call__(self, resource, request, response):
        if not self._skip_render(resource, request, response):
            response.renderer = self._get_renderer(resource, request, response)
            body = self._response_body(resource, request, response)
            if body is not None and response.renderer is not None:
                try:
                    response.renderer(request, response, body)
                except Exception as exc:
                    from _TFL.formatted_repr import formatted_repr as formatted
                    import traceback

                    tb = traceback.format_exc()
                    resource.send_error_email(request, exc, "\n\n".join((formatted(body), tb)))
                    raise
        return response
コード例 #5
0
ファイル: HTTP_Method.py プロジェクト: xiaochang91/tapyr
 def __call__(self, resource, request, response):
     if not self._skip_render(resource, request, response):
         response.renderer = self._get_renderer(resource, request, response)
         body = self._response_body(resource, request, response)
         if body is not None and response.renderer is not None:
             try:
                 response.renderer(request, response, body)
             except Exception as exc:
                 from _TFL.formatted_repr import formatted_repr as formatted
                 import traceback
                 tb = traceback.format_exc()
                 resource.send_error_email \
                     ( request, exc
                     , "\n\n".join ((formatted (body), tb))
                     )
                 raise
     return response
コード例 #6
0
ファイル: Test_Command.py プロジェクト: Tapyr/tapyr
    def create_rst(self, cmd, **kw):
        import _GTW._RST._MOM.Doc
        import _GTW._RST._MOM.Scope

        result = GTW.RST.Root(
            language="de",
            entries=[
                GTW.RST.MOM.Scope(name="v1", auth_required=self.v1_auth_required),
                GTW.RST.MOM.Doc.App_Type(name="Doc"),
                GTW.RST.Raiser(name="RAISE"),
            ],
            **kw
        )
        if self.v1_auth_required:
            ### `secure` and `httponly` break the test --> clear `cookie_kw`
            import _GTW._RST.RAT

            GTW.RST.RAT.cookie_kw = {}
            result.add_entries(GTW.RST.RAT(name="RAT"))
        if cmd.log_level:
            print(formatted(result.Table))
        return result
コード例 #7
0
 def create_rst (self, cmd, ** kw) :
     import _GTW._RST._MOM.Doc
     import _GTW._RST._MOM.Scope
     result = GTW.RST.Root \
         ( language          = "de"
         , entries           =
             [ GTW.RST.MOM.Scope
                 ( name          = "v1"
                 , auth_required = self.v1_auth_required
                 )
             , GTW.RST.MOM.Doc.App_Type (name = "Doc")
             , GTW.RST.Raiser           (name = "RAISE")
             ]
         , ** kw
         )
     if self.v1_auth_required :
         ### `secure` and `httponly` break the test --> clear `cookie_kw`
         import _GTW._RST.RAT
         GTW.RST.RAT.cookie_kw = {}
         result.add_entries (GTW.RST.RAT (name = "RAT"))
     if cmd.log_level :
         print (formatted (result.Table))
     return result