def value(self): global Db if Db is None: from moat.database import DbStore Db = DbStore(category="state") try: return Db.get(self.name) except KeyError: return None
def run(self,ctx,**k): event = self.params(ctx) if not len(event): raise SyntaxError(u"Usage: forget state ‹name…›") name = SName(event) global Db if Db is None: from moat.database import DbStore Db = DbStore(category="state") Db.delete(name)
def run(self, ctx, **k): event = self.params(ctx) if not len(event): raise SyntaxError(u"Usage: forget state ‹name…›") name = SName(event) global Db if Db is None: from moat.database import DbStore Db = DbStore(category="state") Db.delete(name)
def check(self,*args): if len(args) < 1: raise SyntaxError(u"Usage: if saved state ‹name…›") global Db if Db is None: from moat.database import DbStore Db = DbStore(category="state") try: Db.get(Name(*args)) except KeyError: return False else: return True
def check(self, *args): if len(args) < 1: raise SyntaxError(u"Usage: if saved state ‹name…›") global Db if Db is None: from moat.database import DbStore Db = DbStore(category="state") try: Db.get(Name(*args)) except KeyError: return False else: return True
## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License (included; see the file LICENSE) ## for more details. ## ## This header is auto-generated and may self-destruct at any time, ## courtesy of "make update". The original is in ‘scripts/_boilerplate.py’. ## Thus, do not remove the next line, or insert any blank lines above. ##BP from moat.database import DbStore from moat.base import Name from moat.reactor import shut_down,mainloop s = DbStore(Name("Foo","bar")) def main(): s.clear() s.set("one",4) s.set(("two","three"),(4,5,6)) def getter(a,b): _ = s.get(a) assert _ == b, "Check CallBack %r %r %r" % (_,a,b) getter("one",4) getter(("two","three"),(4,5,6)) s.set("one",2) getter("one",2) shut_down()