示例#1
0
文件: state.py 项目: smurfix/MoaT
	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
示例#2
0
文件: state.py 项目: ZigmundRat/moat
 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
示例#3
0
文件: state.py 项目: smurfix/MoaT
	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)
示例#4
0
文件: state.py 项目: ZigmundRat/moat
    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)
示例#5
0
文件: state.py 项目: smurfix/MoaT
	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
示例#6
0
文件: state.py 项目: ZigmundRat/moat
    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
示例#7
0
##  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()