Author: chrisz
Date: Sun Apr 22 04:04:41 2007
New Revision: 6496
Modified:
Webware/trunk/.checksrc.config (contents, props changed)
Webware/trunk/.pylintrc (contents, props changed)
Webware/trunk/DocSupport/.checksrc.config (props changed)
Webware/trunk/Docs/StyleGuidelines.phtml
Webware/trunk/KidKit/.checksrc.config (contents, props changed)
Webware/trunk/MiddleKit/.checksrc.config (contents, props changed)
Webware/trunk/MiscUtils/.checksrc.config (contents, props changed)
Webware/trunk/MiscUtils/Testing/TestDBPool.py
Webware/trunk/PSP/.checksrc.config (contents, props changed)
Webware/trunk/UserKit/.checksrc.config (contents, props changed)
Webware/trunk/WebKit/.checksrc.config (contents, props changed)
Webware/trunk/WebKit/Docs/Tutorial.html
Webware/trunk/WebKit/Docs/UsersGuide.html
Webware/trunk/WebKit/HTTPContent.py
Webware/trunk/WebUtils/.checksrc.config (contents, props changed)
Webware/trunk/bin/.checksrc.config (props changed)
Webware/trunk/bin/checksrc.py
Log:
Style guidelines now allow 100 instead of 80 characters per line.
Modified: Webware/trunk/.checksrc.config
==============================================================================
--- Webware/trunk/.checksrc.config (original)
+++ Webware/trunk/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -1,6 +1,6 @@
-# .checksrc.config
-{
- 'DisableErrors': {
- 'UncapFN': ['clean', 'install'],
- }
-}
+# .checksrc.config
+{
+ 'DisableErrors': {
+ 'UncapFN': ['clean', 'install'],
+ }
+}
Modified: Webware/trunk/.pylintrc
==============================================================================
--- Webware/trunk/.pylintrc (original)
+++ Webware/trunk/.pylintrc Sun Apr 22 04:04:41 2007
@@ -287,7 +287,8 @@
[FORMAT]
# Maximum number of characters on a single line.
-max-line-length=80
+#max-line-length=80
+max-line-length=100
# Maximum number of lines in a module
#max-module-lines=1000
Modified: Webware/trunk/Docs/StyleGuidelines.phtml
==============================================================================
--- Webware/trunk/Docs/StyleGuidelines.phtml (original)
+++ Webware/trunk/Docs/StyleGuidelines.phtml Sun Apr 22 04:04:41 2007
@@ -80,7 +80,7 @@
<p>Some styles prefix the retrieval method with <code>get</code>, but Webware does not for the sake of brevity and because there are methods for which it is not always clear if a <code>get</code> prefix would make sense.</p>
-<p>Methods that return a Boolean are prefixed with <code>is</code> to make their semantics more obvious. Examples include <code>app.isRunning()</code>, <code>user.isActive()</code> and <code>appServer.isPersistent()</code>.</p>
+<p>Methods that return a Boolean are prefixed with <code>is</code> or <code>has</code> to make their semantics more obvious. Examples include <code>request.isSecure()</code>, <code>user.isActive()</code> and <code>response.hasHeader()</code>.</p>
<a name="SynNaming_MethodCategories"></a><h3>Method Categories</h3>
@@ -149,9 +149,9 @@
'why': 'For consistency and to match the capitalization convention used for classes.',
'examples': 'Servlet.py WebKit.cgi HTTPServlet.py',
'negatives': 'myClass.py session.py',
-'exceptions': 'Files located in Webware/bin/ that are intended solely for command line use are left in all lower case similar to other command line programs such as grep and find.'})%>
+'exceptions': 'Files located in <code>Webware/bin/</code> that are intended solely for command line use are left in all lower case similar to other command line programs such as grep and find.'})%>
<%= convention({'what': 'Files do not contain <code>\\r</code> (on POSIX systems).',
-'why': "To avoid problems with POSIX tools that don't like <code>\\r</code> and confusion in the SVN repository which is hosted on Unix.<br>This problem typically happens when a Windows file is FTPed in binary mode to a Unix machine from which it is then checked in.<br>Note that the SVN client on Windows will properly translate back and forth between <code>\\r\\n</code> and <code>\\n</code> upon check out and check in, since we have set the <code>svn:eol-style</code> property to <code> native</code>."})%>
+'why': "To avoid problems with POSIX tools that don't like <code>\\r</code> and confusion in the SVN repository which is hosted on Unix.<br>This problem typically happens when a Windows file is FTPed in binary mode to a Unix machine from which it is then checked in. Note that the SVN client on Windows properly translates back and forth between <code>\\r\\n</code> and <code>\\n</code> upon check out and check in, since we have set the <code>svn:eol-style</code> property to <code> native</code>."})%>
<%= convention({'what': 'Spaces are not used for indentation.',
'why': "The real problem is mixing tabs and spaces for indentation as people have their tabs set to different widths (commonly 4 or 8). Tabs have been chosen because they're convenient, efficient and fast to cursor through."}) %>
<%= convention({'what': 'Tabs are not used past initial indentation.',
@@ -163,7 +163,7 @@
<%= convention({'what': 'Method names start with a lower case letter.',
'why': 'For consistency and ease of typing. This convention is also used in almost every object-oriented language.',
'examples': 'respond() isSecure() setTimeout() htForDict()',
-'negatives': 'Respond() IsSecure()'}) %>
+'negatives': 'Respond() IsSecure() SetTimeout() HtForDict()'}) %>
<%= convention({'what': 'Method names do not start with <b>get</b>.',
'why': 'See <a href="#SynNaming_MethodsAndAttrs">Methods and Attributes</a> above.',
'examples': 'status() numRequests()',
@@ -193,7 +193,7 @@
def hasValue(self, name):
return self._fields.has_key(name) or self._cookies.has_key(name)''',
'exceptions': 'No category comment is added when the class implementation is <code>pass</code>.'}) %>
-<%= convention({'what': 'Use docstrings and the <a href="http://www.python.org/peps/pep-0257.html">PEP 257</a> conventions.',
+<%= convention({'what': 'Use docstrings and the <a href="http://www.python.org/dev/peps/pep-0257.html">PEP 257</a> conventions.',
'why': 'This allows for creating appropriate code documentation automatically. Please note that in the past, this has not been heeded very well. But as the project matures and grows, the docstrings should be improved.',
'examples': '''def function(a, b):
"""Do X and return a list."""''',
@@ -203,6 +203,10 @@
'why': 'These things are easier to track if they are dated and marked in a consistent way.',
'examples': '# @@ 2000-05-03 ce: This is bogus. Disregard for now.',
'negatives': '# I think this is bogus !!'}) %>
+<%= convention({'what': 'Limit all lines to a maximum of 100 characters if possible.',
+'why': 'This has been settled as a compromise between the people wanting to utilize their huge monitors with line sizes of 130 characters and those wanting to follow the stricter Python style guide recommendation of only 80 characters.'}) %>
+<%= convention({'what': 'If not specified otherwise, follow the <a href="http://www.python.org/dev/peps/pep-008.html">PEP 008</a> conventions.',
+'why': "For historical and opinionated reasons of Webware's BDFL, Webware follows its own style guidelines which overrule the standard guidelines for Python. :-)"}) %>
<a name="Structure"></a><h2>Structure and Patterns</h2>
@@ -254,7 +258,7 @@
<a name="Structure_NamedObjs"></a><h3>Accessing Named Objects</h3>
-<p>Several classes in Webware store dictionaries of objects keyed by their name. HTTPRequest is one such class which stores a dictionary of form fields. The convention for providing an interface to this information is as follows:</p>
+<p>Several classes in Webware store dictionaries of objects keyed by their name. <code>HTTPRequest</code> is one such class which stores a dictionary of form fields. The convention for providing an interface to this information is as follows:</p>
<pre class="py">
## Fields ##
@@ -313,6 +317,10 @@
<a name="MiscNotes"></a><h2>Miscellaneous Notes</h2>
+<a name="Misc_Limitations"></a><h3>Limitations</h3>
+
+<p>Some features that have been introduced in newer Python versions, like properties or decorators, could be used to create more readable code. However, since we want Webware to be backward compatible, these newer features should currently not be used. In future versions of Webware we may certainly lift these restrictions and adapt the style guidelines accordingly.</p>
+
<a name="Misc_Permissions"></a><h3>Permissions</h3>
@@ -321,7 +329,7 @@
<a name="Misc_SendingUpdates"></a><h3>Sending Updates</h3>
-<p>Those who actually develop Webware should send messages to <a href="mailto:webware-discuss@...> when they update the repository.</p>
+<p>Those who actually develop Webware should send messages to <a href="mailto:webware-devel@...> when they update the repository.</p>
<p>The subject should contain the word "update" so that release notes can be easily compiled.</p>
@@ -337,9 +345,9 @@
<a name="Misc_checksrc"></a><h3>checksrc.py</h3>
-<p><code>checksrc.py</code> is a program located in Webware/bin used to check the syntax and naming conventions in the actual Webware source code. You can invoke the program with <code>-h</code> or <code>--help</code> to get information on how to use it and there is a good doc string at the top of file if you're interested in more details.</p>
+<p><code>checksrc.py</code> is a program located in <code>Webware/bin</code> used to check the syntax and naming conventions in the actual Webware source code. You can invoke the program with <code>-h</code> or <code>--help</code> to get information on how to use it and there is a good doc string at the top of file if you're interested in more details. <code>checksrc.py</code> should be run periodically and especially before each release of Webware.</p>
-<p><code>checksrc.py</code> should be run periodically and especially before each release of Webware.</p>
+<p>You can also use <code>pylint</code> (available from <a href="http://www.logilab.org">Logilab.org</a>) for this purpose, which can be easily integrated in most IDEs. A suitable rcfile <code>.pylintrc</code> has been placed in the Webware root directory.</p>
<a name="Misc_Future"></a><h3>Future Work</h3>
@@ -347,7 +355,8 @@
<p>A list of future work for this document:</p>
<ul>
- <li> Document the conventions for Webware components.</li>
+ <li>Document the conventions for Webware components.</li>
+ <li>Adapt the document regarding modern Python features.</li>
</ul>
<% footer() %>
\ No newline at end of file
Modified: Webware/trunk/KidKit/.checksrc.config
==============================================================================
--- Webware/trunk/KidKit/.checksrc.config (original)
+++ Webware/trunk/KidKit/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -1,9 +1,11 @@
-# checksrc.config
-{
- 'DisableErrors': {
- 'ExtraUnder':
- ['KidExamplePage'],
- 'NoBlankLines':
- ['KidServletFactory'],
- }
-}
+# checksrc.config
+{
+ 'DisableErrors': {
+ 'ExtraUnder':
+ ['KidExamplePage'],
+ 'LineSize':
+ ['Properties'],
+ 'NoBlankLines':
+ ['KidServletFactory'],
+ }
+}
Modified: Webware/trunk/MiddleKit/.checksrc.config
==============================================================================
--- Webware/trunk/MiddleKit/.checksrc.config (original)
+++ Webware/trunk/MiddleKit/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -2,6 +2,7 @@
{
'SkipFiles': [],
'DisableErrors': {
+ 'LineSize': ['Properties'],
'NoUnderAttr': ['Doc', 'Model', 'PerThreadDict', 'PerThreadList'],
'ExtraUnder': ['MiddleObject'],
'UncapFN': 'main',
Modified: Webware/trunk/MiscUtils/.checksrc.config
==============================================================================
--- Webware/trunk/MiscUtils/.checksrc.config (original)
+++ Webware/trunk/MiscUtils/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -3,8 +3,10 @@
'SkipFiles': ['inspect', 'pydoc'],
'DisableErrors': {
'ClassNotCap': ['BasicDateTime'],
+ 'LineSize': ['Properties'],
'MethCap': ['MixIn'],
- 'NoUnderAttr': ['BasicDateTime', 'DBPool', 'Error', 'M2PickleRPC', 'ParamFactory', 'PickleRPC', 'TestNamedValueAccess'],
+ 'NoUnderAttr': ['BasicDateTime', 'DBPool', 'Error', 'M2PickleRPC',
+ 'ParamFactory', 'PickleRPC', 'TestNamedValueAccess'],
'ExtraUnder': ['DBPool', 'M2PickleRPC', 'NamedValueAccess', 'PickleRPC'],
}
}
Modified: Webware/trunk/MiscUtils/Testing/TestDBPool.py
==============================================================================
--- Webware/trunk/MiscUtils/Testing/TestDBPool.py (original)
+++ Webware/trunk/MiscUtils/Testing/TestDBPool.py Sun Apr 22 04:04:41 2007
@@ -1,9 +1,11 @@
"""
FUTURE
-* Parameterize the database and everything else. Currently hard coded to pgdb template1 database.
+* Parameterize the database and everything else.
+ Currently hard coded to pgdb template1 database.
-* We don't really test performance here. e.g., we don't do benchmarks to see if DBPool actually helps or not.
+* We don't really test performance here.
+ E.g., we don't do benchmarks to see if DBPool actually helps or not.
"""
Modified: Webware/trunk/PSP/.checksrc.config
==============================================================================
--- Webware/trunk/PSP/.checksrc.config (original)
+++ Webware/trunk/PSP/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -1,10 +1,11 @@
-# checksrc.config
-{
- 'DisableErrors': {
- 'GetMeth': ['Context', 'StreamReader'],
- 'MethCap': ['StreamReader'],
- 'NoUnderAttr': ['BraceConverter', 'Generators', 'ParseEventHandler',
- 'PSPParser', 'StreamReader'],
- 'UncapFN': ['cl_psp'],
- }
-}
+# checksrc.config
+{
+ 'DisableErrors': {
+ 'GetMeth': ['Context', 'StreamReader'],
+ 'LineSize': ['Properties'],
+ 'MethCap': ['StreamReader'],
+ 'NoUnderAttr': ['BraceConverter', 'Generators', 'ParseEventHandler',
+ 'PSPParser', 'StreamReader'],
+ 'UncapFN': ['cl_psp'],
+ }
+}
Modified: Webware/trunk/UserKit/.checksrc.config
==============================================================================
--- Webware/trunk/UserKit/.checksrc.config (original)
+++ Webware/trunk/UserKit/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -1,6 +1,7 @@
-# checksrc.config
-{
- 'DisableErrors': {
- 'ExtraUnder': ['GenUserForMKTest'],
- }
-}
+# checksrc.config
+{
+ 'DisableErrors': {
+ 'ExtraUnder': ['GenUserForMKTest'],
+ 'LineSize': ['Properties'],
+ }
+}
Modified: Webware/trunk/WebKit/.checksrc.config
==============================================================================
--- Webware/trunk/WebKit/.checksrc.config (original)
+++ Webware/trunk/WebKit/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -11,6 +11,8 @@
['Image'],
'ExtraUnder':
['AjaxPage', 'HTTPServer', 'JSONRPCServlet', 'XMLRPCServlet'],
+ 'LineSize':
+ ['Properties'],
'NoBlankLines':
['Image'],
'NoUnderAttr':
Modified: Webware/trunk/WebKit/Docs/Tutorial.html
==============================================================================
--- Webware/trunk/WebKit/Docs/Tutorial.html (original)
+++ Webware/trunk/WebKit/Docs/Tutorial.html Sun Apr 22 04:04:41 2007
@@ -9,7 +9,7 @@
</head>
<body>
<div class="document" id="beginner-tutorial">
-<h1 class="title">Beginner Tutorial</h1>
+<h1 class="header">Beginner Tutorial</h1>
<p>Webware for Python</p>
<table class="docutils field-list" frame="void" rules="none">
@@ -367,5 +367,8 @@
</div>
</div>
</div>
+<div class="footer">
+Webware for Python (<a href="http://www.webwareforpython.org">www.webwareforpython.org</a>)
+</div>
</body>
</html>
Modified: Webware/trunk/WebKit/Docs/UsersGuide.html
==============================================================================
--- Webware/trunk/WebKit/Docs/UsersGuide.html (original)
+++ Webware/trunk/WebKit/Docs/UsersGuide.html Sun Apr 22 04:04:41 2007
@@ -9,7 +9,7 @@
</head>
<body>
<div class="document" id="webkit-user-s-guide">
-<h1 class="title">WebKit User's Guide</h1>
+<h1 class="header">WebKit User's Guide</h1>
<p>Webware for Python</p>
<table class="docutils field-list" frame="void" rules="none">
@@ -411,5 +411,8 @@
Servlets.</p>
</div>
</div>
+<div class="footer">
+Webware for Python (<a href="http://www.webwareforpython.org">www.webwareforpython.org</a>)
+</div>
</body>
</html>
Modified: Webware/trunk/WebKit/HTTPContent.py
==============================================================================
--- Webware/trunk/WebKit/HTTPContent.py (original)
+++ Webware/trunk/WebKit/HTTPContent.py Sun Apr 22 04:04:41 2007
@@ -366,7 +366,8 @@
"""
handler.writeln('''
-<p>Servlets can provide debugging information here by overriding <tt>writeExceptionReport()</tt>.</p><p>For example:</p>
+<p>Servlets can provide debugging information here by overriding
+<tt>writeExceptionReport()</tt>.</p><p>For example:</p>
<pre>
exceptionReportAttrs = 'foo bar baz'.split()
def writeExceptionReport(self, handler):
Modified: Webware/trunk/WebUtils/.checksrc.config
==============================================================================
--- Webware/trunk/WebUtils/.checksrc.config (original)
+++ Webware/trunk/WebUtils/.checksrc.config Sun Apr 22 04:04:41 2007
@@ -2,6 +2,7 @@
{
'SkipFiles': ['cgitb', 'Cookie', 'FieldStorage'],
'DisableErrors': {
+ 'LineSize': ['HTMLTag', 'HTTPStatusCodes', 'Properties'],
'NoUnderAttr': ['HTMLTag'],
}
}
Modified: Webware/trunk/bin/checksrc.py
==============================================================================
--- Webware/trunk/bin/checksrc.py (original)
+++ Webware/trunk/bin/checksrc.py Sun Apr 22 04:04:41 2007
@@ -130,6 +130,8 @@
## Init ##
+ _maxLineSize = 100
+
_errors = {
'UncapFN':
'Uncapitalized filename.',
@@ -138,6 +140,8 @@
'StrayTab':
'Stray tab after other characters.'
' No tabs allowed other than initial indentation.',
+ 'LineSize':
+ 'Limit line to a maximum of %d characters.' % _maxLineSize,
'SpaceIndent':
'Found space as part of indentation. Use only tabs.',
'NoBlankLines':
@@ -482,6 +486,7 @@
def checkFileLine(self, line):
line = line.rstrip()
if line:
+ self.checkLineSize(line)
line = self.clearStrings(line)
if line:
self.checkTabsAndSpaces(line)
@@ -506,6 +511,10 @@
self._blankLines += 1
self._lineNum += 1
+ def checkLineSize(self, line):
+ if len(line) > self._maxLineSize:
+ self.error('LineSize')
+
def clearStrings(self, line):
"""Return line with all quoted strings cleared."""
index = 0
@@ -606,8 +615,9 @@
if len(name) > 3 and name[:3].lower() == 'get':
self.error('GetMeth', locals())
- _exprKeywords = dict([(k, None) for k in
- 'if while for with return yield'.split()])
+ _exprKeywords = {}
+ for k in 'if while for with return yield'.split():
+ _exprKeywords[k] = None
def checkExtraParens(self, parts, line):
if (len(parts) > 1 and self._exprKeywords.has_key(parts[0])
@@ -617,8 +627,9 @@
keyword = parts[0]
self.error('ExtraParens', locals())
- _blockKeywords = dict([(k, None) for k in
- 'if elif else: try: except: while for with'.split()])
+ _blockKeywords = {}
+ for k in 'if elif else: try: except: while for with'.split():
+ _blockKeywords[k] = None
def checkCompStmts(self, parts, line):
if (len(parts) > 1 and self._blockKeywords.has_key(parts[0])
@@ -632,6 +643,10 @@
# Any kind of access of self
_accessRE = re.compile(r'self\.(\w+)\s*(\(?)')
+ # Irregular but allowed attribute names
+ _allowedAttrNames = {}
+ for k in 'assert_ has_key'.split():
+ _allowedAttrNames[k] = None
def checkAttrNames(self, line):
for match in self._accessRE.findall(line):
@@ -655,7 +670,8 @@
inner = attribute[1:]
else:
inner = attribute
- if inner.find('_') >= 0 and inner != 'has_key':
+ if inner.find('_') >= 0 \
+ and not self._allowedAttrNames.has_key(inner):
self.error('ExtraUnder', locals())
# Assignment operators
@@ -682,8 +698,9 @@
self.error('OpNoSpace', {'op': match[1] + '='})
# Augmented assignment operators
- _augmOp = dict([(k, None) for k in
- '+ - * / % ** >> << & ^ |'.split()])
+ _augmOp = {}
+ for k in '+ - * / % ** >> << & ^ |'.split():
+ _augmOp[k] = None
def checkAugmStmts(self, parts):
if len(parts) > 4 and parts[1] == '=' \
|