Mercurial > eagle-eye
diff pyikriam/lazy/www/work/__init__.py @ 62:a4c364888197
add ikriam game binding lib python version
author | hychen@mluna |
---|---|
date | Wed, 22 Oct 2008 04:04:32 +0800 |
parents | |
children | 60c4b4b78a01 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pyikriam/lazy/www/work/__init__.py Wed Oct 22 04:04:32 2008 +0800 @@ -0,0 +1,52 @@ +from lazy.www.work.fetch import Fetcher +from lazy.www.work.find import Finder +from lazy.www.core import SemiProduct +class WorkFlow: + + serial_number = 0 + working_product = None + worker = None + + def __init__(self, worker): + self.set_worker(worker) + + def set_worker(self, worker): + self.worker = worker + if self.worker.working_product is None: + self.working_product = SemiProduct() + else: + self.working_product = self.worker.working_product + + def get_content(self): + return self.working_product.content + + def change_worker(self, new_worker): + self.serial_number += 1 + self.worker = new_worker + + def is_fetcher(self, obj): + if obj is not None: return True + + def get(self, data = {} ): + if not self.is_fetcher(self.worker) : + self.change_worker( Fetcher(self.working_product) ) + + self.working_product.content = self.worker.get(data) + return self + + def post(self, data = {} ): + if not self.is_fetcher(self.worker): + self.change_worker( Fetcher(self.working_product) ) + + self.working_product.content = self.worker.post(data) + return self + + def is_finder(self, obj): + if obj is not None: return True + + def find(self, express): + #if not self.is_finder(self.worker): + self.worker = Finder(self.working_product) + self.working_product.content = self.worker.find(express) + + return self \ No newline at end of file