Permalink
Browse files

fix bug

  • Loading branch information...
1 parent 6115994 commit 0a4027b6c92214c02f58231e23c09e2ff947a8d2 @yimiqisan committed May 2, 2012
Showing with 17 additions and 1 deletion.
  1. +13 −0 apps/tools.py
  2. +4 −1 handler/noteHandler.py
View
@@ -173,3 +173,16 @@ def trans_64(s):
except ValueError:
return int(urlsafe_b64decode(s))
+class calc(object):
+ def __init__(self, name):
+ self.name = name
+
+ def __call__(self, method):
+ def wapper(decorated_cls, *args):
+ nm = self.name
+ if ((len(args) > 0) and (len(args[0]) == 32)):nm = nm + '_' + args[0]
+ decorated_cls.__setattr__('calc', decorated_cls.cache.incr(nm))
+ return method(decorated_cls, *args)
+ return wapper
+
+
View
@@ -12,7 +12,7 @@
from baseHandler import BaseHandler
from huwai.apps.note import Note
from huwai.apps.tag import Tag
-from huwai.apps.tools import session
+from huwai.apps.tools import session, calc
from huwai.apps.perm import preperm
from datetime import datetime
@@ -28,14 +28,17 @@ def get(self):
class NoteItemHandler(BaseHandler):
@addslash
@session
+ @calc('note')
def get(self, id):
+ print self.calc
uid = self.SESSION['uid']
n = Note()
r = n._api.get(id, cuid=uid)
if r[0]:
return self.render("note/item.html", **r[1])
else:
return self.render("note/item.html", warning=r[1])
+
class NoteEditHandler(BaseHandler):
@addslash

0 comments on commit 0a4027b

Please sign in to comment.