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):
        #print(request)
        is_maintenance_mode = registry.settings.get("in_maintenance")
        if is_maintenance_mode == "True":
            print(request.url)
            print("maintenance" in request.url) # True but still affected 
by the maintenance mode
            url = request.route_url('maintenance')
            if \
            not "/api/dbmigration" in request.url \
            or not "maintenance" in request.url:
                return HTTPServiceUnavailable(
                    "Please note that we will be performing important 
server maintenance in a few minutes, during which time the server will be 
unavailable. If you are in the middle of something important, please save 
your work or hold off on any critical actions until we are finished."
                     )
                #return HTTPServiceUnavailable(location=url)

        # # Could limit it to certain request.path's.
        # if not ("/api/dbmigration" in request.url and is_maintenance_mode 
== "True") \
        #         or not ("maintenance" in request.url and 
is_maintenance_mode == "True"):
        #     # Return an error response, bypassing the application.
        #     return HTTPServiceUnavailable(
        #             "Please note that we will be performing important 
server maintenance in a few minutes, during which time the server will be 
unavailable. If you are in the middle of something important, please save 
your work or hold off on any critical actions until we are finished."
        #         )
            else:
                # Call next tween/application and return its response 
unchanged.
                return handler(request)
        else:
            # Call next tween/application and return its response unchanged.
            return handler(request)
    return maintenance_tween

>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/3ea70938-5f98-4a6b-97ba-25dea5edc50dn%40googlegroups.com.

Reply via email to