Search code examples
pythondjangodisqusgargoyle

Use Disqus' gargoyle for whole apps


Is there a way to use disqus opensource gargoyle project to switch off whole apps. For example, I have a management app where I allow users to change their accounts and delete them etc.

If i want to tweak around with those features I want to switch the whole app off, so that they cant use it anymore.

I know I can switch off the views seperately but is there a way that allow me to apply a switch to an app in general.

Reference: Gargoyle Docs

What can I do to solve this?


Solution

  • That doesn't seem to be how Gargoyle works. In the simplest sense, Gargoyle is just a set of conditions you add. You use decorators and such to test if a view or a piece of code is allowed to run based on whether it meets the specified conditions.

    I'm sure you understand that, but it fundamentally colors your question. Gargoyle does nothing until you evoke it by checking a condition's status. It's not actively running in the background doing it's own checking, so you can't tell it turn off an entire app on it's own.

    The only way I could see it working the way you want is to use gargoyle.is_active directly in your settings.py file:

    INSTALLED_APPS = [
      # always on apps
    ]
    
    from gargoyle import gargoyle
    if gargoyle.is_active('my_switch'):
        INSTALLED_APPS.append('my_conditional_app')
    

    However, I have no idea whether that would actually work in practice, and even if it does, whether or not it might wreck havoc in some other way.