Author: gotcha
Date: Fri Jun 13 12:23:10 2008
New Revision: 55805
Modified:
kukit/kss.core/branch/jscoverage/kss/core/actionwrapper.py
kukit/kss.core/branch/jscoverage/kss/core/interfaces.py
Log:
cleaned up after pep8
Modified: kukit/kss.core/branch/jscoverage/kss/core/actionwrapper.py
==============================================================================
--- kukit/kss.core/branch/jscoverage/kss/core/actionwrapper.py (original)
+++ kukit/kss.core/branch/jscoverage/kss/core/actionwrapper.py Fri Jun 13
12:23:10 2008
@@ -16,13 +16,13 @@
# 02111-1307, USA.
from textwrap import dedent
-from inspect import formatargspec, getargspec, getargvalues, \
- formatargvalues, currentframe
-from zope.interface import implements
+from inspect import formatargspec, getargspec
+
class KSSExplicitError(Exception):
'Explicit error to be raised'
+
class kssaction(object):
'''Descriptor to bundle kss server actions.
@@ -45,8 +45,8 @@
... raise KSSExplicitError, 'The error'
... def exception(self, a, b, c=0):
... raise Exception, 'Unknown exception'
-
- Now we try qualifying with kssaction. We overwrite render too,
+
+ Now we try qualifying with kssaction. We overwrite render too,
just to enable sensible testing of the output:
>>> class MyView(KSSView):
@@ -64,7 +64,7 @@
... @kssaction
... def exception(self, a, b, c=3):
... raise Exception, 'Unknown exception'
-
+
Instantiate a view.
>>> view = MyView(None, None)
@@ -106,7 +106,7 @@
... def with_docstring(self, a, b, c=3):
... "Docstring"
... raise KSSExplicitError, 'The error'
-
+
>>> request = TestRequest()
>>> view = MyView(None, request)
@@ -127,7 +127,8 @@
Finally, let's check if the method appears if defined on a browser view.
Since there could be a thousand reasons why Five's magic could fail,
- it's good to check this. (XXX Note that this must be adjusted to run on
Zope3.)
+ it's good to check this.
+ (XXX Note that this must be adjusted to run on Zope3.)
>>> try:
... import Products.Five
@@ -171,13 +172,13 @@
... </configure>""")
Let's check it now:
-
+
>>> self.folder.restrictedTraverse('/@@my_view/error')
<bound method MyView.wrapper...
It must also work as a default method of a view since that is
main usage for us:
-
+
>>> v = self.folder.restrictedTraverse('/my_view2')
>>> isinstance(v, MyView)
True
@@ -198,6 +199,7 @@
'Docstring'
'''
+
def __init__(self, f):
self.f = f
# Now this is a solution I don't like, but we need the same
@@ -211,7 +213,8 @@
else:
fixed_args_num = len(argspec[0]) - len(argspec[3])
values_list = [v for v in argspec[0][:fixed_args_num]]
- values_list.extend(['%s=%s' % (v, v) for v in
argspec[0][fixed_args_num:]])
+ values_list.extend(
+ ['%s=%s' % (v, v) for v in argspec[0][fixed_args_num:]])
values_args = ', '.join(values_list)
# provide a docstring in any case.
if self.f.__doc__ is not None:
@@ -228,7 +231,7 @@
self.wrapper_code = compile(code, '<wrapper>', 'exec')
def __get__(self, obj, cls=None):
- d = {'descr': self, 'self': obj}
+ d = {'descr': self, 'self': obj}
exec(self.wrapper_code, d)
wrapper = d['wrapper'].__get__(obj, cls)
return wrapper
@@ -247,10 +250,13 @@
return result
# backward compatibility
+import warnings
+
+
class KssExplicitError(KSSExplicitError):
+
def __init__(self, *args, **kw):
message = "'KssExplicitError' is deprecated," \
"use 'KSSExplicitError'- KSS uppercase instead."
warnings.warn(message, DeprecationWarning, 2)
KSSExplicitError.__init__(self, *args, **kw)
-
Modified: kukit/kss.core/branch/jscoverage/kss/core/interfaces.py
==============================================================================
--- kukit/kss.core/branch/jscoverage/kss/core/interfaces.py (original)
+++ kukit/kss.core/branch/jscoverage/kss/core/interfaces.py Fri Jun 13
12:23:10 2008
@@ -17,12 +17,13 @@
from zope.interface import Interface, Attribute
+
class IKSSCommands(Interface):
'KSS commands'
def addCommand(self, name, selector=None):
'Add a command'
-
+
def render(self, request):
'All methods must use this to return their command set'
@@ -33,10 +34,11 @@
def getCssSelector(self, selector):
'Return selector'
-
+
def getHtmlIdSelector(self, selector):
'Return selector'
+
class IKSSCommand(Interface):
'An KSS command'
@@ -78,6 +80,7 @@
def getParams(self):
''
+
class IKSSCommandView(Interface):
'View of a command set'
@@ -87,7 +90,7 @@
class IKSSParam(Interface):
'An KSS parameter'
-
+
def force_content_unicode(self):
'Content must be str with ascii encoding, or unicode'
@@ -97,6 +100,7 @@
def getContent(self):
''
+
class IKSSView(Interface):
commands = Attribute('An IKSSCommands object that keeps track of '
@@ -113,6 +117,7 @@
# BBB deprecated
IAzaxView = IKSSView
+
class ICommandSet(Interface):
'Methods of this class implement a command set'
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins