fix to api validation, and updates to service monitor to account for new database code.

This commit is contained in:
KeyserSosa
2009-01-28 15:01:56 -08:00
parent 1855d7034e
commit d169f779af
3 changed files with 14 additions and 7 deletions

View File

@@ -490,6 +490,7 @@ class ApiController(RedditController):
VModhash(),
thing = VByNameIfAuthor('id'))
def POST_del(self, thing):
if not thing: return
'''for deleting all sorts of things'''
thing._deleted = True
thing._commit()
@@ -986,6 +987,7 @@ class ApiController(RedditController):
VSrCanBan('id'),
thing = VByName('id'))
def POST_ban(self, thing):
if not thing: return
thing.moderator_banned = not c.user_is_admin
thing.banner = c.user.name
thing._commit()
@@ -997,12 +999,14 @@ class ApiController(RedditController):
thing = VByName('id'))
def POST_unban(self, thing):
# NB: change table updated by reporting
if not thing: return
unreport(thing, correct=False)
@noresponse(VModhash(),
VSrCanBan('id'),
thing = VByName('id'))
def POST_ignore(self, thing):
if not thing: return
# NB: change table updated by reporting
unreport(thing, correct=False)
@@ -1010,6 +1014,7 @@ class ApiController(RedditController):
VModhash(),
thing = VByName('id'))
def POST_save(self, thing):
if not thing: return
r = thing._save(c.user)
if g.write_query_queue:
queries.new_savehide(r)
@@ -1018,6 +1023,7 @@ class ApiController(RedditController):
VModhash(),
thing = VByName('id'))
def POST_unsave(self, thing):
if not thing: return
r = thing._unsave(c.user)
if g.write_query_queue and r:
queries.new_savehide(r)
@@ -1026,6 +1032,7 @@ class ApiController(RedditController):
VModhash(),
thing = VByName('id'))
def POST_hide(self, thing):
if not thing: return
r = thing._hide(c.user)
if g.write_query_queue:
queries.new_savehide(r)
@@ -1034,6 +1041,7 @@ class ApiController(RedditController):
VModhash(),
thing = VByName('id'))
def POST_unhide(self, thing):
if not thing: return
r = thing._unhide(c.user)
if g.write_query_queue and r:
queries.new_savehide(r)
@@ -1226,6 +1234,7 @@ class ApiController(RedditController):
@noresponse(VSponsor(),
thing = VByName('id'))
def POST_unpromote(self, thing):
if not thing: return
unpromote(thing)
@validatedForm(VSponsor(),

View File

@@ -184,14 +184,14 @@ class Globals(object):
return (x.strip() for x in v.split(delim))
def load_db_params(self, gc):
databases = self.to_iter(gc['databases'])
if not databases:
self.databases = tuple(self.to_iter(gc['databases']))
if not self.databases:
return
dbm = db_manager.db_manager()
db_params = ('name', 'db_host', 'db_user', 'db_pass',
'pool_size', 'max_overflow')
for db_name in databases:
for db_name in self.databases:
conf_params = self.to_iter(gc[db_name + '_db'])
params = dict(zip(db_params, conf_params))
dbm.engines[db_name] = db_manager.get_engine(**params)

View File

@@ -34,10 +34,8 @@ def is_db_machine(host):
Given a host name, checks the list of known DB machines to
determine if the host is one of them.
"""
ips = set(v for k,v in g._current_obj().__dict__.iteritems()
if k.endswith("db_host"))
for ip in ips:
for db in g.databases:
ip = list(g.to_iter(getattr(g, db + "_db")))[1]
name = socket.gethostbyaddr(ip)[0]
if (name == host or ("." in host and name.endswith("." + host)) or
name.startswith(host + ".")):