comparison ikweb/tools/lazy/www/work/storage.py @ 247:7747bbe5b68e

start to develope Information Exchange Center of Ikariam Game. (prototpye)
author "Hisn Yi, Chen <ossug.hychen@gmail.com>"
date Mon, 01 Dec 2008 00:27:22 +0800
parents
children
comparison
equal deleted inserted replaced
246:60c4b4b78a01 247:7747bbe5b68e
1 class FileStorager:
2
3 opener = None
4 working_product = None
5
6 """
7 A Semi Production Decoration for content storaging.
8
9 handles content storaging.
10
11 >>> o = Fetcher( SemiProduct(source="file:///tmp/a.txt") )
12 >>> o.get().working_product.content
13 'It works!!\\n'
14 """
15 def __init__(self, working_product):
16 self.working_product = working_product
17
18 def get(self, data = {}):
19 """
20 send datas via http get method.
21 """
22 res = open(self.working_product.source)
23 return res.read()
24
25 def post(self, data = {} ):
26 """
27 send datas via http post method.
28
29 >>> o = Fetcher( SemiProduct(source="file:///tmp/a.txt") )
30 >>> o.post({'a':'b'}).working_product.content
31 'It works!!\\n'
32 """
33 res = open(self.working_product.source)
34 return res.read()