Did you spell this correctly: > return AntiCurlMiddlewarey(app)
There's an extra "y" there. Looks like the real function is named AntiCurlMiddleware without the y. On Aug 2, 2:53 pm, Kate <[email protected]> wrote: > How can I trap a certain user agent and send a 429 response. > > I have the following in my appengine_config.py and it always defaults to a > 200. > > (Note I do not intend to block all Windows user agent requests bit have the > code "sindex = string.find(ua,'Win',0)" there for testing only). > > from webob import Response > import os > > class AntiCurlMiddleware(object): > def __init__(self, app): > self.app = app > > def __call__(self, environ, start_response): > ua = os.environ.get('HTTP_USER_AGENT', "unknown") > sindex = string.find(ua,'Win',0) > > if sindex > 0: > resp = Response('Too many requests!') > resp.status_code =429 > return resp(environ, start_response) > else: > return self.app(environ, start_response) > > def webapp_add_wsgi_middleware(app): > return AntiCurlMiddlewarey(app) -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
