Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into python3
[wrw.git]
/
wrw
/
util.py
diff --git
a/wrw/util.py
b/wrw/util.py
index
d7b52cb
..
a7f1e4c
100644
(file)
--- a/
wrw/util.py
+++ b/
wrw/util.py
@@
-1,11
+1,20
@@
import inspect
import inspect
-import req, dispatch, session, form
+
from .
import req, dispatch, session, form
def wsgiwrap(callable):
def wrapper(env, startreq):
return dispatch.handle(req.origrequest(env), startreq, callable)
return wrapper
def wsgiwrap(callable):
def wrapper(env, startreq):
return dispatch.handle(req.origrequest(env), startreq, callable)
return wrapper
+def stringwrap(charset):
+ def dec(callable):
+ def wrapper(*args, **kwargs):
+ bk = callable(*args, **kwargs)
+ for string in bk:
+ yield string.encode(charset)
+ return wrapper
+ return dec
+
def formparams(callable):
def wrapper(req):
data = form.formdata(req)
def formparams(callable):
def wrapper(req):
data = form.formdata(req)
@@
-55,7
+64,7
@@
class sessiondata(object):
class autodirty(sessiondata):
@classmethod
def get(cls, req):
class autodirty(sessiondata):
@classmethod
def get(cls, req):
- ret = super(
autodirty, cls
).get(req)
+ ret = super().get(req)
if "_is_dirty" not in ret.__dict__:
ret.__dict__["_is_dirty"] = False
return ret
if "_is_dirty" not in ret.__dict__:
ret.__dict__["_is_dirty"] = False
return ret
@@
-67,18
+76,18
@@
class autodirty(sessiondata):
return self._is_dirty
def __setattr__(self, name, value):
return self._is_dirty
def __setattr__(self, name, value):
- super(
autodirty, self
).__setattr__(name, value)
+ super().__setattr__(name, value)
if "_is_dirty" in self.__dict__:
self.__dict__["_is_dirty"] = True
def __delattr__(self, name):
if "_is_dirty" in self.__dict__:
self.__dict__["_is_dirty"] = True
def __delattr__(self, name):
- super(
autodirty, self
).__delattr__(name, value)
+ super().__delattr__(name, value)
if "_is_dirty" in self.__dict__:
self.__dict__["_is_dirty"] = True
class manudirty(object):
def __init__(self, *args, **kwargs):
if "_is_dirty" in self.__dict__:
self.__dict__["_is_dirty"] = True
class manudirty(object):
def __init__(self, *args, **kwargs):
- super(
manudirty, self
).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
self.__dirty = False
def sessfrozen(self):
self.__dirty = False
def sessfrozen(self):
@@
-121,7
+130,7
@@
class specslot(object):
class specclass(type):
def __init__(self, name, bases, tdict):
class specclass(type):
def __init__(self, name, bases, tdict):
- super(
specclass, self
).__init__(name, bases, tdict)
+ super().__init__(name, bases, tdict)
sslots = set()
dslots = set()
for cls in self.__mro__:
sslots = set()
dslots = set()
for cls in self.__mro__:
@@
-133,8
+142,7
@@
class specclass(type):
for i, slot in enumerate(self.__sslots_a__):
setattr(self, slot, specslot(slot, i, slot in dslots))
for i, slot in enumerate(self.__sslots_a__):
setattr(self, slot, specslot(slot, i, slot in dslots))
-class specdirty(sessiondata):
- __metaclass__ = specclass
+class specdirty(sessiondata, metaclass=specclass):
__slots__ = ["session", "__sslots__", "_is_dirty"]
def __specinit__(self):
__slots__ = ["session", "__sslots__", "_is_dirty"]
def __specinit__(self):
@@
-142,7
+150,7
@@
class specdirty(sessiondata):
@staticmethod
def __new__(cls, req, sess):
@staticmethod
def __new__(cls, req, sess):
- self = super(
specdirty, cls
).__new__(cls)
+ self = super().__new__(cls)
self.session = sess
self.__sslots__ = [specslot.unbound] * len(cls.__sslots_a__)
self.__specinit__()
self.session = sess
self.__sslots__ = [specslot.unbound] * len(cls.__sslots_a__)
self.__specinit__()
@@
-174,7
+182,6
@@
class specdirty(sessiondata):
ss = specslot.slist(self)
for i, nm in enumerate(type(self).__sslots_a__):
bound, val = st.pop(nm, (False, None))
ss = specslot.slist(self)
for i, nm in enumerate(type(self).__sslots_a__):
bound, val = st.pop(nm, (False, None))
- print i, nm, bound, val
if not bound:
ss[i] = specslot.unbound
else:
if not bound:
ss[i] = specslot.unbound
else: