Greetings Pyloneers,
I'm implementing a 2-level read only mode in my Pylons
app. First
level is global and prevent any updates: that would be
turned on while
performing major software updates, DB sync, raid-5 rebuild,
or who
knows what. Second level is for soft-ban: a banned IP range
is
prevented from posting updates but it still can access the
content.
I put all the cute warnings at the right places and do the
right
checks but I know I'll forget a place or two so I want to
put my
Alchemy session in read-only mode. I'm running Alchemy 0.3;
here is
how I do, in lib/base.py:
def abort_ro():
raise Exception("Write request while in
read-only mode")
class BaseController(WSGIController):
def __call__(self, environ, start_response):
# Insert any code to be run per request here.
The Routes match
# is under environ['pylons.routes_dict'] should
you want to check
# the action or route vars here
model.ctx.current = make_session()
if asbool(config["site_readonly"]):
model.ctx.current.flush = abort_ro
It works but I'm sure there is a better way to do it. Any
advice on
that?
--
Yannick Gingras
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discuss googlegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---
|