[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Cosmetic fixes.
Gintautas Miliauskas
gintas at pov.lt
Sun Jan 30 14:13:24 EST 2005
Log message for revision 28984:
Cosmetic fixes.
There was one fishy place in zope/schema/_field.py where I removed trailing
whitespace from a doctest (evil!). I think that test was not important.
Changed:
U Zope3/trunk/src/zope/app/broken/tests.py
U Zope3/trunk/src/zope/app/homefolder/README.txt
U Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt
U Zope3/trunk/src/zope/app/session/design.txt
U Zope3/trunk/src/zope/app/tests/functional.py
U Zope3/trunk/src/zope/configuration/tests/test_config.py
U Zope3/trunk/src/zope/schema/_bootstrapfields.py
U Zope3/trunk/src/zope/schema/_field.py
-=-
Modified: Zope3/trunk/src/zope/app/broken/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/broken/tests.py 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/app/broken/tests.py 2005-01-30 19:13:23 UTC (rev 28984)
@@ -71,8 +71,8 @@
Traceback (most recent call last):
...
BrokenModified: Can't modify broken objects
-
+
Cleanup:
>>> import ZODB.broken
Modified: Zope3/trunk/src/zope/app/homefolder/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/README.txt 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/app/homefolder/README.txt 2005-01-30 19:13:23 UTC (rev 28984)
@@ -48,7 +48,7 @@
>>> from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
>>> roles = IPrincipalRoleManager(baseFolder['stephan'])
- >>> [(role, str(setting))
+ >>> [(role, str(setting))
... for role, setting in roles.getRolesForPrincipal('stephan')]
[(u'zope.Manager', 'PermissionSetting: Allow')]
@@ -62,7 +62,7 @@
'sc3'
This has the advantage that you can choose your own `IContainer`
-implementation instead of relying on the vanilla folder.
+implementation instead of relying on the vanilla folder.
Now let's look at some derivations of the same task.
@@ -160,7 +160,7 @@
>>> from zope.app.tests import ztapi
>>> from zope.app.homefolder.interfaces import IHomeFolderManager
- >>> ztapi.provideUtility(IHomeFolderManager, manager, 'manager')
+ >>> ztapi.provideUtility(IHomeFolderManager, manager, 'manager')
(1) Now we can access the home folder via the adapter:
@@ -174,7 +174,7 @@
>>> from zope.app.traversing.interfaces import IPathAdapter
>>> from zope.app import zapi
- >>> zapi.getAdapter(principal, IPathAdapter,
+ >>> zapi.getAdapter(principal, IPathAdapter,
... "homefolder") is baseFolder['stephan']
True
@@ -184,8 +184,8 @@
Setup of the Engine
- >>> from zope.app.pagetemplate.engine import Engine
- >>> from zope.tales.tales import Context
+ >>> from zope.app.pagetemplate.engine import Engine
+ >>> from zope.tales.tales import Context
>>> context = Context(Engine, {'principal': principal})
Executing the TALES expression
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt 2005-01-30 19:13:23 UTC (rev 28984)
@@ -4,7 +4,7 @@
XML-RPC Methods
---------------
-There are two ways to write XML-RPV views. You can write views that
+There are two ways to write XML-RPC views. You can write views that
provide "methods" for other objects, and you can write views that have
their own methods. Let's look at the former case first, since it's a
little bit simpler.
@@ -125,7 +125,7 @@
</methodResponse>
<BLANKLINE>
-Named XM-RPC Views
+Named XML-RPC Views
------------------
Now let's look at views that have their own methods or other
@@ -135,7 +135,7 @@
.../somefolder/listing/contents
To make this possible, the view has to support traversal, so that,
-when it is traversed, it traverses to it's attributes. To supplot
+when it is traversed, it traverses to its attributes. To support
traversal, you can implement or provide an adapter to
`zope.publisher.interfaces.IPublishTraverse`. It's actually better to
provide an adapter so that accesses to attributes during traversal are
Modified: Zope3/trunk/src/zope/app/session/design.txt
===================================================================
--- Zope3/trunk/src/zope/app/session/design.txt 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/app/session/design.txt 2005-01-30 19:13:23 UTC (rev 28984)
@@ -6,7 +6,7 @@
associate an identifier with a particular client. Whenever we get a
request from that client, we compute the identifier and use the
identifier to look up associated information, which is stored on the
-server.
+server.
A major disadvantage of sessions is that they require management of
information on the server. This can have major implications for
@@ -20,7 +20,7 @@
Sessions introduce a number of issues to be considered:
- Clients have to be identified. A number of approaches are possible,
- including:
+ including:
o Using HTTP cookies. The application assigns a client identifier,
which is stored in a cookie. This technique is the most
@@ -68,7 +68,7 @@
If you know that scalability is not (and never will be) an issue,
you can just use the object database.
-
+
If you have client data that needs to be updated often (as in every
request), consider storing the data on the client. (Like all data
received from a client, it may be tainted and, in most instances,
@@ -145,4 +145,4 @@
determined by the session data type interface.
`IPersistentSessionData` defines the application data to be a mapping
object by default. Other data interfaces could specify different
-bahavior.
+bahavior.
Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/app/tests/functional.py 2005-01-30 19:13:23 UTC (rev 28984)
@@ -486,7 +486,7 @@
return self.getOutput()
-headerre = re.compile('(\S+): (.+)$')
+headerre = re.compile(r'(\S+): (.+)$')
def split_header(header):
return headerre.match(header).group(1, 2)
Modified: Zope3/trunk/src/zope/configuration/tests/test_config.py
===================================================================
--- Zope3/trunk/src/zope/configuration/tests/test_config.py 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/configuration/tests/test_config.py 2005-01-30 19:13:23 UTC (rev 28984)
@@ -197,7 +197,7 @@
"""
#'
-def test_kyeword_handling():
+def test_keyword_handling():
"""
>>> machine = ConfigurationMachine()
>>> ns = "http://www.zope.org/testing"
Modified: Zope3/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- Zope3/trunk/src/zope/schema/_bootstrapfields.py 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/schema/_bootstrapfields.py 2005-01-30 19:13:23 UTC (rev 28984)
@@ -182,6 +182,7 @@
object.__class__.__name__))
setattr(object, self.__name__, value)
+
class Container(Field):
def _validate(self, value):
Modified: Zope3/trunk/src/zope/schema/_field.py
===================================================================
--- Zope3/trunk/src/zope/schema/_field.py 2005-01-30 19:06:17 UTC (rev 28983)
+++ Zope3/trunk/src/zope/schema/_field.py 2005-01-30 19:13:23 UTC (rev 28984)
@@ -178,8 +178,6 @@
def __init__(self, values=None, vocabulary=None, source=None, **kw):
"""Initialize object."""
-
-
if vocabulary is not None:
assert (isinstance(vocabulary, basestring)
or IVocabulary.providedBy(vocabulary))
@@ -188,12 +186,12 @@
elif source is not None:
assert ISource.providedBy(source)
vocabulary = source
-
+
assert not (values is None and vocabulary is None), (
"You must specify either values or vocabulary.")
assert values is None or vocabulary is None, (
"You cannot specify both values and vocabulary.")
-
+
self.vocabulary = None
self.vocabularyName = None
if values is not None:
@@ -237,7 +235,7 @@
"""
self.validate(str)
return str
-
+
def _validate(self, value):
# Pass all validations during initialization
if self._init_field:
@@ -264,29 +262,29 @@
def _validate_sequence(value_type, value, errors=None):
"""Validates a sequence value.
-
+
Returns a list of validation errors generated during the validation. If
no errors are generated, returns an empty list.
-
+
value_type is a field. value is the sequence being validated. errors is
an optional list of errors that will be prepended to the return value.
-
+
To illustrate, we'll use a text value type. All values must be unicode.
-
+
>>> field = TextLine(required=True)
-
+
To validate a sequence of various values:
-
+
>>> errors = _validate_sequence(field, ('foo', u'bar', 1))
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>]
-
+
The only valid value in the sequence is the second item. The others
generated errors.
-
+
We can use the optional errors argument to collect additional errors
for a new sequence:
-
+
>>> errors = _validate_sequence(field, (2, u'baz'), errors)
>>> errors
[foo <type 'unicode'>, 1 <type 'unicode'>, 2 <type 'unicode'>]
@@ -329,7 +327,7 @@
# binding value_type is necessary for choices with named vocabularies,
# and possibly also for other fields.
if clone.value_type is not None:
- clone.value_type = clone.value_type.bind(object)
+ clone.value_type = clone.value_type.bind(object)
return clone
def _validate(self, value):
@@ -362,13 +360,13 @@
def _validate_fields(schema, value, errors=None):
if errors is None:
- errors = []
+ errors = []
for name in schema.names(all=True):
if not IMethod.providedBy(schema[name]):
try:
attribute = schema[name]
if IField.providedBy(attribute):
- # validate attributes that are fields
+ # validate attributes that are fields
attribute.validate(getattr(value, name))
except ValidationError, error:
errors.append(error)
@@ -385,17 +383,17 @@
def __init__(self, schema, **kw):
if not IInterface.providedBy(schema):
raise WrongType
-
+
self.schema = schema
super(Object, self).__init__(**kw)
-
+
def _validate(self, value):
super(Object, self)._validate(value)
-
+
# schema has to be provided by value
if not self.schema.providedBy(value):
raise SchemaNotProvided
-
+
# check the value against schema
errors = _validate_fields(self.schema, value)
if errors:
@@ -586,10 +584,10 @@
>>> dotted_name = DottedName(__name__='test')
>>> dotted_name.validate("a.b.c")
>>> dotted_name.validate("a")
- >>> dotted_name.validate(" a ")
+ >>> dotted_name.validate(" a")
Traceback (most recent call last):
...
- InvalidDottedName: a
+ InvalidDottedName: a
>>> dotted_name = DottedName(__name__='test', min_dots=1)
>>> dotted_name.validate('a.b')
More information about the Zope3-Checkins
mailing list