コード例 #1
0
ファイル: hashcache.py プロジェクト: sabaini/emkuu
 def onCreate(self, msg):
     print msg
     if self.errparams(msg): return
     to = urischemes.parse_uri(msg['to'])
     tok = str(uuid.uuid4())
     if msg.attributes.get('location'):
         key = str(urischemes.parse_uri(msg['location']).path.split('/')[-1])
     else:
         key = tok
     if self.cache.has_key(key): # won't create existing entry
         e = messageutils.InfoElement(
             409, fro=MYURL, to=msg['fro'], corrid=msg['corrid'])
         self.xmlstream.send(e)
         return
     self.posttokens[tok] = msg['fro']
     e = messageutils.InfoElement(
         201, fro=MYURL, to=msg['fro'], corrid=msg['corrid'])
     e['location'] = MYURL + '/' + key
     e['posttoken'] = tok
     self.xmlstream.send(e)
     print "sent %s" % e.toXml()
コード例 #2
0
ファイル: hashcache.py プロジェクト: sabaini/emkuu
    def onDelete(self, msg):
        print msg
        if self.errparams(msg): return
        if not self.has_key(msg): # xxx ???
            self.xmlstream.send(self.my404(msg['fro'], msg['corrid']))
            return
        to = urischemes.parse_uri(msg['to'])
        key = str(to.path.split('/')[-1])

        del self.cache[key]
        self.cache.sync()

        e = messageutils.InfoElement(
            204, fro=(MYURL + '/' + key), to=msg['fro'], corrid=msg['corrid'])
        self.xmlstream.send(e)
        print "sent %s" % e.toXml()
コード例 #3
0
ファイル: hashcache.py プロジェクト: sabaini/emkuu
 def onPost(self, msg):
     print msg # xxx statt location to nehmen!
     if self.errparams(msg, rqheaders=['location', 'posttoken']):
         return
     tok = self.posttokens.get(msg['posttoken'])
     if not tok or tok!=msg['fro']:
         self.xmlstream.send(self.my404(msg['fro'], msg['corrid']))
         return
     loc = urischemes.parse_uri(msg['location'])
     key = str(loc.path.split('/')[-1])
     self.cache[key] = str(msg)
     self.cache.sync()
     e = messageutils.InfoElement(
         204, fro=(MYURL + '/' + key), to=msg['fro'], corrid=msg['corrid'])
     self.xmlstream.send(e)
     print "sent %s" % e.toXml()
コード例 #4
0
ファイル: hashcache.py プロジェクト: sabaini/emkuu
 def onPut(self, msg):
     print msg
     if self.errparams(msg): return
     if not self.has_key(msg):
         self.xmlstream.send(self.my404(msg['fro'], msg['corrid']))
         return
     to = urischemes.parse_uri(msg['to'])
     key = str(to.path.split('/')[-1])
     newval = str(msg) # str(Element) retrieves 1st text node
     self.cache[key] = newval
     self.cache.sync()
     e = messageutils.StateElement(fro=msg['to'], to=msg['fro'],
         corrid=msg['corrid'])
     e['status' ] = 201
     self.xmlstream.send(e)
     print "sent %s" % e.toXml()
コード例 #5
0
ファイル: hashcache.py プロジェクト: sabaini/emkuu
 def getpath(self, uri):
     s = urischemes.parse_uri(uri).path
     l = s.split('/')
     l2 = filter(lambda e: e, l)
     return l2