示例#1
0
 def __init__(self, name, path='.'):
     self.name = name
     config_path = locate_config('dz.conf', path)
     if not config_path:
         raise Exception('dz.conf missing')
     self.config = Config(config_path)
示例#2
0
 def __init__(self, name, path='.'):
     self.name = name
     self.config = Config(locate_config('dz.conf', path))
示例#3
0
def get_db():
    """ return a configured db object """
    config = locate_config('services.ini')
    return connect_db(config=config)
示例#4
0
 def __init__(self, name, path='.'):
     self.name = name
     self.config = Config(locate_config('dz.conf', path))
示例#5
0
def use(dbname):
    global _db
    return _db.use(dbname)

def store(kind, db=None):
    if db == None:
        db = _db
    if type(kind) == str:
        s = zoom.EntityStore(db)
        s.kind = kind
    else:
        s = zoom.EntityStore(db, kind)
    return s

_config = locate_config('services.ini')
if _config:
    _db = connect_db(config=_config)

# State
# ==================================================================================
class ServiceState(zoom.Entity): pass

def poke(name, value=None):
    s = store(ServiceState, _db)
    if value==None:
        rec = s.first(name=name)
        if rec: s.delete(rec)
    else:
        r = s.first(name=name)
        if r: