diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ikweb/tools/lazy/www/work/storage.py	Mon Dec 01 00:27:22 2008 +0800
@@ -0,0 +1,34 @@
+class FileStorager:
+    
+    opener = None    
+    working_product = None
+    
+    """
+    A Semi Production Decoration for content storaging.
+    
+    handles content storaging.
+    
+    >>> o = Fetcher( SemiProduct(source="file:///tmp/a.txt") )
+    >>> o.get().working_product.content
+    'It works!!\\n'
+    """
+    def __init__(self, working_product):
+        self.working_product = working_product
+    
+    def get(self, data = {}):
+        """        
+        send datas via http get method.
+        """        
+        res = open(self.working_product.source)
+        return res.read()
+    
+    def post(self, data = {} ):
+        """
+        send datas via http post method.
+        
+        >>> o = Fetcher( SemiProduct(source="file:///tmp/a.txt") )
+        >>> o.post({'a':'b'}).working_product.content
+        'It works!!\\n'
+        """        
+        res = open(self.working_product.source)
+        return res.read()
\ No newline at end of file