Changeset 2262:458867491ec4
- Timestamp:
- 08/27/08 01:48:08 (3 months ago)
- Author:
- dunker@…
- Branch:
- default
- Message:
-
add gozernet/infoitem/+searchdescr to the cloud
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r2259
|
r2262
|
|
| 38 | 38 | return "name=%s url=<%s> seen=%s" % (self.name, self.url, self.regtime) |
| 39 | 39 | |
| | 40 | def doget(self, mount, cb, *args, **kwargs): |
| | 41 | self.client = Client(self.url + mount, self.name).addcb(cb) |
| | 42 | self.client.get() |
| | 43 | |
| | 44 | def dopost(self, mount, cb, *args, **kwargs): |
| | 45 | self.client = Client(self.url + mount, self.name).addcb(cb) |
| | 46 | self.client.post(**kwargs) |
| | 47 | |
| 40 | 48 | def query(self, what, cb): |
| 41 | 49 | if what.startswith('/'): |
| … |
… |
|
| 56 | 64 | self.name).addcb(cb) |
| 57 | 65 | self.client.get() |
| | 66 | |
| | 67 | def infoitemsearchdescr(self, item, cb): |
| | 68 | self.client = Client(self.url + 'gozernet/infoitem/+searchdescr/', \ |
| | 69 | self.name).addcb(cb) |
| | 70 | self.client.post(searchitem=item) |
| 58 | 71 | |
| 59 | 72 | def join(self, cb): |
| … |
… |
|
| 166 | 179 | start_new_thread(asyncore.loop, (), {'use_poll': True }) |
| 167 | 180 | |
| | 181 | def doget(self, mount, *args, **kwargs): |
| | 182 | for url, node in self.nodes.iteritems(): |
| | 183 | node.doget(mount, *args, **kwargs) |
| | 184 | start_new_thread(asyncore.loop, (), {'use_poll': True }) |
| | 185 | |
| | 186 | def dopost(self, mount, *args, **kwargs): |
| | 187 | for url, node in self.nodes.iteritems(): |
| | 188 | node.dopost(mount, *args, **kwargs) |
| | 189 | start_new_thread(asyncore.loop, (), {'use_poll': True }) |
| | 190 | |
| 168 | 191 | def getnodes(self): |
| 169 | 192 | result = [] |
-
|
r2261
|
r2262
|
|
| 76 | 76 | return dumps(info.get(input)) |
| 77 | 77 | |
| | 78 | def infoitemsearchdescr_POST(server, request): |
| | 79 | try: |
| | 80 | input = getpostdata(request) |
| | 81 | what = input['searchitem'] |
| | 82 | except KeyError: |
| | 83 | rlog(10, request.host, 'no searchitem provided') |
| | 84 | return dumps('no searchitem provided') |
| | 85 | return dumps(info.searchdescr(what)) |
| | 86 | |
| 78 | 87 | def init(): |
| 79 | 88 | """ init the cloud plugin """ |
| … |
… |
|
| 90 | 99 | server.addhandler('/gozernet/nodes/', 'GET', nodes_GET) |
| 91 | 100 | server.addhandler('/gozernet/infoitem/', 'GET', infoitem_GET) |
| | 101 | server.addhandler('/gozernet/infoitem/+searchdescr', 'POST', \ |
| | 102 | infoitemsearchdescr_POST) |
| 92 | 103 | server.addhandler('/gozernet/+auth/', 'POST', auth_POST) |
| 93 | 104 | server.addhandler('/gozernet/+ping/', 'GET', ping_GET) |
-
|
r2258
|
r2262
|
|
| 279 | 279 | what = ievent.rest |
| 280 | 280 | what = what.strip().lower() |
| | 281 | if cloud.enabled: |
| | 282 | def cb(client, request): |
| | 283 | if request.error: |
| | 284 | ievent.reply("%s: %s" % (client.host, request.error)) |
| | 285 | if request.data: |
| | 286 | res = [] |
| | 287 | for result in request.data: |
| | 288 | res.append("[%s] %s" % (result[0], result[1])) |
| | 289 | ievent.reply("%s: " % client.host, res, dot=True) |
| | 290 | cloud.dopost('gozernet/infoitem/+searchdescr', cb, searchitem=what) |
| | 291 | return |
| 281 | 292 | result = info.searchdescr(what) |
| 282 | 293 | if result: |