[web2py] Re: Bypass web2py for static maintenance page
I found the answer to my own question. So in case anyone else finds it useful: Instead of using the WSGIScriptAlias directive you can use WSGIScriptAliasMatch which allows for regular expressions. Then I used a negative lookahead to exclude any paths beginning with "maintenance": WSGIScriptAliasMatch "^/(?!maintenance).*$" /path/to/my/web2py/wsgihandler.py It works like a charm. Now when I activate maintenance mode apache serves the static html page in /var/www/html/maintenance. Otherwise, it redirects all other requests to the wsgi handler for web2py. On Monday, September 19, 2022 at 6:07:18 PM UTC-4 Ian W. Scott wrote: > I'm trying to set up a static maintenance page under apache that doesn't > depend on web2py. The problem is that the mod_wsgi scriptalias directive > seems to override the rewrite instructions to serve the static maintenance > page. > > My apache config includes this: > > ErrorDocument 503 /maintenance/maintenance.html > RewriteEngine on > RewriteCond /var/www/html/maintenance/maintenance.enabled -f > RewriteCond %{REQUEST_URI} !=/maintenance/maintenance.html > RewriteRule ^ - [R=503,L] > > This works fine as long as I disable the mod_wsgi scriptalias directive: > > WSGIScriptAlias / /path/to/my/web2py/wsgihandler.py > > Basically I need web2py to handle any urls from the base of my domain. > Except I want to bypass that alias for paths beginning "/maintenance". > > Any suggestions for how to configure this? > > Thanks, > > Ian > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2cdbff07-e7ba-4611-ab26-ab3bf096df04n%40googlegroups.com.
[web2py] Custom Login Decorator
*STATEMENT OF THE PROBLEM* I have an infinite loop problem that i don't know how to escape so i need help I have never used a decorator before I'm not even sure i fully understand how they work but i have used one & it's giving me a headache. I have registration form that's supposed to be protected by a one time code login page that i put inside a decorator trying to simulate *@auth.requires_login()*. The idea is that if the one time code is correct the user should access the registration form but *NEVER* if it's wrong and the user should never be able to bypass the security feature by directly typing the page address in the URL! But now I'm stuck in a loop with a page(one time code page) that keeps calling itself. How can I fix this to get what I want?? *ONE TIME CODE FORM* def subscribe(): key_exists = not db(db.regKeys.regKey == request.vars.regCode).isempty() if request.vars.regCode is None: message='' if key_exists: db(db.regKeys.regKey == request.vars.regCode).delete() redirect(URL('register_product')) if request.vars.regCode is not None and not key_exists: message="INCORRECT REG CODE" return locals() *DECORATOR CODE* def onetimecode(func): def wrapper(): redirect(URL('default', 'subscribe')) return wrapper *REGISTRATION FORM WITH THE DECORATOR* @onetimecodedef register_product(): timeout = auth.settings.expiration details=db(db.thirdParty).select() form=SQLFORM(db.black_market2) if form.process().accepted: response.flash=T('Successfully Registered') return locals() -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/11045f13-00c0-4fbf-9d7a-e39349df5057n%40googlegroups.com.