Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-11 Thread C J
Thank you Mike! I had forgotten "asbool()". It takes time locally to load my page but I finally allow specific route while having the maintenance mode activated. handler(request) takes time. I consider that my questions are answered and that my problem is solved. Thank you very much

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-09 Thread Mike Orr
Don't forget the 'asbool()'. Without it the 'in_maintenance' text setting value may be interpreted wrong. E.g., '0' or ' ' or 'false' would evaluate to True. On Sat, Jan 9, 2021 at 11:30 AM Mike Orr wrote: > > The includeme function takes care of all the tween registration for > you, so you just

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-09 Thread Mike Orr
The includeme function takes care of all the tween registration for you, so you just have to include the module using the "pyramid.includes" setting or such. You've got that working. Since you're enabling maintenance mode with a config setting, and you'll have to restart the application to change

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread C J
I try to understand why my "or not" have no effect: def maintenance_tween_factory(handler, registry): # Return a tween callable. # 'handler' is the next tween or the WSGI application. # Deployment settings are in 'registry.settings'. def maintenance_tween(request):

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread C J
Thank you! I think I finally got it. Now I would like to allow only 2 routes: - one is my "maintenance" because I want to use a jinja template instead of returning the HTTPException - one is "dbmigration" because I still need to call my Cornice API For the moment the maintenance mode

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread C J
I get 'No module named 'maintenance_tween'. Should I separate the two functions in 2 different files, both of them being in the same module? Le vendredi 8 janvier 2021 à 13:04:57 UTC+1, tfl...@gmail.com a écrit : > Hi Cedric, > You just have to include your package from Pyramid main

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread Thierry Florac
Hi Cedric, You just have to include your package from Pyramid main configuration file, using the "includes" section... The "includeme" function will then be called automatically to register your tween! Thierry -- https://www.ulthar.net -- http://pyams.readthedocs.io Le ven. 8 janv. 2021 à

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread C J
I fixed my code by returning the function inside. But I still need to understand where to call theses functions to set everything up. def maintenance_tween_factory(handler, registry): # Return a tween callable. # 'handler' is the next tween or the WSGI application. # Deployment settings are in

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-08 Thread C J
To everybody: thanks a lot for your answers. Sorry for the delay: I am living in France. Bay the way I am still interested in the Pyramid CMS solution steps. Mike, I have created a file named maintenance.py in my utils module. It contains: import pyramid def includeme(config): # Calculate

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread Mike Orr
I forgot the last line. The end of 'my_tween_factory' needs to 'return my_tween'. On Thu, Jan 7, 2021 at 7:05 PM Mike Orr wrote: > I have a request-logging tween in only a page of code. It's > straightforward to write from the documentation. > >

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread Mike Orr
I have a request-logging tween in only a page of code. It's straightforward to write from the documentation. https://pyramid.readthedocs.io/en/latest/narr/hooks.html#registering-tweens I adapted the code for your use case (untested). Your module would have something like this: # Module

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread C J
That's really interesting Thierry. Can you please show me how to do? I have tried to use tweens. I tried many things starting with *pyramid.tweens = pyramid_maintenance.tween_maintenance *and modifying the *__init__.py* file, however, I do not understand what they are and how to use them despite

[pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread 'Jonathan Vanasco' via pylons-discuss
i should add, the pattern for doing this in nginx is often called a flag or semaphore i found this article that goes through a how-to https://blog.devcloud.hosting/configuring-nginx-for-quickly-switching-to-maintenance-mode-e4136cf497f3 basically, you just touch/remove a specific file to

Re: [pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread Thierry Florac
I've built a custom Pyramid tween to handle this and redirect requests while application is up! It can handle redirects (based on regular expressions) before or after the request is handled by Pyramid application, to be able to set the site in "maintenance mode", or to handle custom redirects in

[pylons-discuss] Re: Pyramid maintenance mode

2021-01-07 Thread 'Jonathan Vanasco' via pylons-discuss
I typically handle this on nginx which sites in front of Pyramid. if you wanted to do everything in python, you could probably use WSGI middleware to route to a separate maintenance application or html file. On Thursday, January 7, 2021 at 10:09:34 AM UTC-5 C J wrote: > Hi everybody, > > I am