0

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?

sth
  • 222,467
  • 53
  • 283
  • 367
cwoebker
  • 3,158
  • 5
  • 27
  • 43

1 Answers1

2

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.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • yeah i understood that, your solution seems right theoretically, but yeah this approach might make a wreck of my project^^ i might just declare it on every function, isn't as much work as i expected anyhow, but thanks a lot – cwoebker Jul 26 '11 at 18:28
  • Since settings.py is processed at the startup of the wsgi process, this would be limited to switching on/off at wsgi start. There is a log of magic going on for settings.py, messing with it at runtime can be dangerous. – Paulo Scardine Oct 31 '12 at 15:10