[Testbot] Plone 4.3 - Python 2.7 - Build # 2568 - Still failing! - 5 failure(s)

jenkins at plone.org jenkins at plone.org
Mon Sep 22 16:52:33 UTC 2014


-------------------------------------------------------------------------------
Plone 4.3 - Python 2.7 - Build # 2568 - Still Failing!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-4.3-python-2.7/2568/


-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------

Repository: plone.dexterity
Branch: refs/heads/master
Date: 2014-04-30T21:04:09+03:00
Author: Asko Soukka (datakurre) <asko.soukka at iki.fi>
Commit: https://github.com/plone/plone.dexterity/commit/aad7e7046717ff1a9cc366b5cc9701753b650d19

Fix the default attribute accessor to bind field to context when finding

Files changed:
M CHANGES.rst
M plone/dexterity/content.py
M plone/dexterity/tests/test_content.py

diff --git a/CHANGES.rst b/CHANGES.rst
index b77f9a8..a36d6d5 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,9 @@ Changelog
 2.2.4 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Fix the default attribute accessor to bind field to context when finding
+  the field default.
+  [datakurre]
 
 
 2.2.3 (2014-04-15)
diff --git a/plone/dexterity/content.py b/plone/dexterity/content.py
index d4ebe20..dd7c73a 100644
--- a/plone/dexterity/content.py
+++ b/plone/dexterity/content.py
@@ -255,13 +255,15 @@ def __getattr__(self, name):
         if schema is not None:
             field = schema.get(name, None)
             if field is not None:
-                return deepcopy(field.default)
+                bound = field.bind(self)
+                return deepcopy(bound.default)
 
         # do the same for each subtype
         for schema in SCHEMA_CACHE.subtypes(self.portal_type):
             field = schema.get(name, None)
             if field is not None:
-                return deepcopy(field.default)
+                bound = field.bind(self)
+                return deepcopy(bound.default)
 
         raise AttributeError(name)
 
diff --git a/plone/dexterity/tests/test_content.py b/plone/dexterity/tests/test_content.py
index 6b36b9a..2fdb7e0 100644
--- a/plone/dexterity/tests/test_content.py
+++ b/plone/dexterity/tests/test_content.py
@@ -433,6 +433,36 @@ class ISchema(Interface):
         self.assertEqual(u"id", content.id)
         self.assertRaises(AttributeError, getattr, content, 'baz')
 
+    def test_getattr_consults_schema_item_default_factory_with_context(self):
+
+        content = Item()
+        content.id = u"id"
+        content.portal_type = u"testtype"
+
+        from zope.interface import provider
+        from zope.schema.interfaces import IContextAwareDefaultFactory
+
+        @provider(IContextAwareDefaultFactory)
+        def defaultFactory(context):
+            return u"{0:s}_{1:s}".format(context.id, context.portal_type)
+
+        class ISchema(Interface):
+            foo = zope.schema.TextLine(title=u"foo",
+                                       defaultFactory=defaultFactory)
+            bar = zope.schema.TextLine(title=u"bar")
+
+        # FTI mock
+        fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
+        self.expect(fti_mock.lookupSchema()).result(ISchema)
+        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
+
+        self.replay()
+
+        self.assertEqual(u"id_testtype", content.foo)
+        self.assertEqual(None, content.bar)
+        self.assertEqual(u"id", content.id)
+        self.assertRaises(AttributeError, getattr, content, 'baz')
+
     def test_getattr_on_container_returns_children(self):
 
         content = Container()


Repository: plone.dexterity
Branch: refs/heads/master
Date: 2014-05-08T07:39:53+03:00
Author: Asko Soukka (datakurre) <asko.soukka at iki.fi>
Commit: https://github.com/plone/plone.dexterity/commit/1e5572127ac8052669d278fd92e659804df3ec5a

Fix to bind field only when field has context aware field factory

Files changed:
M plone/dexterity/content.py

diff --git a/plone/dexterity/content.py b/plone/dexterity/content.py
index dd7c73a..f13f5bf 100644
--- a/plone/dexterity/content.py
+++ b/plone/dexterity/content.py
@@ -14,6 +14,8 @@
 from zope.interface.declarations import getObjectSpecification
 from zope.interface.declarations import ObjectSpecificationDescriptor
 
+from zope.schema.interfaces import IContextAwareDefaultFactory
+
 from zope.security.interfaces import IPermission
 
 from zope.annotation import IAttributeAnnotatable
@@ -255,15 +257,23 @@ def __getattr__(self, name):
         if schema is not None:
             field = schema.get(name, None)
             if field is not None:
-                bound = field.bind(self)
-                return deepcopy(bound.default)
+                if IContextAwareDefaultFactory.providedBy(
+                        getattr(field, 'defaultFactory', None)):
+                    bound = field.bind(self)
+                    return deepcopy(bound.default)
+                else:
+                    return deepcopy(field.default)
 
         # do the same for each subtype
         for schema in SCHEMA_CACHE.subtypes(self.portal_type):
             field = schema.get(name, None)
             if field is not None:
-                bound = field.bind(self)
-                return deepcopy(bound.default)
+                if IContextAwareDefaultFactory.providedBy(
+                        getattr(field, 'defaultFactory', None)):
+                    bound = field.bind(self)
+                    return deepcopy(bound.default)
+                else:
+                    return deepcopy(field.default)
 
         raise AttributeError(name)
 


Repository: plone.dexterity
Branch: refs/heads/master
Date: 2014-09-22T17:56:09+02:00
Author: Jens W. Klein (jensens) <jk at kleinundpartner.at>
Commit: https://github.com/plone/plone.dexterity/commit/75d4707bcbc66d477001ed0e3ecc7b5ab9e5b020

merge conflicts solved

Files changed:
M CHANGES.rst
M README.rst
M docs/INSTALL.txt
M docs/LICENSE.txt
M docs/WebDAV.txt
M plone/__init__.py
M plone/dexterity/CONVENTIONS.txt
M plone/dexterity/behavior.py
M plone/dexterity/browser/add.py
M plone/dexterity/browser/base.py
M plone/dexterity/browser/configure.zcml
M plone/dexterity/browser/containercontentcore.pt
M plone/dexterity/browser/edit.py
M plone/dexterity/browser/fti.pt
M plone/dexterity/browser/fti.py
M plone/dexterity/browser/item.pt
M plone/dexterity/browser/itemcontentcore.pt
M plone/dexterity/browser/traversal.py
M plone/dexterity/browser/view.py
M plone/dexterity/configure.zcml
M plone/dexterity/content.py
M plone/dexterity/exportimport.py
M plone/dexterity/factory.py
M plone/dexterity/filerepresentation.py
M plone/dexterity/fti.py
M plone/dexterity/i18n.py
M plone/dexterity/interfaces.py
M plone/dexterity/meta.zcml
M plone/dexterity/primary.py
M plone/dexterity/schema.py
M plone/dexterity/tests/__init__.py
M plone/dexterity/tests/schemata.py
M plone/dexterity/tests/test_behavior.py
M plone/dexterity/tests/test_content.py
M plone/dexterity/tests/test_content_integration.py
M plone/dexterity/tests/test_exportimport.py
M plone/dexterity/tests/test_factory.py
M plone/dexterity/tests/test_fti.py
M plone/dexterity/tests/test_primary.py
M plone/dexterity/tests/test_schema.py
M plone/dexterity/tests/test_schema_cache.py
M plone/dexterity/tests/test_security.py
M plone/dexterity/tests/test_utils.py
M plone/dexterity/tests/test_views.py
M plone/dexterity/tests/test_webdav.py
M plone/dexterity/utils.py

diff --git a/CHANGES.rst b/CHANGES.rst
index a36d6d5..a5322d0 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,9 +4,26 @@ Changelog
 2.2.4 (unreleased)
 ------------------
 
+<<<<<<< HEAD
 - Fix the default attribute accessor to bind field to context when finding
   the field default.
   [datakurre]
+=======
+- fix: when Dexterity container or its children contains any AT content with 
+  AT references in them, any move or rename operation for the parent 
+  Dexterity object will cause AT ReferenceEngine to remove those references.
+  see #20.
+  [datakurre]
+
+- Let utils.createContent also handle setting of attributes on behaviors, which
+  derive from other behaviors.
+  [thet]
+
+- overhaul (no logic changed): 
+  pep8, sorted imports plone.api style, readability, utf8header, 
+  remove bbb code (plone 3)
+  [jensens]
+>>>>>>> master
 
 
 2.2.3 (2014-04-15)
@@ -38,7 +55,8 @@ Changelog
 2.2.0 (2014-01-31)
 ------------------
 
-- utils.createContent honors behaviors [toutpt]
+- utils.createContent honors behaviors.
+  [toutpt]
 
 - Date index method works even if source field is a dexterity field
   wich provides a  datetime python value.
diff --git a/README.rst b/README.rst
index 929980b..0204ef7 100644
--- a/README.rst
+++ b/README.rst
@@ -14,7 +14,7 @@ Dexterity wants to make some things really easy. These are:
 
 - Create a "real" content type entirely through-the-web without having to
   know programming.
-  
+
 - As a business user, create a schema using visual or through-the-web tools,
   and augment it with adapters, event handlers, and other Python code
   written on the filesystem by a Python programmer.
@@ -27,14 +27,14 @@ Dexterity wants to make some things really easy. These are:
   declarative fashion. Behaviours can be things like title-to-id naming,
   support for locking or versioning, or sets of standard metadata with
   associated UI elements.
- 
+
 - Easily package up and distribute content types defined through-the-web,
   on the filesystem, or using a combination of the two.
 
 Philosophy
 ----------
 
-Dexterity is designed with a specific philosophy in mind. This can be 
+Dexterity is designed with a specific philosophy in mind. This can be
 summarised as follows:
 
 Reuse over reinvention
@@ -42,15 +42,15 @@ Reuse over reinvention
    As far as possible, Dexterity should reuse components and technologies
    that already exist. More importantly, however, Dexterity should reuse
    *concepts* that exist elsewhere. It should be easy to learn Dexterity
-   by analogy, and to work with Dexterity types using familiar APIs and 
+   by analogy, and to work with Dexterity types using familiar APIs and
    techniques.
 
 Small over big
 
    Mega-frameworks be damned. Dexterity consists of a number of specialised
    packages, each of which is independently tested and reusable. Furthermore,
-   packages should have as few dependencies as possible, and should declare 
-   their dependencies explicitly. This helps keep the design clean and the 
+   packages should have as few dependencies as possible, and should declare
+   their dependencies explicitly. This helps keep the design clean and the
    code manageable.
 
 Natural interaction over excessive generality
@@ -75,15 +75,15 @@ Zope 3 over Zope 2
    Although Dexterity does not pretend to work with non-CMF systems, as
    many components as possible should work with plain Zope 3, and even where
    there are dependencies on Zope 2, CMF or Plone, they should - as far as
-   is practical - follow Zope 3 techniques and best practices. Many 
+   is practical - follow Zope 3 techniques and best practices. Many
    operations (e.g. managing objects in a folder, creating new objects
    or manipulating objects through a defined schema) are better designed in
-   Zope 3 than they were in Zope 2. 
+   Zope 3 than they were in Zope 2.
 
 Zope concepts over new paradigms
 
    We want Dexterity to be "Zope-ish" (and really, "Zope 3-ish"). Zope is a
-   mature, well-designed (well, mostly) and battle tested platform. We do 
+   mature, well-designed (well, mostly) and battle tested platform. We do
    not want to invent brand new paradigms and techniques if we can help it.
 
 Automated testing over wishful thinking
@@ -102,17 +102,17 @@ The model
 
    The Dexterity "model" describes a type's schemata (most types will have
    only one) and metadata associated with those schemata. A schema is just
-   a series of fields that can be used to render add/edit forms and 
+   a series of fields that can be used to render add/edit forms and
    introspect an object of the given type. The metadata storage is extensible
    via the component architecture. Typical forms of metadata include UI
    hints such as specifying the type of widget to use when rendering a
    particular field, and per-field security settings.
-   
-   The model is typically described in XML, though at runtime it is an 
-   instance of an object providing the IModel interface from 
+
+   The model is typically described in XML, though at runtime it is an
+   instance of an object providing the IModel interface from
    plone.supermodel. Schemata in the model are interfaces with zope.schema
    fields.
-   
+
    The model can exist purely as data in the ZODB if a type is created
    through-the-web. Alternatively, it can be loaded from a file. The XML
    representation is intended to be human-readable and self-documenting.
@@ -125,7 +125,7 @@ The schema
    simply an Interface with zope.schema fields. The schema can be specified
    in Python code (in which case it is simply referenced by name), or it
    can be loaded from an XML model.
-   
+
    The unnamed schema is also known as the IContentType schema, in that the
    schema interface will provide the Zope 3 IContentType interface. This
    means that if you call queryContentType() on a Dexterity content object,
@@ -139,14 +139,14 @@ The class
    Of course, all content objects are instances of a particular class.
    It is easy to provide your own class, and Dexterity has convenient
    base classes for you to use. However, many types will not need a class
-   at all. Instead, they will use the standard Dexterity "Item" and 
+   at all. Instead, they will use the standard Dexterity "Item" and
    "Container" classes.
-   
+
    Dexterity's content factory will initialise an object of one of these
    classes with the fields in the type's content schema, and will ensure
    that objects provide the relevant interfaces, including the schema
    interface itself.
-   
+
    The preferred way to add behaviour and logic to Dexterity content objects
    is via adapters. In this case, you will probably want a filesystem
    version of the schema interface (this can still be loaded from XML if you
@@ -158,11 +158,11 @@ The factory
    Dexterity content is constructed using a standard Zope 3 IFactory
    named utility. By convention the factory utility has the same name as the
    portal_type of the content type.
-   
-   When a Dexterity FTI (Factory Type Information, see below) is created, 
-   an appropriate factory will be registered as a local utility unless one 
+
+   When a Dexterity FTI (Factory Type Information, see below) is created,
+   an appropriate factory will be registered as a local utility unless one
    with that name already exists.
-   
+
    The default factory is capable of initialising a generic 'Item' or
    'Container' object to exhibit a content type schema and have the
    security and other aspects specified in the type's model. You can use
@@ -170,17 +170,17 @@ The factory
 
 Views
 
-   Dexterity will by default create an add view (registered as a local 
+   Dexterity will by default create an add view (registered as a local
    utility, since it needs to take the portal_type of the content type into
    account when determining what fields to render) and an edit view (
    registered as a generic, global view, which inspects the context's
    portal_type at runtime) for each type. There is also a default main
    view, which simply outputs the fields set on the context.
-   
+
    To register new views, you will normally need a filesystem schema
    interface. You can then register views for this interface as you
    normally would.
-   
+
    If you need to override the default add view, create a view for IAdding
    with a name corresponding to the portal_type of the content type.
    This will prevent Dexterity from registering a local view with the same
@@ -191,21 +191,21 @@ The Factory Type Information (FTI)
    The FTI holds various information about the content type. Many operations
    performed by the Dexterity framework begin by looking up the type's
    FTI to find out some information about the type.
-   
+
    The FTI is an object stored in portal_types in the ZMI. Most settings can
    be changed through the web. See the IDexterityFTI interface for more
    information.
-   
+
    When a Dexterity FTI is created, an event handler will create a few
    local components, including the factory utility and add view for the
    new type. The FTI itself is also registered as a named utility, to
    make it easy to look up using syntax like:
-   
+
        getUtility(IDexterityFTI, name=portal_type)
-       
+
    The FTI is also fully importable and exportable using GenericSetup.
-   Thus, the easiest way to create and distribute a content type is to 
-   create a new FTI, set some properties (including a valid XML model, 
+   Thus, the easiest way to create and distribute a content type is to
+   create a new FTI, set some properties (including a valid XML model,
    which can be entered TTW if there is no file or schema interface to use),
    and export it as a GenericSetup extension profile.
 
@@ -214,24 +214,24 @@ Behaviours
    Behaviors are a way write make re-usable bits of functionality that can
    be toggled on or off on a per-type basis. Examples may include common
    metadata, or common functionality such as locking, tagging or ratings.
-   
+
    Behaviors are implemented using the plone.behavior package. See its
    documentation for more details about how to write your own behaviors.
-   
+
    In Dexterity, behaviors can "inject" fields into the standard add and edit
    forms, and may provide marker interfaces for newly created objects. See
    the example.dexterity package for an example of a behavior that provides
    form fields.
-   
+
    In use, a behavior is essentially just an adapter that only appears to be
    registered if the behavior is enabled in the FTI of the object being
    adapted. Thus, if you have a behavior described by my.package.IMyBehavior,
    you'll typically interact with this behavior by doing::
-   
+
        my_behavior = IMyBehavior(context, None)
        if my_behavior is not None:
            ...
-   
+
    The enabled behaviors for a given type are kept in the FTI, as a
    list of dotted interface names.
 
@@ -248,11 +248,11 @@ plone.alterego (Python)
 
    Support for dynamic modules that create objects on the fly. Dexterity
    uses this to dynamically create "real" interfaces for types that exist
-   only through-the-web. This allows these types to have a proper 
+   only through-the-web. This allows these types to have a proper
    IContentType schema, and allows local adapters to be registered for
-   this interface (e.g. a custom view with a template defined through the 
+   this interface (e.g. a custom view with a template defined through the
    web).
-   
+
    Note that if a type uses a filesystem interface (whether written manually
    or loaded from an XML model), this module is not used.
 
@@ -263,7 +263,7 @@ plone.supermodel (Zope 3)
    fields, and is thus easily extensible to new field types. This has the
    added benefit that the interface documentation in the zope.schema package
    applies to the XML format as well.
-   
+
    Supermodel is extensible via adapters and XML namespaces. plone.dexterity
    uses this to allow security and UI hints to be embedded as metadata in the
    XML model.
@@ -274,7 +274,7 @@ plone.behavior (Zope 3)
    a generic behaviour that works via a simple adapter. The adapter will
    appear to be registered for types that have the named behaviour
    available.
-   
+
    Dexterity wires this up in such a way that the list of enabled behaviours
    is stored as a property in the FTI. This makes it easy to add/remove
    behaviours through the web, or using GenericSetup at install time.
@@ -289,7 +289,7 @@ plone.autoform (CMF)
 
    Contains helper functions to construct forms based on tagged values stored
    on schema interfaces.
-   
+
 plone.directives.form (CMF)
 
    Adds convention-over-configuration support for plone.supermodel schemata
@@ -304,9 +304,9 @@ plone.dexterity (CMF)
 
 plone.directives.dexterity (CMF)
 
-   Adds convention-over-configuration support for Dexterity content and 
+   Adds convention-over-configuration support for Dexterity content and
    add/edit forms.
-   
+
 plone.app.dexterity (Plone)
 
    This package contains all Plone-specific aspects of Dexterity, including
@@ -315,7 +315,7 @@ plone.app.dexterity (Plone)
 Usage examples
 --------------
 
-Take a look at the example.dexterity package, which can be found in the 
+Take a look at the example.dexterity package, which can be found in the
 Plone Collective (http://dev.plone.org/collective), for examples of various
 ways to use Dexterity.
 
diff --git a/docs/INSTALL.txt b/docs/INSTALL.txt
index a2e8721..9110f2c 100644
--- a/docs/INSTALL.txt
+++ b/docs/INSTALL.txt
@@ -4,7 +4,7 @@ plone.dexterity Installation
 To install plone.dexterity into the global Python environment (or a workingenv),
 using a traditional Zope 2 instance, you can do this:
 
- * When you're reading this you have probably already run 
+ * When you're reading this you have probably already run
    ``easy_install plone.dexterity``. Find out how to install setuptools
    (and EasyInstall) here:
    http://peak.telecommunity.com/DevCenter/EasyInstall
@@ -20,24 +20,24 @@ Alternatively, if you are using zc.buildout and the plone.recipe.zope2instance
 recipe to manage your project, you can do this:
 
  * Add ``plone.dexterity`` to the list of eggs to install, e.g.:
- 
+
     [buildout]
     ...
     eggs =
         ...
         plone.dexterity
-        
+
   * Tell the plone.recipe.zope2instance recipe to install a ZCML slug:
-  
+
     [instance]
     recipe = plone.recipe.zope2instance
     ...
     zcml =
         plone.dexterity
-        
+
   * Re-run buildout, e.g. with:
-  
+
     $ ./bin/buildout
-        
+
 You can skip the ZCML slug if you are going to explicitly include the package
 from another package's configure.zcml file.
diff --git a/docs/LICENSE.txt b/docs/LICENSE.txt
index e493fe6..8a2ec36 100644
--- a/docs/LICENSE.txt
+++ b/docs/LICENSE.txt
@@ -11,5 +11,5 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA 02111-1307 USA.
diff --git a/docs/WebDAV.txt b/docs/WebDAV.txt
index 3356f67..134d901 100644
--- a/docs/WebDAV.txt
+++ b/docs/WebDAV.txt
@@ -79,7 +79,7 @@ By default ``Resource.PUT()`` fails with 405 Method Not Allowed. That is, it
 is not by default possible to PUT to a resource that already exists. The same
 is true of ``Collection.PUT()``.
 
-In Dexterity, the ``PUT()`` method is overridden to adapt self to 
+In Dexterity, the ``PUT()`` method is overridden to adapt self to
 ``zope.filerepresentation.IRawWriteFile``, and call its ``write()`` method one
 or more times, writing the contents of the request body, before calling
 ``close()``. The ``mimeType`` and ``encoding`` properties will also be set
@@ -149,7 +149,7 @@ status.
 
 The ``PropertyManager`` mixin class defines the ``propertysheets`` variable to
 be an instance of ``DefaultPropertySheets``. This in turn has two property
-sheets, ``default``, a ``DefaultProperties`` instance, and ``webdav``, a 
+sheets, ``default``, a ``DefaultProperties`` instance, and ``webdav``, a
 ``DAVProperties`` instance.
 
 The ``DefaultProperties`` instance contains the main property sheet. This
diff --git a/plone/__init__.py b/plone/__init__.py
index f48ad10..68c04af 100644
--- a/plone/__init__.py
+++ b/plone/__init__.py
@@ -1,6 +1,2 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
-    __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
-    from pkgutil import extend_path
-    __path__ = extend_path(__path__, __name__)
+# -*- coding: utf-8 -*-
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/plone/dexterity/CONVENTIONS.txt b/plone/dexterity/CONVENTIONS.txt
index 8ae5213..690e296 100644
--- a/plone/dexterity/CONVENTIONS.txt
+++ b/plone/dexterity/CONVENTIONS.txt
@@ -4,28 +4,28 @@ Dexterity naming conventions
 The following naming conventions apply to Dexterity code.
 
  * Classes use CamelCase, e.g. SchemaFactory
- 
+
  * Methods and functions that are meant for external use are in mixedCase,
    e.g. createContentInContainer()
-   
+
  * Arguments to methods that are meant for external use are also in mixedCase,
    e.g. addContentToContainer(container, object, checkConstraints=True)
-  
+
  * Class variables and object attributes that are meant for external use
    are also in mixedCase, e.g. isPrincipiaFolderish
-   
+
  * Exceptions to this rule:
- 
+
      * FTI attributes are in lower_case_with_underscore, e.g. model_source
      * Any attribute/argument referring to the CMF portal_type is written as
        such, *not* portalType
- 
+
  * Acronyms in class or variable names are all in the same case, e.g.
    DexterityFTI or ftiCounter.
-   
+
  * Constants and globals are in ALL_CAPS_WITH_UNDER_SCORE e.g. SCHEMA_CACHE
 
  * Internal variables may be in lower_case_with_underscore if appropriate.
 
- * Grok directives use lower_case_and_underscore, e.g. 
+ * Grok directives use lower_case_and_underscore, e.g.
    dexterity.write_permission() or form.default_value().
\ No newline at end of file
diff --git a/plone/dexterity/behavior.py b/plone/dexterity/behavior.py
index c9d2c99..50c2e9e 100644
--- a/plone/dexterity/behavior.py
+++ b/plone/dexterity/behavior.py
@@ -1,30 +1,30 @@
-from zope.interface import implements
-from zope.component import adapts, getUtility, queryUtility
-
+# -*- coding: utf-8 -*-
 from plone.behavior.interfaces import IBehavior
 from plone.behavior.interfaces import IBehaviorAssignable
-
-from plone.dexterity.interfaces import IDexterityFTI
 from plone.dexterity.interfaces import IDexterityContent
+from plone.dexterity.interfaces import IDexterityFTI
+from zope.component import adapts, getUtility, queryUtility
+from zope.interface import implements
+
 
 class DexterityBehaviorAssignable(object):
     """Support plone.behavior behaviors stored in the FTI
     """
-    
+
     implements(IBehaviorAssignable)
     adapts(IDexterityContent)
-    
+
     def __init__(self, context):
         self.fti = getUtility(IDexterityFTI, name=context.portal_type)
-    
+
     def supports(self, behavior_interface):
         for behavior in self.enumerateBehaviors():
             if behavior_interface in behavior.interface._implied:
                 return True
         return False
-        
+
     def enumerateBehaviors(self):
         for name in self.fti.behaviors:
             behavior = queryUtility(IBehavior, name=name)
             if behavior is not None:
-                yield behavior
\ No newline at end of file
+                yield behavior
diff --git a/plone/dexterity/browser/add.py b/plone/dexterity/browser/add.py
index 9ffb6ec..f5d587a 100644
--- a/plone/dexterity/browser/add.py
+++ b/plone/dexterity/browser/add.py
@@ -1,57 +1,54 @@
-from zope.component import getUtility, createObject
-from zope.publisher.browser import BrowserPage
-from zope.event import notify
-
-from z3c.form import form, button
-from plone.z3cform import layout
-
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.i18n import MessageFactory as _
-
+# -*- coding: utf-8 -*-
+from Acquisition import aq_inner, aq_base
+from Acquisition.interfaces import IAcquirer
+from Products.statusmessages.interfaces import IStatusMessage
 from plone.dexterity.browser.base import DexterityExtensibleForm
-from plone.dexterity.utils import addContentToContainer
 from plone.dexterity.events import AddBegunEvent
 from plone.dexterity.events import AddCancelledEvent
+from plone.dexterity.i18n import MessageFactory as _
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.utils import addContentToContainer
 from plone.dexterity.utils import getAdditionalSchemata
+from plone.z3cform import layout
+from z3c.form import form, button
+from zope.component import getUtility, createObject
+from zope.event import notify
+from zope.publisher.browser import BrowserPage
 
-from Acquisition import aq_inner, aq_base
-from Acquisition.interfaces import IAcquirer
-
-from Products.statusmessages.interfaces import IStatusMessage
 
 class DefaultAddForm(DexterityExtensibleForm, form.AddForm):
     """Standard add form, which is wrapped by DefaultAddView (see below).
-    
+
     This form is capable of rendering the fields of any Dexterity schema,
     including behaviours. To do that, needs to know the portal_type, which
     can be set as a class variable (in a subclass), or on a created instance.
-    
+
     By default, the DefaultAddView (see below) will set the portal_type based
     on the FTI.
     """
-    
+
     portal_type = None
     immediate_view = None
-    
+
     def __init__(self, context, request, ti=None):
         super(DefaultAddForm, self).__init__(context, request)
         if ti is not None:
             self.ti = ti
             self.portal_type = ti.getId()
         self.request['disable_border'] = True
-    
+
     @property
     def additionalSchemata(self):
         return getAdditionalSchemata(portal_type=self.portal_type)
 
     # API
-    
+
     def create(self, data):
         fti = getUtility(IDexterityFTI, name=self.portal_type)
-        
+
         container = aq_inner(self.context)
         content = createObject(fti.factory)
-        
+
         # Note: The factory may have done this already, but we want to be sure
         # that the created type has the right portal type. It is possible
         # to re-define a type through the web that uses the factory from an
@@ -59,7 +56,7 @@ def create(self, data):
 
         if hasattr(content, '_setPortalTypeName'):
             content._setPortalTypeName(fti.getId())
-        
+
         # Acquisition wrap temporarily to satisfy things like vocabularies
         # depending on tools
         if IAcquirer.providedBy(content):
@@ -72,24 +69,28 @@ def create(self, data):
         return aq_base(content)
 
     def add(self, object):
-        
+
         fti = getUtility(IDexterityFTI, name=self.portal_type)
         container = aq_inner(self.context)
         new_object = addContentToContainer(container, object)
-        
+
         if fti.immediate_view:
-            self.immediate_view = "%s/%s/%s" % (container.absolute_url(), new_object.id, fti.immediate_view,)
+            self.immediate_view = "/".join(
+                [container.absolute_url(), new_object.id, fti.immediate_view]
+            )
         else:
-            self.immediate_view = "%s/%s" % (container.absolute_url(), new_object.id)
+            self.immediate_view = "/".join(
+                [container.absolute_url(), new_object.id]
+            )
 
     def nextURL(self):
         if self.immediate_view is not None:
             return self.immediate_view
         else:
             return self.context.absolute_url()
-    
+
     # Buttons
-    
+
     @button.buttonAndHandler(_('Save'), name='save')
     def handleAdd(self, action):
         data, errors = self.extractData()
@@ -100,25 +101,29 @@ def handleAdd(self, action):
         if obj is not None:
             # mark only as finished if we get the new object
             self._finishedAdd = True
-            IStatusMessage(self.request).addStatusMessage(_(u"Item created"), "info success")
-    
+            IStatusMessage(self.request).addStatusMessage(
+                _(u"Item created"), "info success"
+            )
+
     @button.buttonAndHandler(_(u'Cancel'), name='cancel')
     def handleCancel(self, action):
-        IStatusMessage(self.request).addStatusMessage(_(u"Add New Item operation cancelled"), "info")
+        IStatusMessage(self.request).addStatusMessage(
+            _(u"Add New Item operation cancelled"), "info"
+        )
         self.request.response.redirect(self.nextURL())
         notify(AddCancelledEvent(self.context))
-    
+
     def update(self):
         super(DefaultAddForm, self).update()
         # fire the edit begun only if no action was executed
         if len(self.actions.executedActions) == 0:
             notify(AddBegunEvent(self.context))
-    
+
     def updateActions(self):
         super(DefaultAddForm, self).updateActions()
         if 'save' in self.actions:
             self.actions["save"].addClass("context")
-        
+
         if 'cancel' in self.actions:
             self.actions["cancel"].addClass("standalone")
 
@@ -132,19 +137,20 @@ def label(self):
 
 class DefaultAddView(layout.FormWrapper, BrowserPage):
     """This is the default add view as looked up by the ++add++ traversal
-    namespace adapter in CMF. It is an unnamed adapter on 
+    namespace adapter in CMF. It is an unnamed adapter on
     (context, request, fti).
-    
+
     Note that this is registered in ZCML as a simple <adapter />, but we
     also use the <class /> directive to set up security.
     """
-    
+
     form = DefaultAddForm
-    
+
     def __init__(self, context, request, ti):
         super(DefaultAddView, self).__init__(context, request)
         self.ti = ti
 
         # Set portal_type name on newly created form instance
-        if self.form_instance is not None and not getattr(self.form_instance, 'portal_type', None): 
+        if self.form_instance is not None \
+           and not getattr(self.form_instance, 'portal_type', None):
             self.form_instance.portal_type = ti.getId()
diff --git a/plone/dexterity/browser/base.py b/plone/dexterity/browser/base.py
index 6daa6b7..47ba91e 100644
--- a/plone/dexterity/browser/base.py
+++ b/plone/dexterity/browser/base.py
@@ -1,4 +1,4 @@
-
+# -*- coding: utf-8 -*-
 from plone.autoform.form import AutoExtensibleForm
 from plone.dexterity.interfaces import IDexterityFTI
 from plone.dexterity.utils import getAdditionalSchemata
diff --git a/plone/dexterity/browser/configure.zcml b/plone/dexterity/browser/configure.zcml
index 3c806d2..5dbf341 100644
--- a/plone/dexterity/browser/configure.zcml
+++ b/plone/dexterity/browser/configure.zcml
@@ -2,7 +2,7 @@
     xmlns="http://namespaces.zope.org/zope"
     xmlns:browser="http://namespaces.zope.org/browser"
     i18n_domain="plone.dexterity">
-  
+
     <!-- Standard view -->
     <browser:page
         for="..interfaces.IDexterityContent"
@@ -11,7 +11,7 @@
         template="item.pt"
         permission="zope2.View"
         />
-    
+
     <!-- Content core views -->
 
     <browser:page
@@ -32,7 +32,7 @@
 
     <!-- Standard IPublishTraverse adapter -->
     <adapter factory=".traversal.DexterityPublishTraverse" />
-    
+
     <!-- Standard add view and form - invoked from ++add++ traverser -->
     <adapter
         for="Products.CMFCore.interfaces.IFolderish
@@ -55,7 +55,7 @@
         class=".edit.DefaultEditView"
         permission="cmf.ModifyPortalContent"
         />
-  
+
     <!-- FTI add form -->
     <browser:page
         for="zope.browser.interfaces.IAdding"
@@ -64,14 +64,14 @@
         class=".fti.FTIAddView"
         permission="cmf.ManagePortal"
         />
-        
+
     <!-- Resources for icons -->
-    
+
     <browser:resource
         name="plone.dexterity.item.gif"
         file="icons/item_icon.gif"
         />
-    
+
     <browser:resource
         name="plone.dexterity.container.gif"
         file="icons/container_icon.gif"
@@ -80,6 +80,6 @@
     <browser:resource
         name="plone.dexterity.fti.gif"
         file="icons/typeinfo.gif"
-        />  
+        />
 
 </configure>
\ No newline at end of file
diff --git a/plone/dexterity/browser/containercontentcore.pt b/plone/dexterity/browser/containercontentcore.pt
index 911012a..f95d8e8 100644
--- a/plone/dexterity/browser/containercontentcore.pt
+++ b/plone/dexterity/browser/containercontentcore.pt
@@ -7,7 +7,7 @@
           <div tal:content="structure widget/render" />
       </div>
   </tal:block>
-          
+
   <fieldset tal:repeat="group view/groups"
             tal:attributes="id python:''.join((group.prefix, 'groups.', group.__name__)).replace('.', '-')">
       <legend tal:content="group/label" />
@@ -17,7 +17,7 @@
           <div tal:content="structure widget/render" />
       </div>
   </fieldset>
-  
+
   <fieldset id="folder-listing">
       <legend>Contents</legend>
       <tal:block define="listing_macro context/folder_listing/macros/listing">
diff --git a/plone/dexterity/browser/edit.py b/plone/dexterity/browser/edit.py
index deec09c..87013b6 100644
--- a/plone/dexterity/browser/edit.py
+++ b/plone/dexterity/browser/edit.py
@@ -1,25 +1,22 @@
-from zope.component import getUtility
-from zope.event import notify
-from zope.interface import classImplements
-
-from z3c.form import form, button
-from plone.z3cform import layout
-
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.i18n import MessageFactory as _
+# -*- coding: utf-8 -*-
+from Products.CMFCore.utils import getToolByName
+from Products.statusmessages.interfaces import IStatusMessage
+from plone.dexterity.browser.base import DexterityExtensibleForm
 from plone.dexterity.events import EditBegunEvent
 from plone.dexterity.events import EditCancelledEvent
 from plone.dexterity.events import EditFinishedEvent
-
-from plone.dexterity.browser.base import DexterityExtensibleForm
+from plone.dexterity.i18n import MessageFactory as _
 from plone.dexterity.interfaces import IDexterityEditForm
-
-from Products.CMFCore.utils import getToolByName
-from Products.statusmessages.interfaces import IStatusMessage
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.z3cform import layout
+from z3c.form import form, button
+from zope.component import getUtility
+from zope.event import notify
+from zope.interface import classImplements
 
 
 class DefaultEditForm(DexterityExtensibleForm, form.EditForm):
-    
+
     @button.buttonAndHandler(_(u'Save'), name='save')
     def handleApply(self, action):
         data, errors = self.extractData()
@@ -27,13 +24,17 @@ def handleApply(self, action):
             self.status = self.formErrorsMessage
             return
         self.applyChanges(data)
-        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), "info success")
+        IStatusMessage(self.request).addStatusMessage(
+            _(u"Changes saved"), "info success"
+        )
         self.request.response.redirect(self.nextURL())
         notify(EditFinishedEvent(self.context))
-    
+
     @button.buttonAndHandler(_(u'Cancel'), name='cancel')
     def handleCancel(self, action):
-        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"), "info")
+        IStatusMessage(self.request).addStatusMessage(
+            _(u"Edit cancelled"), "info"
+        )
         self.request.response.redirect(self.nextURL())
         notify(EditCancelledEvent(self.context))
 
@@ -41,39 +42,46 @@ def nextURL(self):
         view_url = self.context.absolute_url()
         portal_properties = getToolByName(self, 'portal_properties', None)
         if portal_properties is not None:
-            site_properties = getattr(portal_properties, 'site_properties', None)
+            site_properties = getattr(
+                portal_properties,
+                'site_properties',
+                None
+            )
             portal_type = self.portal_type
             if site_properties is not None and portal_type is not None:
-                use_view_action = site_properties.getProperty('typesUseViewActionInListings', ())
+                use_view_action = site_properties.getProperty(
+                    'typesUseViewActionInListings',
+                    ()
+                )
                 if portal_type in use_view_action:
                     view_url = view_url + '/view'
         return view_url
-    
+
     def update(self):
         self.portal_type = self.context.portal_type
         super(DefaultEditForm, self).update()
-        
+
         # fire the edit begun only if no action was executed
         if len(self.actions.executedActions) == 0:
             notify(EditBegunEvent(self.context))
 
     def updateActions(self):
         super(DefaultEditForm, self).updateActions()
-        
+
         if 'save' in self.actions:
             self.actions["save"].addClass("context")
-        
+
         if 'cancel' in self.actions:
             self.actions["cancel"].addClass("standalone")
 
     @property
     def fti(self):
         return getUtility(IDexterityFTI, name=self.portal_type)
-    
+
     @property
     def label(self):
         type_name = self.fti.Title()
         return _(u"Edit ${name}", mapping={'name': type_name})
-        
+
 DefaultEditView = layout.wrap_form(DefaultEditForm)
 classImplements(DefaultEditView, IDexterityEditForm)
diff --git a/plone/dexterity/browser/fti.pt b/plone/dexterity/browser/fti.pt
index 09a83a4..728200e 100644
--- a/plone/dexterity/browser/fti.pt
+++ b/plone/dexterity/browser/fti.pt
@@ -37,7 +37,7 @@
     
   </td>
   <td>
-   <input class="form-element" type="submit" name="submit_add" value="Add" /> 
+   <input class="form-element" type="submit" name="submit_add" value="Add" />
   </td>
  </tr>
 </table>
diff --git a/plone/dexterity/browser/fti.py b/plone/dexterity/browser/fti.py
index 30fc747..d2c0fbc 100644
--- a/plone/dexterity/browser/fti.py
+++ b/plone/dexterity/browser/fti.py
@@ -1,10 +1,11 @@
+# -*- coding: utf-8 -*-
 from Products.CMFCore.browser.typeinfo import FactoryTypeInformationAddView
-
 from plone.dexterity.fti import DexterityFTI
 
+
 class FTIAddView(FactoryTypeInformationAddView):
     """Add view for the Dexterity FTI type
     """
 
     klass = DexterityFTI
-    description = u'Factory Type Information for Dexterity Content Types'
\ No newline at end of file
+    description = u'Factory Type Information for Dexterity Content Types'
diff --git a/plone/dexterity/browser/item.pt b/plone/dexterity/browser/item.pt
index 137a8a2..b42a994 100644
--- a/plone/dexterity/browser/item.pt
+++ b/plone/dexterity/browser/item.pt
@@ -9,7 +9,7 @@
 
 <metal:main fill-slot="main">
 
-    <h1 class="documentFirstHeading" tal:content="context/Title" /> 
+    <h1 class="documentFirstHeading" tal:content="context/Title" />
 
     <p class="documentDescription" tal:content="context/Description" />
 
@@ -20,7 +20,7 @@
             <div tal:content="structure widget/render" />
         </div>
     </tal:block>
-            
+
     <fieldset tal:repeat="group view/groups"
               tal:attributes="id python:''.join((group.prefix, 'groups.', group.__name__)).replace('.', '-')">
         <legend tal:content="group/label" />
diff --git a/plone/dexterity/browser/itemcontentcore.pt b/plone/dexterity/browser/itemcontentcore.pt
index 6e453b6..2e07bdf 100644
--- a/plone/dexterity/browser/itemcontentcore.pt
+++ b/plone/dexterity/browser/itemcontentcore.pt
@@ -7,7 +7,7 @@
           <div tal:content="structure widget/render" />
       </div>
   </tal:block>
-          
+
   <fieldset tal:repeat="group view/groups"
             tal:attributes="id python:''.join((group.prefix, 'groups.', group.__name__)).replace('.', '-')">
       <legend tal:content="group/label" />
diff --git a/plone/dexterity/browser/traversal.py b/plone/dexterity/browser/traversal.py
index f677275..8340cbb 100644
--- a/plone/dexterity/browser/traversal.py
+++ b/plone/dexterity/browser/traversal.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 try:
     from repoze.zope2.publishtraverse import DefaultPublishTraverse
 except ImportError:
@@ -5,67 +6,70 @@
 
 from Acquisition import aq_inner, aq_parent
 from Acquisition.interfaces import IAcquirer
+from plone.dexterity.filerepresentation import FolderDataResource
+from plone.dexterity.interfaces import DAV_FOLDER_DATA_ID
+from plone.dexterity.interfaces import IDexterityContent
 from webdav.NullResource import NullResource
-
 from zope.component import adapts
-
 from zope.publisher.interfaces.browser import IBrowserRequest
 
-from plone.dexterity.interfaces import DAV_FOLDER_DATA_ID
-from plone.dexterity.interfaces import IDexterityContent
-
-from plone.dexterity.filerepresentation import FolderDataResource
 
 class DexterityPublishTraverse(DefaultPublishTraverse):
     """Override the default browser publisher to make WebDAV work for
     Dexterity objects.
-    
+
     In part, this works around certain problems with the ZPublisher that make
     DAV requests difficult, and in part it adds support for the '_data'
     pseudo-resource that is shown for folderish content items.
     """
-    
+
     adapts(IDexterityContent, IBrowserRequest)
-    
+
     def __init__(self, context, request):
         self.context = context
         self.request = request
-    
+
     def publishTraverse(self, request, name):
-        
+
         context = aq_inner(self.context)
-        
-        # If we are trying to traverse to the folder "body" pseudo-object 
+
+        # If we are trying to traverse to the folder "body" pseudo-object
         # returned by listDAVObjects(), return that immediately
 
-        if getattr(request, 'maybe_webdav_client', False) and name == DAV_FOLDER_DATA_ID:
-            return FolderDataResource(DAV_FOLDER_DATA_ID, context).__of__(context)
-        
-        defaultTraversal = super(DexterityPublishTraverse, self).publishTraverse(request, name)
-        
+        if getattr(request, 'maybe_webdav_client', False) \
+           and name == DAV_FOLDER_DATA_ID:
+            return FolderDataResource(
+                DAV_FOLDER_DATA_ID, context
+                ).__of__(context)
+
+        defaultTraversal = super(
+            DexterityPublishTraverse,
+            self).publishTraverse(request, name)
+
         # If this is a WebDAV PUT/PROPFIND/PROPPATCH request, don't acquire
         # things. If we did, we couldn't create a new object with PUT, for
         # example, because the acquired object would shadow the NullResource
-        
-        if (getattr(request, 'maybe_webdav_client', False)               and
-            request.get('REQUEST_METHOD', 'GET') not in ('GET', 'POST',) and
-            IAcquirer.providedBy(defaultTraversal)
-        ):
+
+        if getattr(request, 'maybe_webdav_client', False) \
+           and request.get('REQUEST_METHOD', 'GET') not in ('GET', 'POST',) \
+           and IAcquirer.providedBy(defaultTraversal):
             parent = aq_parent(aq_inner(defaultTraversal))
             if parent is not None and parent is not context:
-                return NullResource(self.context, name, request).__of__(self.context)
-        
+                return NullResource(
+                    self.context,
+                    name,
+                    request).__of__(self.context)
+
         return defaultTraversal
-    
+
     def browserDefault(self, request):
-        
-        # If this is not a WebDAV request, we don't want to give a 
+
+        # If this is not a WebDAV request, we don't want to give a
         # default view. The ZPublisher's WebDAV implementation doesn't
         # deal well with default views.
-        
-        if (getattr(request, 'maybe_webdav_client', False) and
-            request.get('REQUEST_METHOD', 'GET') not in ('GET', 'POST',)
-        ):
+
+        if getattr(request, 'maybe_webdav_client', False) and \
+           request.get('REQUEST_METHOD', 'GET') not in ('GET', 'POST',):
             return self.context, ()
-        
+
         return super(DexterityPublishTraverse, self).browserDefault(request)
diff --git a/plone/dexterity/browser/view.py b/plone/dexterity/browser/view.py
index ac33142..deed522 100644
--- a/plone/dexterity/browser/view.py
+++ b/plone/dexterity/browser/view.py
@@ -1,9 +1,8 @@
-from zope.component import getUtility
-
+# -*- coding: utf-8 -*-
 from plone.autoform.view import WidgetsView
-
 from plone.dexterity.interfaces import IDexterityFTI
 from plone.dexterity.utils import getAdditionalSchemata
+from zope.component import getUtility
 
 
 class DefaultView(WidgetsView):
diff --git a/plone/dexterity/configure.zcml b/plone/dexterity/configure.zcml
index 839b106..51f28db 100644
--- a/plone/dexterity/configure.zcml
+++ b/plone/dexterity/configure.zcml
@@ -14,29 +14,29 @@
     <include package="plone.rfc822" />
     <include package="plone.uuid" />
     <include package="plone.z3cform" />
-    
+
     <include package=".browser" />
     <include package=".fti" />
-    
+
     <!-- Re-index content when it's modified -->
     <subscriber
         for=".interfaces.IDexterityContent
              zope.lifecycleevent.interfaces.IObjectModifiedEvent"
         handler=".content.reindexOnModify"
         />
-    
+
     <!-- Support for dynamic schemata -->
-    
+
     <utility
         factory=".schema.DexteritySchemaPolicy"
         name="dexterity"
         />
-        
+
     <utility
         factory=".schema.SchemaModuleFactory"
         name="plone.dexterity.schema.generated"
         />
-                
+
     <!-- Schema cache -->
     <subscriber handler=".schema.invalidate_schema" />
 
@@ -51,7 +51,7 @@
         icon="plone.dexterity.item.gif"
         />
     <class class=".content.Item" />
-        
+
     <five:registerClass
         class=".content.Container"
         meta_type="Dexterity Container"
@@ -59,7 +59,7 @@
         icon="plone.dexterity.item.gif"
         />
     <class class=".content.Container" />
-        
+
     <!-- Register FTI class -->
     <five:registerClass
         class=".fti.DexterityFTI"
@@ -69,37 +69,37 @@
         icon="plone.dexterity.fti.gif"
         global="False"
         />
-        
+
     <!-- Register FTI add/remove/modify handlers -->
-    
+
     <subscriber
         for=".interfaces.IDexterityFTI
              zope.container.interfaces.IObjectAddedEvent"
         handler=".fti.ftiAdded"
         />
-        
+
     <subscriber
         for=".interfaces.IDexterityFTI
              zope.container.interfaces.IObjectRemovedEvent"
         handler=".fti.ftiRemoved"
         />
-        
+
     <subscriber
         for=".interfaces.IDexterityFTI
              zope.container.interfaces.IObjectMovedEvent"
         handler=".fti.ftiRenamed"
         />
-    
+
     <subscriber
         for=".interfaces.IDexterityFTI
              zope.lifecycleevent.interfaces.IObjectModifiedEvent"
         handler=".fti.ftiModified"
         />
-    
+
     <!-- File representation (FTP/WebDAV support) -->
     <adapter factory=".filerepresentation.DefaultDirectoryFactory" />
     <adapter factory=".filerepresentation.DefaultFileFactory" />
-    
+
     <adapter
         provides="zope.filerepresentation.interfaces.IRawReadFile"
         factory=".filerepresentation.DefaultReadFile"
diff --git a/plone/dexterity/content.py b/plone/dexterity/content.py
index f13f5bf..a9e046d 100644
--- a/plone/dexterity/content.py
+++ b/plone/dexterity/content.py
@@ -1,61 +1,48 @@
+# -*- coding: utf-8 -*-
+from AccessControl import ClassSecurityInfo
+from AccessControl import Permissions as acpermissions
+from AccessControl import getSecurityManager
 from Acquisition import Explicit, aq_base, aq_parent
 from DateTime import DateTime
-from zExceptions import Unauthorized
 from OFS.PropertyManager import PropertyManager
 from OFS.SimpleItem import SimpleItem
-
-from copy import deepcopy
-
-from zope.component import queryUtility
-
-from zope.interface import implements
-from zope.interface.declarations import Implements
-from zope.interface.declarations import implementedBy
-from zope.interface.declarations import getObjectSpecification
-from zope.interface.declarations import ObjectSpecificationDescriptor
-
-from zope.schema.interfaces import IContextAwareDefaultFactory
-
-from zope.security.interfaces import IPermission
-
-from zope.annotation import IAttributeAnnotatable
-
-from plone.dexterity.interfaces import IDexterityContent
-from plone.dexterity.interfaces import IDexterityItem
-from plone.dexterity.interfaces import IDexterityContainer
-
-from plone.dexterity.schema import SCHEMA_CACHE
-
-from zope.container.contained import Contained
-
-import AccessControl.Permissions
-from AccessControl import ClassSecurityInfo
-from AccessControl import getSecurityManager
-
 from Products.CMFCore import permissions
+from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Products.CMFCore.PortalContent import PortalContent
 from Products.CMFCore.PortalFolder import PortalFolderBase
-from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
-from Products.CMFPlone.interfaces import IConstrainTypes
-from Products.CMFCore.interfaces import ITypeInformation
 from Products.CMFCore.interfaces import ICatalogableDublinCore
 from Products.CMFCore.interfaces import IDublinCore
 from Products.CMFCore.interfaces import IMutableDublinCore
-
+from Products.CMFCore.interfaces import ITypeInformation
 from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin
-
-from plone.folder.ordered import CMFOrderedBTreeFolderBase
-from plone.uuid.interfaces import IAttributeUUID
-from plone.uuid.interfaces import IUUID
-
+from Products.CMFPlone.interfaces import IConstrainTypes
+from copy import deepcopy
 from plone.autoform.interfaces import READ_PERMISSIONS_KEY
-from plone.supermodel.utils import mergedTaggedValueDict
-
-from plone.dexterity.filerepresentation import DAVResourceMixin, DAVCollectionMixin
+from plone.dexterity.filerepresentation import DAVCollectionMixin
+from plone.dexterity.filerepresentation import DAVResourceMixin
+from plone.dexterity.interfaces import IDexterityContainer
+from plone.dexterity.interfaces import IDexterityContent
 from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.interfaces import IDexterityItem
+from plone.dexterity.schema import SCHEMA_CACHE
 from plone.dexterity.utils import datify
-from plone.dexterity.utils import safe_utf8
 from plone.dexterity.utils import safe_unicode
+from plone.dexterity.utils import safe_utf8
+from plone.folder.ordered import CMFOrderedBTreeFolderBase
+from plone.supermodel.utils import mergedTaggedValueDict
+from plone.uuid.interfaces import IAttributeUUID
+from plone.uuid.interfaces import IUUID
+from zExceptions import Unauthorized
+from zope.annotation import IAttributeAnnotatable
+from zope.component import queryUtility
+from zope.container.contained import Contained
+from zope.interface import implements
+from zope.interface.declarations import Implements
+from zope.interface.declarations import ObjectSpecificationDescriptor
+from zope.interface.declarations import getObjectSpecification
+from zope.interface.declarations import implementedBy
+from zope.schema.interfaces import IContextAwareDefaultFactory
+from zope.security.interfaces import IPermission
 
 _marker = object()
 _zone = DateTime().timezone()
@@ -152,7 +139,9 @@ def __call__(self, name, value):
 
         permission = queryUtility(IPermission, name=info[name])
         if permission is not None:
-            return getSecurityManager().checkPermission(permission.title, context)
+            return getSecurityManager().checkPermission(
+                permission.title, context
+            )
 
         return 0
 
@@ -167,6 +156,37 @@ def _get_schema(self, inst):
 
 
 class PasteBehaviourMixin(object):
+
+    def _notifyOfCopyTo(self, container, op=0):
+        """Keep Archetypes' reference info internally when op == 1 (move)
+        because in those cases we need to keep Archetypes' refeferences.
+
+        This is only required to support legacy Archetypes' references related
+        to content within Dexterity container objects.
+        """
+        # AT BaseObject does this to prevent removing AT refs on object move
+        # See: Products.Archetypes.Referenceable.Referenceable._notifyOfCopyTo
+
+        # This isn't really safe for concurrent usage, but the
+        # worse case is not that bad and could be fixed with a reindex
+        # on the archetype tool:
+        if op == 1:
+            self._v_cp_refs = 1
+            self._v_is_cp = 0
+        if op == 0:
+            self._v_cp_refs = 0
+            self._v_is_cp = 1
+
+        # AT BaseFolderMixin does this to propagate the notify to its children
+        # See: Products.Archetypes.BaseFolder.BaseFolderMixin._notifyOfCopyTo
+
+        if isinstance(self, PortalFolderBase):
+            for child in self.objectValues():
+                try:
+                    child._notifyOfCopyTo(self, op)
+                except AttributeError:
+                    pass
+
     def _verifyObjectPaste(self, obj, validate_src=True):
         # Extend the paste checks from OFS.CopySupport.CopyContainer
         # (permission checks) and
@@ -179,10 +199,13 @@ def _verifyObjectPaste(self, obj, validate_src=True):
             if portal_type:
                 fti = queryUtility(ITypeInformation, name=portal_type)
                 if fti is not None and not fti.isConstructionAllowed(self):
-                    raise ValueError('You can not add the copied content here.')
+                    raise ValueError(
+                        'You can not add the copied content here.'
+                    )
 
 
-class DexterityContent(DAVResourceMixin, PortalContent, PropertyManager, Contained):
+class DexterityContent(DAVResourceMixin, PortalContent, PropertyManager,
+                       Contained):
     """Base class for Dexterity content
     """
     implements(
@@ -283,9 +306,10 @@ def __getattr__(self, name):
 
     def _get__name__(self):
         return unicode(self.id)
+
     def _set__name__(self, value):
         if isinstance(value, unicode):
-            value = str(value) # may throw, but that's OK - id must be ASCII
+            value = str(value)  # may throw, but that's OK - id must be ASCII
         self.id = value
     __name__ = property(_get__name__, _set__name__)
 
@@ -586,7 +610,7 @@ class Container(
 
     security = ClassSecurityInfo()
     security.declareProtected(
-        AccessControl.Permissions.copy_or_move, 'manage_copyObjects')
+        acpermissions.copy_or_move, 'manage_copyObjects')
     security.declareProtected(
         permissions.ModifyPortalContent, 'manage_cutObjects')
     security.declareProtected(
@@ -633,9 +657,13 @@ def manage_delObjects(self, ids=None, REQUEST=None):
             ids = [ids]
         for id in ids:
             item = self._getOb(id)
-            if not getSecurityManager().checkPermission(permissions.DeleteObjects, item):
-                raise Unauthorized, (
-                    "Do not have permissions to remove this object")
+            if not getSecurityManager().checkPermission(
+                permissions.DeleteObjects,
+                item
+            ):
+                raise Unauthorized(
+                    "Do not have permissions to remove this object"
+                )
         return super(Container, self).manage_delObjects(ids, REQUEST=REQUEST)
 
     # override PortalFolder's allowedContentTypes to respect IConstrainTypes
@@ -657,10 +685,19 @@ def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
         """
         constrains = IConstrainTypes(self, None)
 
-        if constrains and not type_name in [fti.getId() for fti in constrains.allowedContentTypes()]:
-            raise ValueError('Subobject type disallowed by IConstrainTypes adapter: %s' % type_name)
-
-        return super(Container, self).invokeFactory(type_name, id, RESPONSE, *args, **kw)
+        if constrains:
+            allowed_ids = [
+                fti.getId() for fti in constrains.allowedContentTypes()
+            ]
+            if type_name not in allowed_ids:
+                raise ValueError(
+                    'Subobject type disallowed by IConstrainTypes adapter: %s'
+                    % type_name
+                )
+
+        return super(Container, self).invokeFactory(
+            type_name, id, RESPONSE, *args, **kw
+        )
 
 
 def reindexOnModify(content, event):
diff --git a/plone/dexterity/exportimport.py b/plone/dexterity/exportimport.py
index 675aa6e..7540067 100644
--- a/plone/dexterity/exportimport.py
+++ b/plone/dexterity/exportimport.py
@@ -1,18 +1,17 @@
-from csv import reader
-from csv import writer
-from StringIO import StringIO
-
-from zope.component import queryAdapter
-from zope.interface import implements
-
-from Products.GenericSetup.content import _globtest
+# -*- coding: utf-8 -*-
 from Products.GenericSetup.content import FauxDAVRequest
 from Products.GenericSetup.content import FauxDAVResponse
 from Products.GenericSetup.content import FolderishExporterImporter
+from Products.GenericSetup.content import _globtest
 from Products.GenericSetup.interfaces import IContentFactoryName
 from Products.GenericSetup.interfaces import IFilesystemExporter
 from Products.GenericSetup.interfaces import IFilesystemImporter
 from Products.GenericSetup.utils import _getDottedName
+from StringIO import StringIO
+from csv import reader
+from csv import writer
+from zope.component import queryAdapter
+from zope.interface import implements
 
 
 class DexterityContentExporterImporter(FolderishExporterImporter):
diff --git a/plone/dexterity/factory.py b/plone/dexterity/factory.py
index 3f3eb74..cacc15d 100644
--- a/plone/dexterity/factory.py
+++ b/plone/dexterity/factory.py
@@ -1,22 +1,20 @@
+# -*- coding: utf-8 -*-
 from persistent import Persistent
-
-from zope.interface import implements
-from zope.interface.declarations import Implements
-
-from zope.component import getUtility
-from zope.component.factory import Factory
-
 from plone.dexterity.interfaces import IDexterityFTI
 from plone.dexterity.interfaces import IDexterityFactory
-
 from plone.dexterity.utils import resolveDottedName
+from zope.component import getUtility
+from zope.component.factory import Factory
+from zope.interface import implements
+from zope.interface.declarations import Implements
+
 
 class DexterityFactory(Persistent, Factory):
-    """A factory for Dexterity content. 
+    """A factory for Dexterity content.
     """
-    
+
     implements(IDexterityFactory)
-    
+
     def __init__(self, portal_type):
         self.portal_type = portal_type
 
@@ -32,16 +30,22 @@ def description(self):
 
     def __call__(self, *args, **kw):
         fti = getUtility(IDexterityFTI, name=self.portal_type)
-        
+
         klass = resolveDottedName(fti.klass)
         if klass is None or not callable(klass):
-            raise ValueError("Content class %s set for type %s is not valid" % (fti.klass, self.portal_type))
-        
+            raise ValueError(
+                "Content class %s set for type %s is not valid" %
+                (fti.klass, self.portal_type)
+            )
+
         try:
             obj = klass(*args, **kw)
         except TypeError, e:
-            raise ValueError("Error whilst constructing content for %s using class %s: %s" % (self.portal_type, fti.klass, str(e)))
-        
+            raise ValueError(
+                "Error whilst constructing content for %s using class %s: %s"
+                % (self.portal_type, fti.klass, str(e))
+            )
+
         # Set portal_type if not set, but avoid creating an instance variable
         # if possible
         if getattr(obj, 'portal_type', '') != self.portal_type:
@@ -56,4 +60,4 @@ def getInterfaces(self):
         return spec
 
     def __repr__(self):
-        return '<%s for %s>' %(self.__class__.__name__, self.portal_type)
+        return '<%s for %s>' % (self.__class__.__name__, self.portal_type)
diff --git a/plone/dexterity/filerepresentation.py b/plone/dexterity/filerepresentation.py
index 7eb322e..cfa1d49 100644
--- a/plone/dexterity/filerepresentation.py
+++ b/plone/dexterity/filerepresentation.py
@@ -1,55 +1,47 @@
-import tempfile
-
-# capitalised for Python 2.4 compatibility
-from email.Generator import Generator
-from email.Parser import FeedParser
-from email.Message import Message
-
-from zope.interface import implements
-from zope.component import adapts
-from zope.schema import getFieldsInOrder
-from zope.event import notify
-from zope.lifecycleevent import modified, ObjectCreatedEvent
-
-from zope.interface.interfaces import IInterface
-from zope.size.interfaces import ISized
-from zope.component import createObject
-
+# -*- coding: utf-8 -*-
 from Acquisition import aq_base, Implicit
-from zExceptions import Unauthorized, MethodNotAllowed
-from webdav.Resource import Resource
-from ZPublisher.Iterators import IStreamIterator
 from Products.CMFCore.utils import getToolByName
-
-from zope.filerepresentation.interfaces import IRawReadFile
-from zope.filerepresentation.interfaces import IRawWriteFile
-
-from zope.filerepresentation.interfaces import IDirectoryFactory
-from zope.filerepresentation.interfaces import IFileFactory
-
-from plone.rfc822.interfaces import IPrimaryField
-from plone.rfc822 import constructMessageFromSchemata
-from plone.rfc822 import initializeObjectFromSchemata
-
-from plone.dexterity.interfaces import IDexterityContent
-from plone.dexterity.interfaces import IDexterityContainer
-
+from ZPublisher.Iterators import IStreamIterator
+from email.generator import Generator
+from email.message import Message
+from email.parser import FeedParser
 from plone.dexterity.interfaces import DAV_FOLDER_DATA_ID
-
+from plone.dexterity.interfaces import IDexterityContainer
+from plone.dexterity.interfaces import IDexterityContent
 from plone.dexterity.utils import iterSchemata
 from plone.memoize.instance import memoize
+from plone.rfc822 import constructMessageFromSchemata
+from plone.rfc822 import initializeObjectFromSchemata
+from plone.rfc822.interfaces import IPrimaryField
+from webdav.Resource import Resource
+from zExceptions import MethodNotAllowed
+from zExceptions import Unauthorized
+from zope.component import adapts
+from zope.component import createObject
+from zope.event import notify
+from zope.filerepresentation.interfaces import IDirectoryFactory
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IRawReadFile
+from zope.filerepresentation.interfaces import IRawWriteFile
+from zope.interface import implements
+from zope.interface.interfaces import IInterface
+from zope.lifecycleevent import modified, ObjectCreatedEvent
+from zope.schema import getFieldsInOrder
+from zope.size.interfaces import ISized
+import tempfile
+
 
 class DAVResourceMixin(object):
     """Mixin class for WebDAV resource support.
-    
+
     The main purpose of this class is to implement the Zope 2 WebDAV API to
     delegate to more granular adapters.
     """
-    
+
     def get_size(self):
         """Get the size of the content item in bytes. Used both in folder
         listings and in DAV PROPFIND requests.
-        
+
         The default implementation delegates to an ISized adapter and calls
         getSizeForSorting(). This returns a tuple (unit, value). If the unit
         is 'bytes', the value is returned, otherwise the size is 0.
@@ -61,7 +53,7 @@ def get_size(self):
         if unit == 'bytes':
             return size
         return 0
-    
+
     def content_type(self):
         """Return the content type (MIME type) of the tiem
         """
@@ -69,114 +61,122 @@ def content_type(self):
         if readFile is None:
             return None
         return readFile.mimeType
-    
+
     def Format(self):
         """Return the content type (MIME type) of the item
         """
         return self.content_type()
-    
+
     def manage_DAVget(self):
         """Get the body of the content item in a WebDAV response.
         """
         return self.manage_FTPget()
-    
+
     def manage_FTPget(self, REQUEST=None, RESPONSE=None):
         """Return the body of the content item in an FTP or WebDAV response.
-        
+
         This adapts self to IRawReadFile(), which is then returned as an
         iterator. The adapter should provide IStreamIterator.
         """
         reader = IRawReadFile(self, None)
         if reader is None:
             return ''
-        
+
         request = REQUEST is not None and REQUEST or self.REQUEST
         response = RESPONSE is not None and RESPONSE or request.response
-        
+
         mimeType = reader.mimeType
         encoding = reader.encoding
-        
+
         if mimeType is not None:
             if encoding is not None:
-                response.setHeader('Content-Type', '%s; charset="%s"' % (mimeType, encoding,))
+                response.setHeader(
+                    'Content-Type', '%s; charset="%s"' % (mimeType, encoding,)
+                )
             else:
                 response.setHeader('Content-Type', mimeType)
-        
+
         size = reader.size()
         if size is not None:
             response.setHeader('Content-Length', str(size))
-        
+
         # if the reader is an iterator that the publisher can handle, return
         # it as-is. Otherwise, read the full contents
-        
-        if ((IInterface.providedBy(IStreamIterator) and IStreamIterator.providedBy(reader))
-         or (not IInterface.providedBy(IStreamIterator) and IStreamIterator.isImplementedBy(reader))
-        ):
+        is_iface = IInterface.providedBy(IStreamIterator)
+        if is_iface and IStreamIterator.providedBy(reader):
             return reader
-        else:
-            return reader.read()
-    
+        if not is_iface and IStreamIterator.isImplementedBy(reader):
+            return reader
+
+        return reader.read()
+
     def PUT(self, REQUEST=None, RESPONSE=None):
         """WebDAV method to replace self with a new resource. This is also
         used when initialising an object just created from a NullResource.
-        
+
         This will look up an IRawWriteFile adapter on self and write to it,
         line-by-line, from the request body.
         """
         request = REQUEST is not None and REQUEST or self.REQUEST
         response = RESPONSE is not None and RESPONSE or request.response
-        
+
         self.dav__init(request, response)
         self.dav__simpleifhandler(request, response, refresh=1)
-        
+
         infile = request.get('BODYFILE', None)
         if infile is None:
-            raise MethodNotAllowed("Cannot complete PUT request: No BODYFILE in request")
-        
+            raise MethodNotAllowed(
+                "Cannot complete PUT request: No BODYFILE in request"
+            )
+
         writer = IRawWriteFile(self, None)
         if writer is None:
-            raise MethodNotAllowed("Cannot complete PUT request: No IRawWriteFile adapter found")
-        
+            raise MethodNotAllowed(
+                "Cannot complete PUT request: No IRawWriteFile adapter found"
+            )
+
         contentTypeHeader = request.get_header('content-type', None)
-        
+
         if contentTypeHeader is not None:
             msg = Message()
             msg['Content-Type'] = contentTypeHeader
-            
+
             mimeType = msg.get_content_type()
             if mimeType is not None:
                 writer.mimeType = mimeType
-            
+
             charset = msg.get_param('charset')
             if charset is not None:
                 writer.encoding = charset
-        
+
         try:
             for chunk in infile:
                 writer.write(chunk)
         finally:
             writer.close()
-        
+
         modified(self)
         return response
 
 
 class DAVCollectionMixin(DAVResourceMixin):
     """Mixin class for WebDAV collection support.
-    
+
     The main purpose of this class is to implement the Zope 2 WebDAV API to
     delegate to more granular adapters.
     """
-    
+
     def MKCOL_handler(self, id, REQUEST=None, RESPONSE=None):
         """Handle "make collection" by delegating to an IDirectoryFactory
         adapter.
         """
         factory = IDirectoryFactory(self, None)
         if factory is None:
-            raise MethodNotAllowed("Cannot create collection: No IDirectoryFactory adapter found")
+            raise MethodNotAllowed(
+                "Cannot create collection: No IDirectoryFactory adapter found"
+            )
         factory(id)
-    
+
     def PUT_factory(self, name, contentType, body):
         """Handle constructing a new object upon a PUT request by delegating
         to an IFileFactory adapter
@@ -185,10 +185,10 @@ def PUT_factory(self, name, contentType, body):
         if factory is None:
             return None
         return factory(name, contentType, body)
-    
+
     def listDAVObjects(self):
         """Return objects for WebDAV folder listings.
-        
+
         We add a non-folderish pseudo object which contains the "body" data
         for this container.
         """
@@ -197,7 +197,7 @@ def listDAVObjects(self):
             parentList = []
         else:
             parentList = list(parentList)
-        
+
         # insert the FolderDataResource pseudo child
         faux = FolderDataResource(DAV_FOLDER_DATA_ID, self).__of__(self)
         parentList.insert(0, faux)
@@ -207,28 +207,28 @@ def listDAVObjects(self):
 class FolderDataResource(Implicit, Resource):
     """This object is a proxy which is created on-demand during traversal,
     to allow access to the "file-like" aspects of a container type.
-    
+
     When a Container object is listed via WebDAV, the first item in the folder
     listing is an instance of this class with an id of '_data'. When
     requested, the default Dexterity IPublishTraverse adapter will also return
     an instance (the instances are non-persistent). A GET, PUT, HEAD, LOCK,
-    UNLOCK, PROPFIND or PROPPATCH request against this resource will be 
+    UNLOCK, PROPFIND or PROPPATCH request against this resource will be
     treated as if it were a request against the parent object, treating it
     as a resource (file) rather than a collection (folder).
     """
-    
+
     __dav_collection__ = 0
-    
+
     def __init__(self, name, parent):
         self.__dict__.update({'__parent__': parent, '__name__': name})
-    
+
     # We need to proxy certain things to the parent for getting and setting
     # of property sheet values to work.
-    # 
+    #
     # XXX: A better approach may be to define a custom PropertySheets type
     # with some kind of wrapping property sheet that redefines v_self() to
     # be the container.
-    
+
     def __getattr__(self, name):
         """Fall back on parent for certain things, even if we're aq_base'd.
         This makes propertysheet access work.
@@ -236,7 +236,7 @@ def __getattr__(self, name):
         if hasattr(self.__parent__.aq_base, name):
             return getattr(self.__parent__, name)
         raise AttributeError(name)
-    
+
     def __setattr__(self, name, value):
         """Set certain attributes on the parent
         """
@@ -246,101 +246,110 @@ def __setattr__(self, name, value):
             setattr(self.__parent__, name, value)
         else:
             object.__setattr__(self, name, value)
-    
+
     @property
     def _properties(self):
         return self.__parent__._properties
 
     @_properties.setter
     def _properties(self, value):
-        self.__parent__._properties = value        
-    
+        self.__parent__._properties = value
+
     @property
     def id(self):
         return self.__name__
-    
+
     def getId(self):
         """Get id for traveral purposes
         """
         return self.__name__
-        
+
     def HEAD(self, REQUEST, RESPONSE):
         """HEAD request: use the Resource algorithm on the data of the
         parent.
         """
         return Resource.HEAD(self.__parent__, REQUEST, RESPONSE)
-    
+
     def OPTIONS(self, REQUEST, RESPONSE):
         """OPTIONS request: delegate to parent
         """
         return self.__parent__.OPTIONS(REQUEST, RESPONSE)
-    
+
     def TRACE(self, REQUEST, RESPONSE):
         """TRACE request: delegate to parent
         """
         return self.__parent__.TRACE(REQUEST, RESPONSE)
-    
+
     def PROPFIND(self, REQUEST, RESPONSE):
         """PROPFIND request: use Resource algorithm on self, so that we do
         not appear as a folder.
-        
+
         Certain things may be acquired, notably .propertysheets
         """
         return super(FolderDataResource, self).PROPFIND(REQUEST, RESPONSE)
-    
+
     def PROPPATCH(self, REQUEST, RESPONSE):
         """PROPPATCH request: Use Resource algorithm on self, so that we do
         not appear as a folder.
-        
+
         Certain things may be acquired, notably .propertysheets
         """
         return super(FolderDataResource, self).PROPPATCH(REQUEST, RESPONSE)
-    
+
     def LOCK(self, REQUEST, RESPONSE):
         """LOCK request: delegate to parent
         """
         return self.__parent__.LOCK(REQUEST, RESPONSE)
-    
+
     def UNLOCK(self, REQUEST, RESPONSE):
         """UNLOCK request: delegate to parent
         """
         return self.__parent__.UNLOCK(REQUEST, RESPONSE)
-    
+
     def PUT(self, REQUEST, RESPONSE):
         """PUT request: delegate to parent
         """
         return self.__parent__.PUT(REQUEST, RESPONSE)
-    
+
     def MKCOL(self, REQUEST, RESPONSE):
         """MKCOL request: not allowed
         """
-        raise MethodNotAllowed('Cannot create a collection inside a folder data: try at the folder level instead')
-    
+        raise MethodNotAllowed(
+            'Cannot create a collection inside a folder data: try at the '
+            'folder level instead'
+        )
+
     def DELETE(self, REQUEST, RESPONSE):
         """DELETE request: not allowed
         """
-        raise MethodNotAllowed('Cannot delete folder data: delete folder instead')
-    
+        raise MethodNotAllowed(
+            'Cannot delete folder data: delete folder instead'
+        )
+
     def COPY(self, REQUEST, RESPONSE):
         """COPY request: not allowed
         """
-        raise MethodNotAllowed('Cannot copy folder data: copy the folder instead')
-        
+        raise MethodNotAllowed(
+            'Cannot copy folder data: copy the folder instead'
+        )
+
     def MOVE(self, REQUEST, RESPONSE):
         """MOVE request: not allowed
         """
-        raise MethodNotAllowed('Cannot move folder data: move the folder instead')
-    
+        raise MethodNotAllowed(
+            'Cannot move folder data: move the folder instead'
+        )
+
     def manage_DAVget(self):
         """DAV content access: delete to manage_FTPget()
         """
         return self.__parent__.manage_DAVget()
-    
+
     def manage_FTPget(self):
         """FTP access: delegate to parent
         """
         return self.__parent__.manage_FTPget()
-    
+
     def listDAVObjects(self):
         """DAV object listing: return nothing
         """
@@ -351,39 +360,39 @@ class StringStreamIterator(object):
     """Simple stream iterator to allow efficient data streaming.
     """
     implements(IStreamIterator)
-    
-    def __init__(self, data, size=None, chunk=1<<16):
+
+    def __init__(self, data, size=None, chunk=1 << 16):
         """Consume data (a str) into a temporary file and prepare streaming.
-        
+
         size is the length of the data. If not given, the length of the data
         string is used.
-        
+
         chunk is the chunk size for the iterator
         """
         f = tempfile.TemporaryFile(mode='w+b')
         f.write(data)
-        
+
         if size is not None:
             assert size == f.tell(), 'Size argument does not match data length'
         else:
             size = f.tell()
-        
+
         f.seek(0)
-        
+
         self.file = f
         self.size = size
         self.chunk = chunk
-    
+
     def __iter__(self):
         return self
-    
+
     def next(self):
         data = self.file.read(self.chunk)
         if not data:
             self.file.close()
             raise StopIteration
         return data
-    
+
     def __len__(self):
         return self.size
 
@@ -391,16 +400,16 @@ def __len__(self):
 class DefaultDirectoryFactory(object):
     """Default directory factory, invoked when an FTP/WebDAV operation
     attempts to create a new folder via a MKCOL request.
-    
+
     The default implementation simply calls manage_addFolder().
     """
-    
+
     implements(IDirectoryFactory)
     adapts(IDexterityContainer)
-    
+
     def __init__(self, context):
         self.context = context
-    
+
     def __call__(self, name):
         self.context.manage_addFolder(name)
 
@@ -408,40 +417,40 @@ def __call__(self, name):
 class DefaultFileFactory(object):
     """Default file factory, invoked when an FTP/WebDAV operation
     attempts to create a new resource via a PUT request.
-    
+
     The default implementation uses the content_type_registry to find a
     type to add, and then creates an instance using the portal_types
     tool.
     """
-    
+
     implements(IFileFactory)
     adapts(IDexterityContainer)
-    
+
     def __init__(self, context):
         self.context = context
-    
+
     def __call__(self, name, contentType, data):
-        
+
         # Deal with Finder cruft
         if name == '.DS_Store':
             raise Unauthorized("Refusing to store Mac OS X resource forks")
         elif name.startswith('._'):
             raise Unauthorized("Refusing to store Mac OS X resource forks")
-        
+
         registry = getToolByName(self.context, 'content_type_registry', None)
         if registry is None:
-            return None # fall back on default
-        
+            return None  # fall back on default
+
         typeObjectName = registry.findTypeName(name, contentType, data)
         if typeObjectName is None:
-            return # fall back on default
-        
+            return  # fall back on default
+
         typesTool = getToolByName(self.context, 'portal_types')
-        
+
         targetType = typesTool.getTypeInfo(typeObjectName)
         if targetType is None:
-            return # fall back on default
-        
+            return  # fall back on default
+
         # There are two possibilities here: either we have a new-style
         # IFactory utility, in which case all is good. We can call the
         # factory and return the object. Or, we have an old style factory
@@ -450,58 +459,65 @@ def __call__(self, name, contentType, data):
         # object, before re-creating it immediately afterwards in
         # NullResource.PUT(). Naturally this sucks. At least, let's do the
         # sane thing for content with new-style factories.
-        
-        if targetType.product: # boo :(
-            
+
+        if targetType.product:  # boo :(
+
             newName = self.context.invokeFactory(typeObjectName, name)
             obj = aq_base(self.context._getOb(newName))
             self.context._delObject(newName)
             return obj
-            
-        else: # yay
-            
+
+        else:  # yay
+
             contextType = typesTool.getTypeInfo(self.context)
             if contextType is not None:
                 if not contextType.allowType(typeObjectName):
-                    raise Unauthorized("Creating a %s object here is not allowed" % typeObjectName)
-            
+                    raise Unauthorized(
+                        "Creating a %s object here is not allowed" %
+                        typeObjectName
+                    )
+
             if not targetType.isConstructionAllowed(self.context):
-                raise Unauthorized("Creating a %s object here is not allowed" % typeObjectName)
-            
+                raise Unauthorized(
+                    "Creating a %s object here is not allowed" %
+                    typeObjectName
+                )
+
             obj = createObject(targetType.factory)
-            
+
             if hasattr(obj, '_setPortalTypeName'):
                 obj._setPortalTypeName(targetType.getId())
-            
+
             # we fire this event here, because NullResource.PUT will now go
             # and set the object on the parent. The correct sequence of
             # events is object created -> object added. In this case, we'll
             # get object created -> object added -> object modified.
             notify(ObjectCreatedEvent(obj))
-        
+
         return obj
 
+
 class ReadFileBase(object):
     """Convenience base class for read files which delegate to another stream
     type (e.g. a temporary file or StringIO)
-    
+
     Override _getStream() and any required methods.
     """
-    
+
     implements(IRawReadFile)
-    
+
     def __init__(self, context):
         self.context = context
         self._size = 0
-    
+
     mimeType = None
     encoding = 'utf-8'
     name = None
-    
+
     @property
     def closed(self):
         return self._getStream().closed
-    
+
     def size(self):
         stream = self._getStream()
         pos = stream.tell()
@@ -509,64 +525,64 @@ def size(self):
         size = stream.tell()
         stream.seek(pos)
         return size
-    
+
     def seek(self, offset, whence=None):
         if whence is not None:
             self._getStream().seek(offset, whence)
         else:
             self._getStream().seek(offset)
-    
+
     def tell(self):
         return self._getStream().tell()
-    
+
     def close(self):
         self._getStream().close()
-    
+
     def read(self, size=None):
         if size is not None:
             return self._getStream().read(size)
         else:
             return self._getStream().read()
-    
+
     def readline(self, size=None):
         if size is None:
             return self._getStream().readline()
         else:
             return self._getStream().readline(size)
-    
+
     def readlines(self, sizehint=None):
         if sizehint is None:
             return self._getStream().readlines()
         else:
             return self._getStream().readlines(sizehint)
-    
+
     def __iter__(self):
         return self
-    
+
     def next(self):
         return self._getStream().next()
-    
+
     def _getStream(self):
         raise NotImplementedError("Subclass and override this _getStream()")
 
 
 class DefaultReadFile(ReadFileBase):
     """IRawReadFile adapter for Dexterity objects.
-    
+
     Uses RFC822 marshaler.
-    
+
     This is also marked as an IStreamIterator, which means that it is safe
     to return it to the publisher directly. In particular, the size() method
     will return an accurate file size.
     """
-    
+
     implements(IStreamIterator)
     adapts(IDexterityContent)
-    
+
     def __init__(self, context):
         self.context = context
         self._haveMessage = False
-    
+
     @property
     def mimeType(self):
         if not self._haveMessage:
@@ -585,33 +601,36 @@ def mimeType(self):
             return 'text/plain'
         else:
             return 'message/rfc822'
-    
+
     @property
     def encoding(self):
         return self._getMessage().get_charset() or 'utf-8'
-    
+
     @property
     def name(self):
         return self._getMessage().get_filename(None)
-    
+
     def size(self):
         # construct the stream if necessary
         self._getStream()
         return self._size
-    
+
     # internal helper methods
-    
+
     @memoize
     def _getMessage(self):
         """Construct message on demand
         """
-        message = constructMessageFromSchemata(self.context, iterSchemata(self.context))
-        
+        message = constructMessageFromSchemata(
+            self.context,
+            iterSchemata(self.context)
+        )
+
         # Store the portal type in a header, to allow it to be identifed later
         message['Portal-Type'] = self.context.portal_type
-        
+
         return message
-    
+
     @memoize
     def _getStream(self):
         # We write to a TemporayFile instead of a StringIO because we don't
@@ -630,49 +649,49 @@ def _getStream(self):
 class WriteFileBase(object):
     """Convenience base class for write files which delegate to another
     stream, e.g. a file or StringIO.
-    
+
     Implement _getStream() and override any methods required.
     """
-    
+
     implements(IRawWriteFile)
-    
+
     def __init__(self, context):
         self.context = context
-        
+
         self._closed = False
         self._written = 0
-        
+
     mimeType = None
     encoding = 'utf-8'
     name = None
-    
+
     @property
     def closed(self):
         return self._closed
-    
+
     def seek(self, offset, whence=None):
         if whence is not None:
             self._getStream().seek(offset, whence)
         else:
             self._getStream().seek(offset)
-    
+
     def tell(self):
         return self._getStream().tell()
-    
+
     def close(self):
         self._closed = True
         self._getStream().close()
-    
+
     def write(self, data):
         if self._closed:
             raise ValueError("File is closed")
         self._written += len(data)
         self._getStream().write(data)
-        
+
     def writelines(self, sequence):
         for item in sequence:
             self.write(item)
-    
+
     def truncate(self, size=None):
         if self._closed:
             raise ValueError("File is closed")
@@ -681,26 +700,26 @@ def truncate(self, size=None):
         else:
             self._getStream().truncate()
         self._written = 0
-    
+
     def flush(self):
         self._getStream().flush()
-    
+
     def _getStream(self):
         raise NotImplementedError("Subclass and override this _getStream()")
 
 
 class DefaultWriteFile(object):
     """IRawWriteFile file adapter for Dexterity objects.
-    
+
     Uses RFC822 marshaler.
     """
-    
+
     implements(IRawWriteFile)
     adapts(IDexterityContent)
-    
+
     def __init__(self, context):
         self.context = context
-        
+
         self._mimeType = None
         self._encoding = 'utf-8'
         self._closed = False
@@ -708,7 +727,7 @@ def __init__(self, context):
         self._written = 0
         self._parser = FeedParser()
         self._message = None
-    
+
     @property
     def mimeType(self):
         if self._message is None:
@@ -717,64 +736,71 @@ def mimeType(self):
             return 'text/plain'
         else:
             return 'message/rfc822'
-    
+
     @mimeType.setter
     def mimeType(self, value):
         self._mimeType = value
-    
+
     @property
     def encoding(self):
         if self._message is not None:
             return self._message.get_charset() or self._encoding
         return self._encoding
-    
+
     @encoding.setter
     def encoding(self, value):
         self._encoding = value
-    
+
     @property
     def closed(self):
         return self._closed
-    
+
     @property
     def name(self):
         if self._message is not None:
             return self._message.get_filename(self._name)
         return self._name
-    
+
     @name.setter
     def name(self, value):
         self._name = value
-    
+
     def seek(self, offset, whence=None):
         raise NotImplementedError("Seeking is not supported")
-    
+
     def tell(self):
         return self._written
-    
+
     def close(self):
         self._message = self._parser.close()
         self._closed = True
-        initializeObjectFromSchemata(self.context, iterSchemata(self.context), self._message, self._encoding)
-    
+        initializeObjectFromSchemata(
+            self.context,
+            iterSchemata(self.context),
+            self._message,
+            self._encoding
+        )
+
     def write(self, data):
         if self._closed:
             raise ValueError("File is closed")
         self._written += len(data)
         self._parser.feed(data)
-    
+
     def writelines(self, sequence):
         for item in sequence:
             self.write(item)
-    
+
     def truncate(self, size=None):
         if (size is None and self._written != 0) and size != 0:
-            raise NotImplementedError("The 'size' argument to truncate() must be 0 - partial truncation is not supported")
+            raise NotImplementedError(
+                "The 'size' argument to truncate() must be 0 - partial "
+                "truncation is not supported"
+            )
         if self._closed:
             raise ValueError("File is closed")
         self._parser = FeedParser()
         self._written = 0
-    
+
     def flush(self):
         pass
-
diff --git a/plone/dexterity/fti.py b/plone/dexterity/fti.py
index 6fffe39..bbba19e 100644
--- a/plone/dexterity/fti.py
+++ b/plone/dexterity/fti.py
@@ -1,44 +1,34 @@
-import os.path
-import logging
-
-from zope.interface import implements
-
+# -*- coding: utf-8 -*-
+from AccessControl import getSecurityManager
+from Acquisition import aq_base
+from Products.CMFCore.interfaces import ISiteRoot
+from Products.CMFDynamicViewFTI import fti as base
+from plone.dexterity import utils
+from plone.dexterity.factory import DexterityFactory
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.interfaces import IDexterityFTIModificationDescription
+from plone.dexterity.schema import SchemaInvalidatedEvent
+from plone.supermodel import loadString, loadFile
+from plone.supermodel.model import Model
+from plone.supermodel.utils import syncSchema
+from zope.component import getAllUtilitiesRegisteredFor
+from zope.component import getUtility
+from zope.component import queryUtility
 from zope.component.interfaces import IFactory
-from zope.component import getUtility, queryUtility, getAllUtilitiesRegisteredFor
-
 from zope.event import notify
-
-from zope.security.interfaces import IPermission
-
+from zope.i18nmessageid import Message
+from zope.interface import implements
 from zope.lifecycleevent import modified
-
+from zope.security.interfaces import IPermission
 from zope.site.hooks import getSiteManager
-from zope.i18nmessageid import Message
-
-from plone.supermodel import loadString, loadFile
-from plone.supermodel.model import Model
-from plone.supermodel.utils import syncSchema
-
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.interfaces import IDexterityFTIModificationDescription
-from plone.dexterity import utils
-
-from plone.dexterity.factory import DexterityFactory
-
-from Acquisition import aq_base
-from AccessControl import getSecurityManager
-
-from Products.CMFCore.interfaces import ISiteRoot
-from Products.CMFDynamicViewFTI import fti as base
-
+import logging
+import os.path
 import plone.dexterity.schema
 
-from plone.dexterity.schema import SchemaInvalidatedEvent
-
 
 class DexterityFTIModificationDescription(object):
     implements(IDexterityFTIModificationDescription)
-    
+
     def __init__(self, attribute, oldValue):
         self.attribute = attribute
         self.oldValue = oldValue
@@ -47,77 +37,95 @@ def __init__(self, attribute, oldValue):
 class DexterityFTI(base.DynamicViewTypeInformation):
     """A Dexterity FTI
     """
-    
+
     implements(IDexterityFTI)
 
     meta_type = "Dexterity FTI"
-    
+
     _properties = base.DynamicViewTypeInformation._properties + (
-        { 'id': 'add_permission', 
-          'type': 'selection',
-          'select_variable': 'possiblePermissionIds',
-          'mode': 'w',
-          'label': 'Add permission',
-          'description': 'Permission needed to be able to add content of this type'
+        {
+            'id': 'add_permission',
+            'type': 'selection',
+            'select_variable': 'possiblePermissionIds',
+            'mode': 'w',
+            'label': 'Add permission',
+            'description': 'Permission needed to be able to add content of '
+                           'this type',
         },
-        { 'id': 'klass', 
-          'type': 'string',
-          'mode': 'w',
-          'label': 'Content type class',
-          'description': 'Dotted name to the class that contains the content type'
+        {
+            'id': 'klass',
+            'type': 'string',
+            'mode': 'w',
+            'label': 'Content type class',
+            'description': 'Dotted name to the class that contains the '
+                           'content type'
         },
-        { 'id': 'behaviors', 
-          'type': 'lines',
-          'mode': 'w',
-          'label': 'Behaviors',
-          'description': 'Named of enabled behaviors type'
+        {
+            'id': 'behaviors',
+            'type': 'lines',
+            'mode': 'w',
+            'label': 'Behaviors',
+            'description': 'Named of enabled behaviors type'
         },
-        { 'id': 'schema', 
-          'type': 'string',
-          'mode': 'w',
-          'label': 'Schema',
-          'description': "Dotted name to the interface describing content type's schema. " +
-                         "This does not need to be given if model_source or model_file are given, " +
-                         "and either contains an unnamed (default) schema."
+        {
+            'id': 'schema',
+            'type': 'string',
+            'mode': 'w',
+            'label': 'Schema',
+            'description': "Dotted name to the interface describing content "
+                           "type's schema.  This does not need to be given "
+                           "if model_source or model_file are given, and "
+                           "either contains an unnamed (default) schema."
         },
-        { 'id': 'model_source', 
-          'type': 'text',
-          'mode': 'w',
-          'label': 'Model source',
-          'description': "XML source for the type's model. Note that this takes " +
-                         "precedence over any model file."
+        {
+            'id': 'model_source',
+            'type': 'text',
+            'mode': 'w',
+            'label': 'Model source',
+            'description': "XML source for the type's model. Note that this "
+                           "takes precedence over any model file."
         },
-        { 'id': 'model_file', 
-          'type': 'string',
-          'mode': 'w',
-          'label': 'Model file',
-          'description': "Path to file containing the schema model. This can be " +
-                         "relative to a package, e.g. 'my.package:myschema.xml'."
+        {
+            'id': 'model_file',
+            'type': 'string',
+            'mode': 'w',
+            'label': 'Model file',
+            'description': "Path to file containing the schema model. "
+                           "This can be relative to a package, e.g. "
+                           "'my.package:myschema.xml'."
         },
-        { 'id': 'schema_policy',
-          'type': 'string',
-          'mode': 'w',
-          'label': 'Content type schema policy',
-          'description': 'Name of the schema policy.'
+        {
+            'id': 'schema_policy',
+            'type': 'string',
+            'mode': 'w',
+            'label': 'Content type schema policy',
+            'description': 'Name of the schema policy.'
         },
 
     )
-    
-    default_aliases = {'(Default)': '(dynamic view)',
-                       'view': '(selected layout)',
-                       'edit': '@@edit',
-                       'sharing': '@@sharing',}
-    
-    default_actions = [{'id': 'view', 
-                        'title': 'View', 
-                        'action': 'string:${object_url}',
-                        'permissions': ('View',)},
-                       {'id': 'edit', 
-                        'title': 'Edit', 
-                        'action': 'string:${object_url}/edit',
-                        'permissions': ('Modify portal content',)},
-                        ]
-    
+
+    default_aliases = {
+        '(Default)': '(dynamic view)',
+        'view': '(selected layout)',
+        'edit': '@@edit',
+        'sharing': '@@sharing',
+    }
+
+    default_actions = [
+        {
+            'id': 'view',
+            'title': 'View',
+            'action': 'string:${object_url}',
+            'permissions': ('View',)
+        },
+        {
+            'id': 'edit',
+            'title': 'Edit',
+            'action': 'string:${object_url}/edit',
+            'permissions': ('Modify portal content',)
+        },
+    ]
+
     immediate_view = 'view'
     default_view = 'view'
     view_methods = ('view',)
@@ -132,13 +140,13 @@ class DexterityFTI(base.DynamicViewTypeInformation):
     model_file = u""
     schema = u""
     schema_policy = u"dexterity"
-    
+
     def __init__(self, *args, **kwargs):
         super(DexterityFTI, self).__init__(*args, **kwargs)
-        
+
         if 'aliases' not in kwargs:
             self.setMethodAliases(self.default_aliases)
-            
+
         if 'actions' not in kwargs:
             for action in self.default_actions:
                 self.addAction(id=action['id'],
@@ -148,37 +156,40 @@ def __init__(self, *args, **kwargs):
                                permission=action.get('permissions', ()),
                                category=action.get('category', 'object'),
                                visible=action.get('visible', True))
-        
+
         # Default factory name to be the FTI name
         if not self.factory:
             self.factory = self.getId()
-        
+
         # In CMF (2.2+, but we've backported it) the property add_view_expr is
         # used to construct an action in the 'folder/add' category. The
         # portal_types tool loops over all FTIs and lets them provide such
         # actions.
-        # 
+        #
         # By convention, the expression is string:${folder_url}/++add++my.type
-        # 
+        #
         # The ++add++ traverser will find the FTI with name my.type, and then
         # looks up an adapter for (context, request, fti) with a name equal
         # to fti.factory, falling back on an unnamed adapter. The result is
         # assumed to be an add view.
-        # 
+        #
         # Dexterity provides a default (unnamed) adapter for any IFolderish
         # context, request and IDexterityFTI that can construct an add view
         # for any Dexterity schema.
-        
+
         if not self.add_view_expr:
-            add_view_expr = kwargs.get('add_view_expr', "string:${folder_url}/++add++%s" % self.getId())
+            add_view_expr = kwargs.get(
+                'add_view_expr',
+                "string:${folder_url}/++add++%s" % self.getId()
+            )
             self._setPropValue('add_view_expr', add_view_expr)
-        
+
         # Set the content_meta_type from the klass
-        
+
         klass = utils.resolveDottedName(self.klass)
         if klass is not None:
             self.content_meta_type = getattr(klass, 'meta_type', None)
-    
+
     def Title(self):
         if self.title and self.i18n_domain:
             try:
@@ -191,12 +202,18 @@ def Title(self):
     def Description(self):
         if self.description and self.i18n_domain:
             try:
-                return Message(self.description.decode('utf8'), self.i18n_domain)
+                return Message(
+                    self.description.decode('utf8'),
+                    self.i18n_domain
+                )
             except UnicodeDecodeError:
-                return Message(self.description.decode('latin-1'), self.i18n_domain)
+                return Message(
+                    self.description.decode('latin-1'),
+                    self.i18n_domain
+                )
         else:
             return self.description
-    
+
     def Metatype(self):
         if self.content_meta_type:
             return self.content_meta_type
@@ -205,89 +222,100 @@ def Metatype(self):
         if klass is not None:
             self.content_meta_type = getattr(klass, 'meta_type', None)
         return self.content_meta_type
-    
+
     @property
     def hasDynamicSchema(self):
         return not(self.schema)
-    
+
     def lookupSchema(self):
         schema = None
-        
+
         # If a specific schema is given, use it
         if self.schema:
             try:
                 schema = utils.resolveDottedName(self.schema)
             except ImportError:
-                logging.warning(u"Schema %s set for type %s cannot be resolved" % (self.schema, self.getId()))
+                logging.warning(
+                    u"Schema %s set for type %s cannot be resolved" %
+                    (self.schema, self.getId())
+                )
                 # fall through to return a fake class with no
                 # fields so that end user code doesn't break
-                
+
         if schema:
             return schema
-        
+
         # Otherwise, look up a dynamic schema. This will query the model for
-        # an unnamed schema if it is the first time it is looked up. 
+        # an unnamed schema if it is the first time it is looked up.
         # See schema.py
 
         schemaName = utils.portalTypeToSchemaName(self.getId())
         return getattr(plone.dexterity.schema.generated, schemaName)
-    
+
     def lookupModel(self):
-        
+
         if self.model_source:
             return loadString(self.model_source, policy=self.schema_policy)
-        
+
         elif self.model_file:
             model_file = self._absModelFile()
             return loadFile(model_file, reload=True, policy=self.schema_policy)
-        
+
         elif self.schema:
             schema = self.lookupSchema()
             return Model({u"": schema})
-        
-        raise ValueError("Neither model source, nor model file, nor schema is specified in FTI %s" % self.getId())
-    
+
+        raise ValueError(
+            "Neither model source, nor model file, nor schema is specified in "
+            "FTI %s" % self.getId()
+        )
+
     #
     # Base class overrides
-    # 
-    
+    #
+
     # Make sure we get an event when the FTI is modified
-    
+
     def _updateProperty(self, id, value):
         """Allow property to be updated, and fire a modified event. We do this
         on a per-property basis and invalidate selectively based on the id of
         the property that was changed.
         """
-        
+
         oldValue = getattr(self, id, None)
         super(DexterityFTI, self)._updateProperty(id, value)
         new_value = getattr(self, id, None)
-        
+
         if oldValue != new_value:
             modified(self, DexterityFTIModificationDescription(id, oldValue))
-            
+
             # Update meta_type from klass
             if id == 'klass':
                 klass = utils.resolveDottedName(new_value)
                 if klass is not None:
                     self.content_meta_type = getattr(klass, 'meta_type', None)
-    
+
     # Allow us to specify a particular add permission rather than rely on ones
     # stored in meta types that we don't have anyway
-    
+
     def isConstructionAllowed(self, container):
         if not self.add_permission:
             return False
-        
+
         permission = queryUtility(IPermission, name=self.add_permission)
         if permission is None:
             return False
-        
-        return bool(getSecurityManager().checkPermission(permission.title, container))
-        
+
+        return bool(
+            getSecurityManager().checkPermission(
+                permission.title,
+                container
+            )
+        )
+
     #
     # Helper methods
-    # 
+    #
 
     def possiblePermissionIds(self):
         """Get a vocabulary of Zope 3 permission ids
@@ -300,7 +328,7 @@ def possiblePermissionIds(self):
     def _absModelFile(self):
         colons = self.model_file.count(':')
         model_file = self.model_file
-        
+
         # We have a package and not an absolute Windows path
         if colons == 1 and self.model_file[1:3] != ':\\':
             package, filename = self.model_file.split(':')
@@ -310,63 +338,82 @@ def _absModelFile(self):
             model_file = os.path.join(os.path.split(mod.__file__)[0], filename)
         else:
             if not os.path.isabs(model_file):
-                raise ValueError(u"Model file name %s is not an absolute path and does not contain a package name in %s" % (model_file, self.getId(),))
-        
+                raise ValueError(
+                    u"Model file name %s is not an absolute path and does "
+                    u"not contain a package name in %s"
+                    % (model_file, self.getId(),)
+                )
+
         if not os.path.isfile(model_file):
-            raise ValueError(u"Model file %s in %s cannot be found" % (model_file, self.getId(),))
-        
+            raise ValueError(
+                u"Model file %s in %s cannot be found"
+                % (model_file, self.getId(),)
+            )
+
         return model_file
 
+
 def _fixProperties(class_, ignored=['product', 'content_meta_type']):
     """Remove properties with the given ids, and ensure that later properties
     override earlier ones with the same id
     """
     properties = []
     processed = set()
-    
+
     for item in reversed(class_._properties):
         item = item.copy()
-        
+
         if item['id'] in processed:
             continue
-        
+
         # Ignore some fields
         if item['id'] in ignored:
             continue
-        
+
         properties.append(item)
         processed.add('id')
-    
+
     class_._properties = tuple(reversed(properties))
 _fixProperties(DexterityFTI)
 
-# Event handlers
 
+# Event handlers
 def register(fti):
     """Helper method to:
-    
+
          - register an FTI as a local utility
          - register a local factory utility
          - register an add view
     """
 
-    fti = aq_base(fti) # remove acquisition wrapper
+    fti = aq_base(fti)  # remove acquisition wrapper
     site = getUtility(ISiteRoot)
     site_manager = getSiteManager(site)
-    
+
     portal_type = fti.getId()
-    
+
     fti_utility = queryUtility(IDexterityFTI, name=portal_type)
     if fti_utility is None:
-        site_manager.registerUtility(fti, IDexterityFTI, portal_type, info='plone.dexterity.dynamic')
-        
+        site_manager.registerUtility(
+            fti,
+            IDexterityFTI,
+            portal_type,
+            info='plone.dexterity.dynamic'
+        )
+
     factory_utility = queryUtility(IFactory, name=fti.factory)
     if factory_utility is None:
-        site_manager.registerUtility(DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic')
+        site_manager.registerUtility(
+            DexterityFactory(portal_type),
+            IFactory,
+            fti.factory,
+            info='plone.dexterity.dynamic'
+        )
+
 
 def unregister(fti, old_name=None):
     """Helper method to:
-    
+
         - unregister the FTI local utility
         - unregister any local factory utility associated with the FTI
         - unregister any local add view associated with the FTI
@@ -374,15 +421,16 @@ def unregister(fti, old_name=None):
     site = queryUtility(ISiteRoot)
     if site is None:
         return
-    
+
     site_manager = getSiteManager(site)
-    
+
     portal_type = old_name or fti.getId()
 
     notify(SchemaInvalidatedEvent(portal_type))
-    
+
     site_manager.unregisterUtility(provided=IDexterityFTI, name=portal_type)
-    unregister_factory(fti.factory, site_manager)    
+    unregister_factory(fti.factory, site_manager)
+
 
 def unregister_factory(factory_name, site_manager):
     """Helper method to unregister factories when unused by any dexterity
@@ -390,90 +438,107 @@ def unregister_factory(factory_name, site_manager):
     """
     utilities = list(site_manager.registeredUtilities())
     # Do nothing if an FTI is still using it
-    if factory_name in [f.component.factory for f in utilities
-                        if (f.provided, f.info) == (IDexterityFTI, 'plone.dexterity.dynamic')]:
+    if factory_name in [
+        f.component.factory for f in utilities
+        if (f.provided, f.info) == (IDexterityFTI, 'plone.dexterity.dynamic')
+    ]:
         return
-    
+
     # If a factory with a matching name exists, remove it
     if [f for f in utilities
         if (f.provided, f.name, f.info) == (IFactory, factory_name, 'plone.dexterity.dynamic')]:
         site_manager.unregisterUtility(provided=IFactory, name=factory_name)
 
+
 def ftiAdded(object, event):
     """When the FTI is created, install local components
     """
-    
+
     if not IDexterityFTI.providedBy(event.object):
         return
-    
+
     register(event.object)
-    
+
+
 def ftiRemoved(object, event):
     """When the FTI is removed, uninstall local coponents
     """
-    
+
     if not IDexterityFTI.providedBy(event.object):
         return
-            
+
     unregister(event.object)
 
+
 def ftiRenamed(object, event):
     """When the FTI is modified, ensure local components are still valid
     """
-    
+
     if not IDexterityFTI.providedBy(event.object):
         return
-    
-    if event.oldParent is None or event.newParent is None or event.oldName == event.newName:
+
+    if event.oldParent is None \
+       or event.newParent is None \
+       or event.oldName == event.newName:
         return
-    
+
     unregister(event.object, event.oldName)
     register(event.object)
 
+
 def ftiModified(object, event):
-    """When an FTI is modified, re-sync and invalidate the schema, if 
+    """When an FTI is modified, re-sync and invalidate the schema, if
     necessary.
     """
-    
+
     if not IDexterityFTI.providedBy(event.object):
         return
-    
+
     fti = event.object
     portal_type = fti.getId()
-    
+
     mod = {}
     for desc in event.descriptions:
         if IDexterityFTIModificationDescription.providedBy(desc):
             mod[desc.attribute] = desc.oldValue
-    
-    # If the factory utility name was modified, we may get an orphan if one 
+
+    # If the factory utility name was modified, we may get an orphan if one
     # was registered as a local utility to begin with. If so, remove the
     # orphan.
-    
+
     if 'factory' in mod:
         old_factory = mod['factory']
-        
+
         site = getUtility(ISiteRoot)
         site_manager = getSiteManager(site)
-        
+
         # Remove previously registered factory, if no other type uses it.
         unregister_factory(old_factory, site_manager)
-        
+
         # Register a new local factory if one doesn't exist already
         new_factory_utility = queryUtility(IFactory, name=fti.factory)
         if new_factory_utility is None:
-            site_manager.registerUtility(DexterityFactory(portal_type), IFactory, fti.factory, info='plone.dexterity.dynamic')
-        
+            site_manager.registerUtility(
+                DexterityFactory(portal_type),
+                IFactory,
+                fti.factory,
+                info='plone.dexterity.dynamic'
+            )
+
     # Determine if we need to invalidate the schema at all
-    if 'behaviors' in mod or 'schema' in mod or 'model_source' in mod or 'model_file' in mod:
-        
+    if 'behaviors' in mod \
+       or 'schema' in mod \
+       or 'model_source' in mod \
+       or 'model_file' in mod:
+
         # Determine if we need to re-sync a dynamic schema
-        if (fti.model_source or fti.model_file) and ('model_source' in mod or 'model_file' in mod):
-            
+        if (fti.model_source or fti.model_file) \
+           and ('model_source' in mod or 'model_file' in mod):
+
             schemaName = utils.portalTypeToSchemaName(portal_type)
             schema = getattr(plone.dexterity.schema.generated, schemaName)
-    
+
             model = fti.lookupModel()
             syncSchema(model.schema, schema, overwrite=True)
-        
+
         notify(SchemaInvalidatedEvent(portal_type))
diff --git a/plone/dexterity/i18n.py b/plone/dexterity/i18n.py
index 95fdb1d..08b6593 100644
--- a/plone/dexterity/i18n.py
+++ b/plone/dexterity/i18n.py
@@ -1,2 +1,3 @@
+# -*- coding: utf-8 -*-
 import zope.i18nmessageid
 MessageFactory = zope.i18nmessageid.MessageFactory("plone.dexterity")
diff --git a/plone/dexterity/interfaces.py b/plone/dexterity/interfaces.py
index 60b85c3..6f5fdb9 100644
--- a/plone/dexterity/interfaces.py
+++ b/plone/dexterity/interfaces.py
@@ -1,6 +1,9 @@
+# -*- coding: utf-8 -*-
+from Products.CMFCore.interfaces import ITypeInformation
+from zope.component.interfaces import IFactory
+from zope.component.interfaces import IObjectEvent
 from zope.interface import Interface, Attribute
 from zope.lifecycleevent.interfaces import IModificationDescription
-
 import zope.schema
 
 try:
@@ -9,14 +12,10 @@
     class IContentType(Interface):
         pass
 
-from zope.component.interfaces import IFactory
-from zope.component.interfaces import IObjectEvent
-
-from Products.CMFCore.interfaces import ITypeInformation
-
 # id for pseudo-resource used to expose data for folderish items over WebDAV
 DAV_FOLDER_DATA_ID = '_data'
 
+
 class IDexterityFTI(ITypeInformation):
     """The Factory Type Information for Dexterity content objects
     """
@@ -24,7 +23,7 @@ class IDexterityFTI(ITypeInformation):
     def lookupSchema():
         """Return an InterfaceClass that represents the schema of this type.
         Raises a ValueError if it cannot be found.
-        
+
         If a schema interface is specified, return this. Otherwise, look up
         the model from either the TTW model source string or a specified
         model XML file, and build a schema from the unnamed schema
@@ -35,135 +34,150 @@ def lookupModel():
         """Return the IModel specified in either the model_source or
         model_file (the former takes precedence). See plone.supermodel for
         more information about this type.
-        
+
         If neither a model_source or a model_file is given, but a schema is
         given, return a faux model that contains just this schema.
-        
+
         Note that model.schema is not necessarily going to be the same as
         the schema returned by lookupSchema().
         """
-    
+
     add_permission = zope.schema.DottedName(
-            title=u"Add permission",
-            description=u"Zope 3 permission name for the permission required to construct this content",
-        )
-    
+        title=u"Add permission",
+        description=u"Zope 3 permission name for the permission required to "
+                    u"construct this content",
+    )
+
     behaviors = zope.schema.List(
-            title=u"Behaviors",
-            description=u"A list of behaviors that are enabled for this type. "
-                        u"See plone.behavior for more details.",
-            value_type=zope.schema.DottedName(title=u"Behavior name")
-        )
+        title=u"Behaviors",
+        description=u"A list of behaviors that are enabled for this type. "
+                    u"See plone.behavior for more details.",
+        value_type=zope.schema.DottedName(title=u"Behavior name")
+    )
 
     schema = zope.schema.DottedName(
-            title=u"Schema interface",
-            description=u"Dotted name to an interface describing the type. "
-                        u"This is not required if there is a model file or a "
-                        u"model source string containing an unnamed schema."
-        )
+        title=u"Schema interface",
+        description=u"Dotted name to an interface describing the type. "
+                    u"This is not required if there is a model file or a "
+                    u"model source string containing an unnamed schema."
+    )
 
     model_source = zope.schema.Text(
-            title=u"Model text",
-            description=u"XML representation of the model for this type. " +
-                        u"If this is given, it will override any model_file."
-        )
+        title=u"Model text",
+        description=u"XML representation of the model for this type. " +
+                    u"If this is given, it will override any model_file."
+    )
 
     model_file = zope.schema.Text(
-            title=u"Model file",
-            description=u"A file that contains an XML model. " 
-                        u"This may be an absolute path, or one relative to a " 
-                        u"package, e.g. my.package:model.xml"
-        )
-    
+        title=u"Model file",
+        description=u"A file that contains an XML model. "
+                    u"This may be an absolute path, or one relative to a "
+                    u"package, e.g. my.package:model.xml"
+    )
+
     hasDynamicSchema = zope.schema.Bool(
-            title=u"Whether or not the FTI uses a dynamic schema.",
-            readonly=True
-        )
+        title=u"Whether or not the FTI uses a dynamic schema.",
+        readonly=True
+    )
+
 
 class IDexterityFTIModificationDescription(IModificationDescription):
     """Descriptor passed with an IObjectModifiedEvent for a Dexterity FTI.
     """
-    
-    attribute = zope.schema.ASCII(title=u"Name of the attribute that was modified")
+
+    attribute = zope.schema.ASCII(
+        title=u"Name of the attribute that was modified"
+    )
     oldValue = Attribute("Old value")
 
+
 class IDexterityFactory(IFactory):
     """A factory that can create Dexterity objects.
-    
+
     This factory will create an object by looking up the klass property of
-    the FTI with the given portal type. It will also set the portal_type 
+    the FTI with the given portal type. It will also set the portal_type
     on the instance and mark the instance as providing the schema interface
     if it does not do so already.
     """
-    
-    portal_type = zope.schema.TextLine(title=u"Portal type name",
-                                       description=u"The portal type this is an FTI for")
 
-# Schema
+    portal_type = zope.schema.TextLine(
+        title=u"Portal type name",
+        description=u"The portal type this is an FTI for"
+    )
 
+
+# Schema
 class IDexteritySchema(Interface):
     """Base class for Dexterity schemata
     """
 
-# Schema cache
 
+# Schema cache
 class ISchemaInvalidatedEvent(Interface):
     """Event fired when the schema cache should be invalidated.
-    
+
     If the portal_type is not given, all schemata will be cleared from the
     cache.
     """
-    
+
     portal_type = zope.schema.TextLine(title=u"FTI name", required=False)
 
-# Content
 
+# Content
 class IDexterityContent(Interface):
     """Marker interface for dexterity-managed content objects
     """
 
+
 class IDexterityItem(IDexterityContent):
     """Marker interface applied to dexterity-managed non-folderish objects
     """
-    
+
+
 class IDexterityContainer(IDexterityContent):
     """Marker interface applied to dexterity-managed folderish objects
     """
 
-# Events
 
+# Events
 class IBegunEvent(IObjectEvent):
     """Base begun event
     """
 
+
 class IEditBegunEvent(IBegunEvent):
     """An edit operation was begun
     """
 
+
 class IAddBegunEvent(IBegunEvent):
     """An add operation was begun. The event context is the folder,
     since the object does not exist yet.
     """
 
+
 class ICancelledEvent(IObjectEvent):
     """Base cancel event
     """
 
+
 class IEditCancelledEvent(ICancelledEvent):
     """An edit operation was cancelled
     """
 
+
 class IAddCancelledEvent(ICancelledEvent):
     """An add operation was cancelled. The event context is the folder,
     since the object does not exist yet.
     """
 
+
 class IEditFinishedEvent(IObjectEvent):
     """Edit was finished and contents are saved. This event is fired
     even when no changes happen (and no modified event is fired.)
     """
 
-# Views
 
+# Views
 class IDexterityEditForm(Interface):
     """The edit form for a Dexterity content type."""
diff --git a/plone/dexterity/meta.zcml b/plone/dexterity/meta.zcml
index 79876ba..94ffb10 100644
--- a/plone/dexterity/meta.zcml
+++ b/plone/dexterity/meta.zcml
@@ -4,5 +4,5 @@
 
     <!-- Include ZCML directive from plone.behavior -->
     <include package="plone.behavior" file="meta.zcml" />
-    
+
 </configure>
diff --git a/plone/dexterity/primary.py b/plone/dexterity/primary.py
index 5e9ac11..dbb1da3 100644
--- a/plone/dexterity/primary.py
+++ b/plone/dexterity/primary.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from plone.dexterity.interfaces import IDexterityContent
 from plone.dexterity.utils import iterSchemata
 from plone.rfc822.interfaces import IPrimaryField
diff --git a/plone/dexterity/schema.py b/plone/dexterity/schema.py
index 5188299..13d0f38 100644
--- a/plone/dexterity/schema.py
+++ b/plone/dexterity/schema.py
@@ -1,34 +1,29 @@
-import new
-import functools
-
-from threading import RLock
-from plone.synchronize import synchronized
-
-from zope.interface import implements, alsoProvides
-from zope.interface.interface import InterfaceClass
-
-from zope.component import adapter
-from zope.component import queryUtility, getAllUtilitiesRegisteredFor
-
-from plone.behavior.interfaces import IBehavior
-
-from plone.supermodel.parser import ISchemaPolicy
-from plone.supermodel.utils import syncSchema
-
+# -*- coding: utf-8 -*-
+from plone.alterego import dynamic
 from plone.alterego.interfaces import IDynamicObjectFactory
-
+from plone.behavior.interfaces import IBehavior
+from plone.dexterity import utils
 from plone.dexterity.interfaces import IContentType
-from plone.dexterity.interfaces import IDexteritySchema
 from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.interfaces import IDexteritySchema
 from plone.dexterity.interfaces import ISchemaInvalidatedEvent
-
-from plone.dexterity import utils
-from plone.alterego import dynamic
+from plone.supermodel.parser import ISchemaPolicy
+from plone.supermodel.utils import syncSchema
+from plone.synchronize import synchronized
+from threading import RLock
+from zope.component import adapter
+from zope.component import queryUtility, getAllUtilitiesRegisteredFor
+from zope.interface import implementer
+from zope.interface import alsoProvides
+from zope.interface.interface import InterfaceClass
+import functools
+import new
 
 # Dynamic modules
 generated = dynamic.create('plone.dexterity.schema.generated')
 transient = new.module("transient")
 
+
 def invalidate_cache(fti):
     fti._p_activate()
     fti.__dict__.pop('_v_schema_get', None)
@@ -57,28 +52,28 @@ def decorator(self, portal_type):
 
 
 class SchemaCache(object):
-    """Simple schema cache. 
-    
+    """Simple schema cache.
+
     This cache will store a Python object reference to the schema, as returned
     by fti.lookupSchema(), for any number of portal types. The value will
     be cached until the server is restarted or the cache is invalidated or
     cleared.
-    
+
     You should only use this if you require bare-metal speed. For almost all
     operations, it's safer and easier to do:
-    
+
         >>> fti = getUtility(IDexterityFTI, name=portal_type)
         >>> schema = fti.lookupSchema()
-    
+
     The lookupSchema() call is probably as fast as this cache. However, if
     you need to avoid the utility lookup, you can use the cache like so:
-    
+
         >>> from plone.dexterity.schema import SCHEMA_CACHE
         >>> my_schema = SCHEMA_CACHE.get(portal_type)
-        
+
     The cache uses the FTI's modification time as its invariant.
     """
-    
+
     lock = RLock()
 
     def __init__(self, cache_enabled=True):
@@ -111,7 +106,6 @@ def clear(self):
         for fti in getAllUtilitiesRegisteredFor(IDexterityFTI):
             invalidate_cache(fti)
 
-
     @synchronized(lock)
     def invalidate(self, portal_type):
         fti = queryUtility(IDexterityFTI, name=portal_type)
@@ -121,12 +115,14 @@ def invalidate(self, portal_type):
 
 SCHEMA_CACHE = SchemaCache()
 
+
+ at implementer(ISchemaInvalidatedEvent)
 class SchemaInvalidatedEvent(object):
-    implements(ISchemaInvalidatedEvent)
-    
+
     def __init__(self, portal_type):
         self.portal_type = portal_type
 
+
 @adapter(ISchemaInvalidatedEvent)
 def invalidate_schema(event):
     if event.portal_type:
@@ -134,88 +130,87 @@ def invalidate_schema(event):
     else:
         SCHEMA_CACHE.clear()
 
-# Dynamic module factory
 
+# Dynamic module factory
+ at implementer(IDynamicObjectFactory)
 class SchemaModuleFactory(object):
     """Create dynamic schema interfaces on the fly
     """
-    
-    implements(IDynamicObjectFactory)
-    
+
     lock = RLock()
     _transient_SCHEMA_CACHE = {}
-    
+
     @synchronized(lock)
     def __call__(self, name, module):
         """Someone tried to load a dynamic interface that has not yet been
         created yet. We will attempt to load it from the FTI if we can. If
         the FTI doesn't exist, create a temporary marker interface that we
         can fill later.
-        
-        The goal here is to ensure that we create exactly one interface 
+
+        The goal here is to ensure that we create exactly one interface
         instance for each name. If we can't find an FTI, we'll cache the
         interface so that we don't get a new one with a different id later.
         This cache is global, so we synchronise the method with a thread
         lock.
-        
+
         Once we have a properly populated interface, we set it onto the
         module using setattr(). This means that the factory will not be
         invoked again.
         """
-        
+
         try:
             prefix, portal_type, schemaName = utils.splitSchemaName(name)
         except ValueError:
             return None
-        
+
         if name in self._transient_SCHEMA_CACHE:
             schema = self._transient_SCHEMA_CACHE[name]
         else:
             bases = ()
-            
+
             is_default_schema = not schemaName
             if is_default_schema:
                 bases += (IDexteritySchema,)
-        
+
             schema = InterfaceClass(name, bases, __module__=module.__name__)
-        
+
             if is_default_schema:
                 alsoProvides(schema, IContentType)
-        
+
         fti = queryUtility(IDexterityFTI, name=portal_type)
         if fti is None and name not in self._transient_SCHEMA_CACHE:
             self._transient_SCHEMA_CACHE[name] = schema
         elif fti is not None:
-            model = fti.lookupModel()            
+            model = fti.lookupModel()
             syncSchema(model.schemata[schemaName], schema, sync_bases=True)
 
             # Save this schema in the module - this factory will not be
             # called again for this name
-            
+
             if name in self._transient_SCHEMA_CACHE:
                 del self._transient_SCHEMA_CACHE[name]
-                
+
             setattr(module, name, schema)
 
         return schema
 
+
+ at implementer(ISchemaPolicy)
 class DexteritySchemaPolicy(object):
     """Determines how and where imported dynamic interfaces are created.
     Note that these schemata are never used directly. Rather, they are merged
     into a schema with a proper name and module, either dynamically or
     in code.
     """
-    implements(ISchemaPolicy)
-    
+
     def module(self, schemaName, tree):
         return 'plone.dexterity.schema.transient'
-        
+
     def bases(self, schemaName, tree):
         return ()
-        
+
     def name(self, schemaName, tree):
         # We use a temporary name whilst the interface is being generated;
         # when it's first used, we know the portal_type and site, and can
         # thus update it
         return '__tmp__' + schemaName
-
diff --git a/plone/dexterity/tests/__init__.py b/plone/dexterity/tests/__init__.py
index e69de29..40a96af 100644
--- a/plone/dexterity/tests/__init__.py
+++ b/plone/dexterity/tests/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
diff --git a/plone/dexterity/tests/schemata.py b/plone/dexterity/tests/schemata.py
index 8df573a..5687810 100644
--- a/plone/dexterity/tests/schemata.py
+++ b/plone/dexterity/tests/schemata.py
@@ -1,24 +1,27 @@
-from zope.interface import Interface
+# -*- coding: utf-8 -*-
+from plone.supermodel.interfaces import FILENAME_KEY
 from zope import schema
+from zope.interface import Interface
 
-from plone.supermodel.interfaces import FILENAME_KEY
 
 class ITestSchema(Interface):
     """Schema used for testing
     """
-    
+
     title = schema.TextLine(title=u"Title",
                             description=u"Administrative title")
-                        
+
     description = schema.Text(title=u"Description",
                               required=False)
 
+
 class ITaggedValueSchema(Interface):
     """Schema used for testing tagged value filenames
     """
-    
+
 ITaggedValueSchema.setTaggedValue(FILENAME_KEY, '/path/to/dummy.xml')
 
+
 class IDerivedFromTaggedValueSchema(ITaggedValueSchema):
     """Schema used for testing tagged value filenames
     """
\ No newline at end of file
diff --git a/plone/dexterity/tests/test_behavior.py b/plone/dexterity/tests/test_behavior.py
index 009ba44..76dbe49 100644
--- a/plone/dexterity/tests/test_behavior.py
+++ b/plone/dexterity/tests/test_behavior.py
@@ -1,27 +1,29 @@
-import unittest
-from plone.mocktestcase import MockTestCase
-
-from zope.interface import Interface
-
+# -*- coding: utf-8 -*-
 from plone.behavior.interfaces import IBehavior
-
-from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.behavior import DexterityBehaviorAssignable
 from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.mocktestcase import MockTestCase
+from zope.interface import Interface
+import unittest
 
-from plone.dexterity.behavior import DexterityBehaviorAssignable
 
 class IOne(Interface):
     pass
 
+
 class ITwo(Interface):
     pass
 
+
 class IThree(Interface):
     pass
 
+
 class IFour(IThree):
     pass
 
+
 class TestBehavior(MockTestCase):
 
     def test_supports(self):
@@ -30,10 +32,18 @@ def test_supports(self):
         context_dummy = self.create_dummy(portal_type=u"testtype")
 
         # Behavior mock
-        behavior_dummy_1 = self.create_dummy(interface = IOne)
-        self.mock_utility(behavior_dummy_1, IBehavior, name=IOne.__identifier__)
-        behavior_dummy_4 = self.create_dummy(interface = IFour)
-        self.mock_utility(behavior_dummy_4, IBehavior, name=IFour.__identifier__)
+        behavior_dummy_1 = self.create_dummy(interface=IOne)
+        self.mock_utility(
+            behavior_dummy_1,
+            IBehavior,
+            name=IOne.__identifier__
+        )
+        behavior_dummy_4 = self.create_dummy(interface=IFour)
+        self.mock_utility(
+            behavior_dummy_4,
+            IBehavior,
+            name=IFour.__identifier__
+        )
 
         # FTI mock
         fti = DexterityFTI(u"testtype")
@@ -67,7 +77,10 @@ def test_enumerate(self):
 
         assignable = DexterityBehaviorAssignable(context_dummy)
 
-        self.assertEqual([behavior_dummy], list(assignable.enumerateBehaviors()))
+        self.assertEqual(
+            [behavior_dummy],
+            list(assignable.enumerateBehaviors())
+        )
 
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_content.py b/plone/dexterity/tests/test_content.py
index 2fdb7e0..3c0e988 100644
--- a/plone/dexterity/tests/test_content.py
+++ b/plone/dexterity/tests/test_content.py
@@ -1,24 +1,21 @@
 # -*- coding: utf-8 -*-
-import unittest
-from plone.mocktestcase import MockTestCase
-
+from Products.CMFPlone.interfaces import IConstrainTypes
 from datetime import date, datetime
+from plone.behavior.interfaces import IBehavior
+from plone.behavior.registration import BehaviorRegistration
+from plone.dexterity.content import Item, Container
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IDexterityFTI, IDexterityContainer
+from plone.dexterity.schema import SCHEMA_CACHE
+from plone.folder.default import DefaultOrdering
+from plone.mocktestcase import MockTestCase
 from pytz import timezone
-
 from zope.annotation.attribute import AttributeAnnotations
-from zope.interface import Interface, alsoProvides
 from zope.component import provideAdapter, getUtility
+from zope.interface import Interface, alsoProvides
+import unittest
 import zope.schema
 
-from Products.CMFPlone.interfaces import IConstrainTypes
-from plone.dexterity.interfaces import IDexterityFTI, IDexterityContainer
-from plone.dexterity.fti import DexterityFTI
-from plone.dexterity.schema import SCHEMA_CACHE
-from plone.dexterity.content import Item, Container
-from plone.behavior.interfaces import IBehavior
-from plone.behavior.registration import BehaviorRegistration
-from plone.folder.default import DefaultOrdering
-
 
 class TestContent(MockTestCase):
 
@@ -32,8 +29,10 @@ def test_provided_by_item(self):
         class FauxDataManager(object):
             def setstate(self, obj):
                 pass
+
             def oldstate(self, obj, tid):
                 pass
+
             def register(self, obj):
                 pass
 
@@ -92,8 +91,10 @@ class MyItem(Item):
         class FauxDataManager(object):
             def setstate(self, obj):
                 pass
+
             def oldstate(self, obj, tid):
                 pass
+
             def register(self, obj):
                 pass
 
@@ -202,8 +203,10 @@ class MyItem(Item):
         class FauxDataManager(object):
             def setstate(self, obj):
                 pass
+
             def oldstate(self, obj, tid):
                 pass
+
             def register(self, obj):
                 pass
 
@@ -291,8 +294,10 @@ class MyItem(Item):
         class FauxDataManager(object):
             def setstate(self, obj):
                 pass
+
             def oldstate(self, obj, tid):
                 pass
+
             def register(self, obj):
                 pass
 
@@ -853,8 +858,10 @@ def test_field_default_independence(self):
         class FauxDataManager(object):
             def setstate(self, obj):
                 pass
+
             def oldstate(self, obj, tid):
                 pass
+
             def register(self, obj):
                 pass
 
diff --git a/plone/dexterity/tests/test_content_integration.py b/plone/dexterity/tests/test_content_integration.py
index d02f640..e796107 100644
--- a/plone/dexterity/tests/test_content_integration.py
+++ b/plone/dexterity/tests/test_content_integration.py
@@ -1,5 +1,6 @@
-import unittest
+# -*- coding: utf-8 -*-
 from plone.testing.zca import UNIT_TESTING
+import unittest
 
 # TODO: End to end tests that ensure components are properly wired up
 #  - for now, we have some tests in example.dexterity, but we should have
@@ -7,9 +8,9 @@
 
 
 class TestUUIDIntegration(unittest.TestCase):
-    
+
     layer = UNIT_TESTING
-    
+
     def setUp(self):
         import zope.component.testing
         import plone.uuid
@@ -18,7 +19,7 @@ def setUp(self):
 
         zope.component.testing.setUp()
         xmlconfig.file('configure.zcml', plone.uuid)
-    
+
     def test_uuid_assigned_on_creation(self):
         from plone.dexterity.content import Item
         from plone.uuid.interfaces import IUUID
diff --git a/plone/dexterity/tests/test_exportimport.py b/plone/dexterity/tests/test_exportimport.py
index 9977aa8..32e1142 100644
--- a/plone/dexterity/tests/test_exportimport.py
+++ b/plone/dexterity/tests/test_exportimport.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import unittest
 
 
@@ -6,7 +7,8 @@ class ExportImportTests(unittest.TestCase):
     def test_export(self):
         # Make sure our exporter delegates to manage_FTPget()
         from plone.dexterity.content import Item
-        from plone.dexterity.exportimport import DexterityContentExporterImporter
+        from plone.dexterity.exportimport import \
+            DexterityContentExporterImporter
         from Products.GenericSetup.tests.common import DummyExportContext
 
         class DummyItem(Item):
@@ -26,7 +28,8 @@ def manage_FTPget(self):
     def test_import(self):
         # Make sure our importer delegates to PUT()
         from plone.dexterity.content import Item
-        from plone.dexterity.exportimport import DexterityContentExporterImporter
+        from plone.dexterity.exportimport import \
+            DexterityContentExporterImporter
         from Products.GenericSetup.tests.common import DummyImportContext
 
         class DummyItem(Item):
diff --git a/plone/dexterity/tests/test_factory.py b/plone/dexterity/tests/test_factory.py
index c541f91..f84a542 100644
--- a/plone/dexterity/tests/test_factory.py
+++ b/plone/dexterity/tests/test_factory.py
@@ -1,16 +1,16 @@
-import unittest
+# -*- coding: utf-8 -*-
+from plone.dexterity.factory import DexterityFactory
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IDexterityFTI
 from plone.mocktestcase import MockTestCase
-
 from zope.interface import Interface
+import unittest
 
-from plone.dexterity.interfaces import IDexterityFTI
-
-from plone.dexterity.fti import DexterityFTI
-from plone.dexterity.factory import DexterityFactory
 
 class IDummy(Interface):
     pass
 
+
 class TestFactory(MockTestCase):
 
     def test_title(self):
@@ -53,7 +53,6 @@ def test_get_interfaces(self):
     #   - callable is called to get an object
     #   - portal_type is set if not set already
 
-
     def test_create_with_schema_already_provided_and_portal_type_set(self):
 
         # Object returned by class
@@ -65,8 +64,12 @@ def test_create_with_schema_already_provided_and_portal_type_set(self):
         self.expect(klass_mock()).result(obj_mock)
 
         # Resolver
-        resolver_mock = self.mocker.replace("plone.dexterity.utils.resolveDottedName")
-        self.expect(resolver_mock("my.mocked.ContentTypeClass")).result(klass_mock)
+        resolver_mock = self.mocker.replace(
+            "plone.dexterity.utils.resolveDottedName"
+        )
+        self.expect(
+            resolver_mock("my.mocked.ContentTypeClass")
+        ).result(klass_mock)
 
         # FTI
         fti_mock = self.mocker.mock(DexterityFTI)
@@ -82,7 +85,10 @@ def test_create_sets_portal_type_if_not_set(self):
 
         # Object returned by class
         obj_mock = self.mocker.mock()
-        self.expect(obj_mock.portal_type).throw(AttributeError) # -> need to set portal_type
+        self.expect(
+            obj_mock.portal_type
+        ).throw(AttributeError)  # -> need to set portal_type
+
         obj_mock.portal_type = u"testtype"
 
         # Class set by factory
@@ -90,8 +96,12 @@ def test_create_sets_portal_type_if_not_set(self):
         self.expect(klass_mock()).result(obj_mock)
 
         # Resolver
-        resolver_mock = self.mocker.replace("plone.dexterity.utils.resolveDottedName")
-        self.expect(resolver_mock("my.mocked.ContentTypeClass")).result(klass_mock)
+        resolver_mock = self.mocker.replace(
+            "plone.dexterity.utils.resolveDottedName"
+        )
+        self.expect(
+            resolver_mock("my.mocked.ContentTypeClass")
+        ).result(klass_mock)
 
         # FTI
         fti_mock = self.mocker.mock(DexterityFTI)
@@ -107,7 +117,9 @@ def test_create_sets_portal_type_if_wrong(self):
 
         # Object returned by class
         obj_mock = self.mocker.mock()
-        self.expect(obj_mock.portal_type).result('othertype') # -> need to fix portal_type
+        self.expect(
+            obj_mock.portal_type
+        ).result('othertype')  # -> need to fix portal_type
         obj_mock.portal_type = u"testtype"
 
         # Class set by factory
@@ -115,8 +127,12 @@ def test_create_sets_portal_type_if_wrong(self):
         self.expect(klass_mock()).result(obj_mock)
 
         # Resolver
-        resolver_mock = self.mocker.replace("plone.dexterity.utils.resolveDottedName")
-        self.expect(resolver_mock("my.mocked.ContentTypeClass")).result(klass_mock)
+        resolver_mock = self.mocker.replace(
+            "plone.dexterity.utils.resolveDottedName"
+        )
+        self.expect(
+            resolver_mock("my.mocked.ContentTypeClass")
+        ).result(klass_mock)
 
         # FTI
         fti_mock = self.mocker.mock(DexterityFTI)
@@ -139,8 +155,12 @@ def test_create_initialises_schema_if_not_provided(self):
         self.expect(klass_mock()).result(obj_mock)
 
         # Resolver
-        resolver_mock = self.mocker.replace("plone.dexterity.utils.resolveDottedName")
-        self.expect(resolver_mock("my.mocked.ContentTypeClass")).result(klass_mock)
+        resolver_mock = self.mocker.replace(
+            "plone.dexterity.utils.resolveDottedName"
+        )
+        self.expect(
+            resolver_mock("my.mocked.ContentTypeClass")
+        ).result(klass_mock)
 
         # FTI
         fti_mock = self.mocker.mock(DexterityFTI)
@@ -163,8 +183,12 @@ def test_factory_passes_args_and_kwargs(self):
         self.expect(klass_mock(u"id", title=u"title")).result(obj_mock)
 
         # Resolver
-        resolver_mock = self.mocker.replace("plone.dexterity.utils.resolveDottedName")
-        self.expect(resolver_mock("my.mocked.ContentTypeClass")).result(klass_mock)
+        resolver_mock = self.mocker.replace(
+            "plone.dexterity.utils.resolveDottedName"
+        )
+        self.expect(
+            resolver_mock("my.mocked.ContentTypeClass")
+        ).result(klass_mock)
 
         # FTI
         fti_mock = self.mocker.mock(DexterityFTI)
@@ -176,5 +200,6 @@ def test_factory_passes_args_and_kwargs(self):
         factory = DexterityFactory(portal_type=u"testtype")
         self.assertEqual(obj_mock, factory(u"id", title=u"title"))
 
+
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_fti.py b/plone/dexterity/tests/test_fti.py
index c69ab80..02b3189 100644
--- a/plone/dexterity/tests/test_fti.py
+++ b/plone/dexterity/tests/test_fti.py
@@ -1,53 +1,45 @@
-import unittest
-import mocker
+# -*- coding: utf-8 -*-
+from Products.CMFCore.interfaces import ISiteRoot
+from plone.dexterity import utils
+from plone.dexterity.factory import DexterityFactory
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.fti import DexterityFTIModificationDescription
+from plone.dexterity.fti import ftiAdded
+from plone.dexterity.fti import ftiModified
+from plone.dexterity.fti import ftiRemoved
+from plone.dexterity.fti import ftiRenamed
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.schema import DexteritySchemaPolicy
+from plone.dexterity.tests.schemata import ITestSchema
 from plone.mocktestcase import MockTestCase
-
-import os.path
-
-from zope.interface import Interface
+from plone.supermodel.model import Model
+from zope.component import getGlobalSiteManager
 from zope.component import queryUtility
-
-from zope.security.interfaces import IPermission
-
-import zope.schema
-
+from zope.component.hooks import setSite, setHooks
 from zope.component.interfaces import IFactory
-
-from zope.component import getGlobalSiteManager
 from zope.component.persistentregistry import PersistentComponents
-from zope.component.hooks import setSite, setHooks
-
-from zope.lifecycleevent.interfaces import IObjectModifiedEvent
-from zope.lifecycleevent import ObjectModifiedEvent
-
-from zope.container.contained import ObjectMovedEvent
 from zope.container.contained import ObjectAddedEvent
+from zope.container.contained import ObjectMovedEvent
 from zope.container.contained import ObjectRemovedEvent
-
-from plone.dexterity.interfaces import IDexterityFTI
-
-from plone.dexterity.fti import DexterityFTI, DexterityFTIModificationDescription
-from plone.dexterity.fti import ftiAdded, ftiRemoved, ftiRenamed, ftiModified
-
-from plone.dexterity.factory import DexterityFactory
-
-from plone.dexterity.schema import DexteritySchemaPolicy
-
-from plone.dexterity import utils
-from plone.dexterity.tests.schemata import ITestSchema
-
-from plone.supermodel.model import Model
-
-from Products.CMFCore.interfaces import ISiteRoot
-
+from zope.interface import Interface
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
+from zope.security.interfaces import IPermission
+import mocker
+import os.path
 import plone.dexterity.schema.generated
+import unittest
+import zope.schema
+
 
 class TestClass(object):
     meta_type = "Test Class"
 
+
 class TestClass2(object):
     meta_type = "Test Class 2"
 
+
 class ITestInterface(Interface):
     pass
 
@@ -70,13 +62,14 @@ def test_lookupSchema_with_concrete_schema(self):
         fti = DexterityFTI(u"testtype")
         fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"
         self.assertEqual(ITestSchema, fti.lookupSchema())
-        self.assertEqual(ITestSchema, fti.lookupSchema()) # second time uses _v attribute
+        # second time uses _v attribute
+        self.assertEqual(ITestSchema, fti.lookupSchema())
 
     def test_lookupSchema_with_dynamic_schema(self):
         fti = DexterityFTI(u"testtype")
-        fti.schema = None # use dynamic schema
+        fti.schema = None  # use dynamic schema
 
-        portal = self.create_dummy(getPhysicalPath=lambda:('', 'site'))
+        portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
         self.mock_utility(portal, ISiteRoot)
 
         schemaName = utils.portalTypeToSchemaName(fti.getId())
@@ -93,14 +86,13 @@ def test_lookupSchema_with_nonexistant_schema(self):
         """
         fti = DexterityFTI(u"testtype")
         fti.schema = 'model.wont.be.imported'
-        portal = self.create_dummy(getPhysicalPath=lambda:('', 'site'))
+        portal = self.create_dummy(getPhysicalPath=lambda: ('', 'site'))
         self.mock_utility(portal, ISiteRoot)
         schemaName = utils.portalTypeToSchemaName(fti.getId())
         setattr(plone.dexterity.schema.generated, schemaName, ITestSchema)
         self.assertEqual(ITestSchema, fti.lookupSchema())
         delattr(plone.dexterity.schema.generated, schemaName)
 
-
     def test_lookupModel_from_string(self):
         fti = DexterityFTI(u"testtype")
         fti.schema = None
@@ -110,7 +102,9 @@ def test_lookupModel_from_string(self):
         model_dummy = Model()
 
         loadString_mock = self.mocker.replace("plone.supermodel.loadString")
-        self.expect(loadString_mock(fti.model_source, policy=u"dexterity")).result(model_dummy)
+        self.expect(
+            loadString_mock(fti.model_source, policy=u"dexterity")
+        ).result(model_dummy)
 
         self.replay()
 
@@ -127,10 +121,15 @@ def test_lookupModel_from_file_with_package(self):
         model_dummy = Model()
 
         import plone.dexterity.tests
-        abs_file = os.path.join(os.path.split(plone.dexterity.tests.__file__)[0], "test.xml")
+        abs_file = os.path.join(
+            os.path.split(plone.dexterity.tests.__file__)[0],
+            "test.xml"
+        )
 
         loadFile_mock = self.mocker.replace("plone.supermodel.loadFile")
-        self.expect(loadFile_mock(abs_file, reload=True, policy=u"dexterity")).result(model_dummy)
+        self.expect(
+            loadFile_mock(abs_file, reload=True, policy=u"dexterity")
+        ).result(model_dummy)
 
         self.replay()
 
@@ -140,7 +139,10 @@ def test_lookupModel_from_file_with_package(self):
     def test_lookupModel_from_file_with_absolute_path(self):
 
         import plone.dexterity.tests
-        abs_file = os.path.join(os.path.split(plone.dexterity.tests.__file__)[0], "test.xml")
+        abs_file = os.path.join(
+            os.path.split(plone.dexterity.tests.__file__)[0],
+            "test.xml"
+        )
 
         fti = DexterityFTI(u"testtype")
         fti.schema = None
@@ -150,7 +152,9 @@ def test_lookupModel_from_file_with_absolute_path(self):
         model_dummy = Model()
 
         loadFile_mock = self.mocker.replace("plone.supermodel.loadFile")
-        self.expect(loadFile_mock(abs_file, reload=True, policy=u"dexterity")).result(model_dummy)
+        self.expect(
+            loadFile_mock(abs_file, reload=True, policy=u"dexterity")
+        ).result(model_dummy)
 
         self.replay()
 
@@ -173,7 +177,9 @@ def test_lookupModel_from_file_with_win32_absolute_path(self):
         self.expect(isfile_mock(fti.model_file)).result(True)
 
         loadFile_mock = self.mocker.replace("plone.supermodel.loadFile")
-        self.expect(loadFile_mock(fti.model_file, reload=True, policy=u"dexterity")).result(model_dummy)
+        self.expect(
+            loadFile_mock(fti.model_file, reload=True, policy=u"dexterity")
+        ).result(model_dummy)
 
         self.replay()
 
@@ -192,14 +198,17 @@ def test_lookupModel_with_schema_only(self):
 
     def test_lookupModel_from_string_with_schema(self):
         fti = DexterityFTI(u"testtype")
-        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema" # effectively ignored
+        # effectively ignored:
+        fti.schema = u"plone.dexterity.tests.schemata.ITestSchema"
         fti.model_source = "<model />"
         fti.model_file = None
 
         model_dummy = Model()
 
         loadString_mock = self.mocker.replace("plone.supermodel.loadString")
-        self.expect(loadString_mock(fti.model_source, policy=u"dexterity")).result(model_dummy)
+        self.expect(
+            loadString_mock(fti.model_source, policy=u"dexterity")
+        ).result(model_dummy)
 
         self.replay()
 
@@ -215,7 +224,6 @@ def test_lookupModel_failure(self):
 
         self.assertRaises(ValueError, fti.lookupModel)
 
-
     def test_fires_modified_event_on_update_property_if_changed(self):
         fti = DexterityFTI(u"testtype")
 
@@ -223,15 +231,21 @@ def test_fires_modified_event_on_update_property_if_changed(self):
         fti.global_allow = False
 
         notify_mock = self.mocker.replace('zope.event.notify')
-        self.expect(notify_mock(mocker.MATCH(lambda x: IObjectModifiedEvent.providedBy(x) \
-                                                        and len(x.descriptions) == 1 \
-                                                        and x.descriptions[0].attribute == 'title' \
-                                                        and x.descriptions[0].oldValue == "Old title")))
+        self.expect(
+            notify_mock(
+                mocker.MATCH(
+                    lambda x: IObjectModifiedEvent.providedBy(x)
+                    and len(x.descriptions) == 1
+                    and x.descriptions[0].attribute == 'title'
+                    and x.descriptions[0].oldValue == "Old title"
+                )
+            )
+        )
 
         self.replay()
 
-        fti._updateProperty('title', "New title") # fires event caught above
-        fti._updateProperty('allow_discussion', False) # does not fire
+        fti._updateProperty('title', "New title")  # fires event caught above
+        fti._updateProperty('allow_discussion', False)  # does not fire
 
     def test_fires_modified_event_on_change_properties_per_changed_property(self):
         fti = DexterityFTI(u"testtype")
@@ -240,18 +254,34 @@ def test_fires_modified_event_on_change_properties_per_changed_property(self):
         fti.global_allow = True
 
         notify_mock = self.mocker.replace('zope.event.notify')
-        self.expect(notify_mock(mocker.MATCH(lambda x: IObjectModifiedEvent.providedBy(x) \
-                                                        and len(x.descriptions) == 1 \
-                                                        and x.descriptions[0].attribute == 'title' \
-                                                        and x.descriptions[0].oldValue == "Old title")))
-
-        self.expect(notify_mock(mocker.MATCH(lambda x: IObjectModifiedEvent.providedBy(x) \
-                                                        and len(x.descriptions) == 1 \
-                                                        and x.descriptions[0].attribute == 'global_allow' \
-                                                        and x.descriptions[0].oldValue == True)))
+        self.expect(
+            notify_mock(
+                mocker.MATCH(
+                    lambda x: IObjectModifiedEvent.providedBy(x)
+                    and len(x.descriptions) == 1
+                    and x.descriptions[0].attribute == 'title'
+                    and x.descriptions[0].oldValue == "Old title"
+                )
+            )
+        )
+
+        self.expect(
+            notify_mock(
+                mocker.MATCH(
+                    lambda x: IObjectModifiedEvent.providedBy(x)
+                    and len(x.descriptions) == 1
+                    and x.descriptions[0].attribute == 'global_allow'
+                    and x.descriptions[0].oldValue is True
+                )
+            )
+        )
         self.replay()
 
-        fti.manage_changeProperties(title="New title", allow_discussion=False, global_allow=False)
+        fti.manage_changeProperties(
+            title="New title",
+            allow_discussion=False,
+            global_allow=False
+        )
 
     def test_checks_permission_in_is_construction_allowed_true(self):
         fti = DexterityFTI(u"testtype")
@@ -262,12 +292,22 @@ def test_checks_permission_in_is_construction_allowed_true(self):
         permission_dummy.id = 'demo.Permission'
         permission_dummy.title = 'Some add permission'
 
-        self.mock_utility(permission_dummy, IPermission, name=u"demo.Permission")
+        self.mock_utility(
+            permission_dummy,
+            IPermission,
+            name=u"demo.Permission"
+        )
 
         security_manager_mock = self.mocker.mock()
-        self.expect(security_manager_mock.checkPermission("Some add permission", container_dummy)).result(True)
-
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
+        self.expect(
+            security_manager_mock.checkPermission(
+                "Some add permission",
+                container_dummy)
+        ).result(True)
+
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
         self.expect(getSecurityManager_mock()).result(security_manager_mock)
 
         self.replay()
@@ -283,12 +323,23 @@ def test_checks_permission_in_is_construction_allowed_false(self):
         permission_dummy.id = 'demo.Permission'
         permission_dummy.title = 'Some add permission'
 
-        self.mock_utility(permission_dummy, IPermission, name=u"demo.Permission")
+        self.mock_utility(
+            permission_dummy,
+            IPermission,
+            name=u"demo.Permission"
+        )
 
         security_manager_mock = self.mocker.mock()
-        self.expect(security_manager_mock.checkPermission("Some add permission", container_dummy)).result(False)
-
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
+        self.expect(
+            security_manager_mock.checkPermission(
+                "Some add permission",
+                container_dummy
+            )
+        ).result(False)
+
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
         self.expect(getSecurityManager_mock()).result(security_manager_mock)
 
         self.replay()
@@ -297,7 +348,7 @@ def test_checks_permission_in_is_construction_allowed_false(self):
 
     def test_no_permission_utility_means_no_construction(self):
         fti = DexterityFTI(u"testtype")
-        fti.add_permission = 'demo.Permission' # not an IPermission utility
+        fti.add_permission = 'demo.Permission'  # not an IPermission utility
         container_dummy = self.create_dummy()
         self.assertEqual(False, fti.isConstructionAllowed(container_dummy))
 
@@ -309,26 +360,43 @@ def test_no_permission_means_no_construction(self):
 
     def test_add_view_url_set_on_creation(self):
         fti = DexterityFTI(u"testtype")
-        self.assertEqual('string:${folder_url}/++add++testtype', fti.add_view_expr)
+        self.assertEqual(
+            'string:${folder_url}/++add++testtype',
+            fti.add_view_expr
+        )
 
     def test_factory_set_on_creation(self):
         fti = DexterityFTI(u"testtype")
         self.assertEqual('testtype', fti.factory)
 
     def test_addview_and_factory_not_overridden_on_creation(self):
-        fti = DexterityFTI(u"testtype",
-                           add_view_expr="string:${folder_url}/@@my-addview",
-                           factory="my.factory")
-        self.assertEqual('string:${folder_url}/@@my-addview', fti.add_view_expr)
+        fti = DexterityFTI(
+            u"testtype",
+            add_view_expr="string:${folder_url}/@@my-addview",
+            factory="my.factory"
+        )
+        self.assertEqual(
+            'string:${folder_url}/@@my-addview',
+            fti.add_view_expr
+        )
         self.assertEqual('my.factory', fti.factory)
 
     def test_meta_type(self):
-        fti = DexterityFTI(u"testtype", klass="plone.dexterity.tests.test_fti.TestClass")
+        fti = DexterityFTI(
+            u"testtype",
+            klass="plone.dexterity.tests.test_fti.TestClass"
+        )
         self.assertEqual(TestClass.meta_type, fti.Metatype())
 
     def test_meta_type_change_class(self):
-        fti = DexterityFTI(u"testtype", klass="plone.dexterity.tests.test_fti.TestClass")
-        fti._updateProperty('klass', "plone.dexterity.tests.test_fti.TestClass2")
+        fti = DexterityFTI(
+            u"testtype",
+            klass="plone.dexterity.tests.test_fti.TestClass"
+        )
+        fti._updateProperty(
+            'klass',
+            "plone.dexterity.tests.test_fti.TestClass2"
+        )
         self.assertEqual(TestClass2.meta_type, fti.Metatype())
 
     def test_title_i18n(self):
@@ -357,11 +425,16 @@ def test_description_i18n(self):
 
     def test_lookupModel_without_schema_policy(self):
         gsm = getGlobalSiteManager()
-        gsm.registerUtility(DexteritySchemaPolicy(), plone.supermodel.interfaces.ISchemaPolicy, name=u"dexterity")
+        gsm.registerUtility(
+            DexteritySchemaPolicy(),
+            plone.supermodel.interfaces.ISchemaPolicy,
+            name=u"dexterity"
+        )
 
         fti = DexterityFTI(u"testtype")
         fti.schema = None
-        fti.model_source = '<model xmlns="http://namespaces.plone.org/supermodel/schema"><schema/></model>'
+        fti.model_source = '<model xmlns="http://namespaces.plone.org/'\
+                           'supermodel/schema"><schema/></model>'
         fti.model_file = None
 
         model = fti.lookupModel()
@@ -374,11 +447,16 @@ def bases(self, schemaName, tree):
 
         gsm = getGlobalSiteManager()
         policy = TestSchemaPolicy()
-        gsm.registerUtility(policy, plone.supermodel.interfaces.ISchemaPolicy, name=u"test")
+        gsm.registerUtility(
+            policy,
+            plone.supermodel.interfaces.ISchemaPolicy,
+            name=u"test"
+        )
 
         fti = DexterityFTI(u"testtype")
         fti.schema = None
-        fti.model_source = '<model xmlns="http://namespaces.plone.org/supermodel/schema"><schema/></model>'
+        fti.model_source = '<model xmlns="http://namespaces.plone.org/'\
+                           'supermodel/schema"><schema/></model>'
         fti.model_file = None
         fti.schema_policy = u"test"
 
@@ -402,25 +480,51 @@ def test_components_registered_on_add(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock)
-
-        # We expect that no components are registered , so look for all registrations
-        self.expect(site_manager_mock.registerUtility(fti, IDexterityFTI, portal_type, info='plone.dexterity.dynamic')).passthrough()
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, portal_type, info='plone.dexterity.dynamic')).passthrough()
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock)
+
+        # We expect that no components are registered , so look for all
+        # registrations
+        self.expect(
+            site_manager_mock.registerUtility(
+                fti,
+                IDexterityFTI,
+                portal_type,
+                info='plone.dexterity.dynamic')
+        ).passthrough()
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                portal_type,
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
 
         self.replay()
 
         ftiAdded(fti, ObjectAddedEvent(fti, container_dummy, fti.getId()))
 
-        site_dummy = self.create_dummy(getSiteManager = lambda: site_manager_mock)
+        site_dummy = self.create_dummy(
+            getSiteManager=lambda: site_manager_mock
+        )
         setSite(site_dummy)
         setHooks()
 
-        self.assertNotEquals(None, queryUtility(IDexterityFTI, name=portal_type))
+        self.assertNotEquals(
+            None,
+            queryUtility(IDexterityFTI, name=portal_type)
+        )
         self.assertNotEquals(None, queryUtility(IFactory, name=portal_type))
 
     def test_components_not_registered_on_add_if_exist(self):
@@ -432,21 +536,42 @@ def test_components_not_registered_on_add_if_exist(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
         self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock)
 
         # Register FTI utility and factory utility
 
         self.mock_utility(fti, IDexterityFTI, name=portal_type)
-        self.mock_utility(DexterityFactory(portal_type), IFactory, name=portal_type)
-
-        # We expect that all components are registered, so do not expect any registrations
-
-        self.expect(site_manager_mock.registerUtility(fti, IDexterityFTI, portal_type)).passthrough().count(0)
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, portal_type)).passthrough().count(0)
+        self.mock_utility(
+            DexterityFactory(portal_type),
+            IFactory,
+            name=portal_type
+        )
+
+        # We expect that all components are registered, so do not expect any
+        # registrations
+
+        self.expect(
+            site_manager_mock.registerUtility(
+                fti,
+                IDexterityFTI,
+                portal_type
+            )
+        ).passthrough().count(0)
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory, portal_type
+            )
+        ).passthrough().count(0)
 
         self.replay()
 
@@ -461,15 +586,31 @@ def test_components_unregistered_on_delete(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # We expect to always be able to unregister without error, even if the
         # components do not exists (as here)
 
-        self.expect(site_manager_mock.unregisterUtility(provided=IDexterityFTI, name=portal_type)).passthrough()
-        self.expect(site_manager_mock.unregisterUtility(provided=IFactory, name=portal_type)).passthrough()
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IDexterityFTI,
+                name=portal_type
+            )
+        ).passthrough()
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IFactory,
+                name=portal_type
+            )
+        ).passthrough()
 
         self.replay()
 
@@ -479,7 +620,9 @@ def test_components_unregistered_on_delete(self):
         # Then remove them again
         ftiRemoved(fti, ObjectRemovedEvent(fti, container_dummy, fti.getId()))
 
-        site_dummy = self.create_dummy(getSiteManager = lambda: site_manager_mock)
+        site_dummy = self.create_dummy(
+            getSiteManager=lambda: site_manager_mock
+        )
         setSite(site_dummy)
         setHooks()
 
@@ -495,14 +638,21 @@ def test_components_unregistered_on_delete_does_not_error_with_no_components(sel
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
         self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock)
 
         # We expect to always be able to unregister without error, even if the
         # components do not exists (as here)
 
-        self.expect(site_manager_mock.unregisterUtility(provided=IDexterityFTI, name=portal_type)).passthrough()
+        self.expect(site_manager_mock.unregisterUtility(
+            provided=IDexterityFTI,
+            name=portal_type)
+        ).passthrough()
 
         self.replay()
 
@@ -517,31 +667,50 @@ def test_global_components_not_unregistered_on_delete(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock)
 
         # Register FTI utility and factory utility
 
         self.mock_utility(fti, IDexterityFTI, name=portal_type)
-        self.mock_utility(DexterityFactory(portal_type), IFactory, name=portal_type)
+        self.mock_utility(
+            DexterityFactory(portal_type),
+            IFactory,
+            name=portal_type
+        )
 
         # We expect to always be able to unregister without error, even if the
-        # component exists. The factory is only unregistered if it was registered
-        # with info='plone.dexterity.dynamic'.
-
-        self.expect(site_manager_mock.unregisterUtility(provided=IDexterityFTI, name=portal_type)).passthrough()
+        # component exists. The factory is only unregistered if it was
+        # registered with info='plone.dexterity.dynamic'.
 
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IDexterityFTI,
+                name=portal_type
+            )
+        ).passthrough()
 
         self.replay()
 
         ftiRemoved(fti, ObjectRemovedEvent(fti, container_dummy, fti.getId()))
 
-        site_dummy = self.create_dummy(getSiteManager = lambda: site_manager_mock)
+        site_dummy = self.create_dummy(
+            getSiteManager=lambda: site_manager_mock
+        )
         setSite(site_dummy)
         setHooks()
 
-        self.assertNotEquals(None, queryUtility(IDexterityFTI, name=portal_type))
+        self.assertNotEquals(
+            None,
+            queryUtility(IDexterityFTI, name=portal_type)
+        )
         self.assertNotEquals(None, queryUtility(IFactory, name=portal_type))
 
     def test_components_reregistered_on_rename(self):
@@ -553,31 +722,73 @@ def test_components_reregistered_on_rename(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # First look for unregistration of all local components
-
-        self.expect(site_manager_mock.unregisterUtility(provided=IDexterityFTI, name=portal_type)).passthrough()
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IDexterityFTI,
+                name=portal_type
+            )
+        ).passthrough()
 
         # Then look for re-registration of global components
-        self.expect(site_manager_mock.registerUtility(fti, IDexterityFTI, portal_type, info='plone.dexterity.dynamic')).passthrough()
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, portal_type, info='plone.dexterity.dynamic')).passthrough()
-
-        self.assertEqual('string:${folder_url}/++add++testtype', fti.add_view_expr)
+        self.expect(
+            site_manager_mock.registerUtility(
+                fti,
+                IDexterityFTI,
+                portal_type,
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                portal_type,
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
+
+        self.assertEqual(
+            'string:${folder_url}/++add++testtype',
+            fti.add_view_expr
+        )
 
         self.replay()
 
-        ftiRenamed(fti, ObjectMovedEvent(fti, container_dummy, fti.getId(), container_dummy, u"newtype"))
-
-        site_dummy = self.create_dummy(getSiteManager = lambda: site_manager_mock)
+        ftiRenamed(
+            fti,
+            ObjectMovedEvent(
+                fti,
+                container_dummy,
+                fti.getId(),
+                container_dummy,
+                u"newtype"
+            )
+        )
+
+        site_dummy = self.create_dummy(
+            getSiteManager=lambda: site_manager_mock
+        )
         setSite(site_dummy)
         setHooks()
 
-        self.assertNotEquals(None, queryUtility(IDexterityFTI, name=portal_type))
+        self.assertNotEquals(
+            None,
+            queryUtility(IDexterityFTI, name=portal_type)
+        )
         self.assertNotEquals(None, queryUtility(IFactory, name=portal_type))
 
     def test_dynamic_schema_refreshed_on_modify_model_file(self):
@@ -592,7 +803,9 @@ class INew(Interface):
         self.expect(fti.lookupModel()).result(model_dummy)
         self.create_dummy()
 
-        site_dummy = self.create_dummy(getPhysicalPath = lambda: ('', 'siteid'))
+        site_dummy = self.create_dummy(
+            getPhysicalPath=lambda: ('', 'siteid')
+        )
         self.mock_utility(site_dummy, ISiteRoot)
 
         class IBlank(Interface):
@@ -605,7 +818,13 @@ class IBlank(Interface):
         setattr(plone.dexterity.schema.generated, schemaName, IBlank)
 
         # Sync this with schema
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('model_file', '')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('model_file', '')
+            )
+        )
 
         self.assertTrue('title' in IBlank)
         self.assertTrue(IBlank['title'].title == u"title")
@@ -622,7 +841,9 @@ class INew(Interface):
         self.expect(fti.lookupModel()).result(model_dummy)
         self.create_dummy()
 
-        site_dummy = self.create_dummy(getPhysicalPath = lambda: ('', 'siteid'))
+        site_dummy = self.create_dummy(
+            getPhysicalPath=lambda: ('', 'siteid')
+        )
         self.mock_utility(site_dummy, ISiteRoot)
 
         class IBlank(Interface):
@@ -635,7 +856,13 @@ class IBlank(Interface):
         setattr(plone.dexterity.schema.generated, schemaName, IBlank)
 
         # Sync this with schema
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('model_source', '')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('model_source', '')
+            )
+        )
 
         self.assertTrue('title' in IBlank)
         self.assertTrue(IBlank['title'].title == u"title")
@@ -654,7 +881,9 @@ class INew(Interface):
         self.expect(fti.lookupModel()).result(model_dummy).count(0, None)
         self.create_dummy()
 
-        site_dummy = self.create_dummy(getPhysicalPath = lambda: ('', 'siteid'))
+        site_dummy = self.create_dummy(
+            getPhysicalPath=lambda: ('', 'siteid')
+        )
         self.mock_utility(site_dummy, ISiteRoot)
 
         self.replay()
@@ -669,7 +898,13 @@ class INew(Interface):
 
         # Sync should not happen now
 
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('schema', '')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('schema', '')
+            )
+        )
 
         self.assertFalse('title' in IBlank)
 
@@ -681,9 +916,15 @@ def test_old_factory_unregistered_after_name_changed_if_dynamic(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # Pretend like we have a utility registered
 
@@ -695,16 +936,35 @@ def test_old_factory_unregistered_after_name_changed_if_dynamic(self):
         self.expect(site_manager_mock.registeredUtilities()).result([reg1])
 
         # Expect this to get removed
-        self.expect(site_manager_mock.unregisterUtility(provided=IFactory, name='old-factory'))
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IFactory,
+                name='old-factory'
+            )
+        )
 
         # And a new one to be created with the new factory name
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, 'new-factory', info='plone.dexterity.dynamic')).passthrough()
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                'new-factory',
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
 
         self.replay()
         fti.factory = 'new-factory'
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('factory', 'old-factory')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('factory', 'old-factory')
+            )
+        )
 
     def test_new_factory_not_registered_after_name_changed_if_exists(self):
         portal_type = u"testtype"
@@ -714,21 +974,45 @@ def test_new_factory_not_registered_after_name_changed_if_exists(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # Create a global default for the new name
-        self.mock_utility(DexterityFactory(portal_type), IFactory, name='new-factory')
+        self.mock_utility(
+            DexterityFactory(portal_type),
+            IFactory,
+            name='new-factory'
+        )
 
         # Factory should not be registered again
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, 'new-factory', info='plone.dexterity.dynamic')).passthrough().count(0)
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                'new-factory',
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough().count(0)
 
         self.replay()
         fti.factory = 'new-factory'
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('factory', 'old-factory')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('factory', 'old-factory')
+            )
+        )
 
     def test_old_factory_not_unregistered_if_not_created_by_dexterity(self):
         portal_type = u"testtype"
@@ -738,9 +1022,15 @@ def test_old_factory_not_unregistered_if_not_created_by_dexterity(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # Pretend like we have a utility registered
 
@@ -752,17 +1042,35 @@ def test_old_factory_not_unregistered_if_not_created_by_dexterity(self):
         self.expect(site_manager_mock.registeredUtilities()).result([reg1])
 
         # This should not be removed, since we didn't create it
-        self.expect(site_manager_mock.unregisterUtility(provided=IFactory, name='old-factory')).count(0)
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IFactory,
+                name='old-factory'
+            )
+        ).count(0)
 
         # A new one may still be created, however
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, 'new-factory', info='plone.dexterity.dynamic')).passthrough()
-
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                'new-factory',
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
 
         self.replay()
         fti.factory = 'new-factory'
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('factory', 'old-factory')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription('factory', 'old-factory')
+            )
+        )
 
     def test_renamed_factory_not_unregistered_if_not_unique(self):
         portal_type = u"testtype"
@@ -774,28 +1082,72 @@ def test_renamed_factory_not_unregistered_if_not_unique(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # Pretend two FTIs are registered, both using common-factory
-        self.expect(site_manager_mock.registeredUtilities()).result([
-            self.create_dummy(provided=IFactory, name='common-factory', info='plone.dexterity.dynamic'),
-            self.create_dummy(component=fti, provided=IDexterityFTI, name='testtype', info='plone.dexterity.dynamic'),
-            self.create_dummy(component=fti2, provided=IDexterityFTI, name='testtype2', info='plone.dexterity.dynamic'),
+        self.expect(
+            site_manager_mock.registeredUtilities()
+        ).result([
+            self.create_dummy(
+                provided=IFactory,
+                name='common-factory',
+                info='plone.dexterity.dynamic'
+            ),
+            self.create_dummy(
+                component=fti,
+                provided=IDexterityFTI,
+                name='testtype',
+                info='plone.dexterity.dynamic'
+            ),
+            self.create_dummy(
+                component=fti2,
+                provided=IDexterityFTI,
+                name='testtype2',
+                info='plone.dexterity.dynamic'
+            ),
         ])
 
         # We shouldn't remove this since fti2 still uses it
-        self.expect(site_manager_mock.unregisterUtility(provided=IFactory, name='common-factory')).count(0)
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IFactory,
+                name='common-factory'
+            )
+        ).count(0)
 
         # And a new one to be created with the new factory name
-        self.expect(site_manager_mock.registerUtility(
-                    mocker.MATCH(lambda x: isinstance(x, DexterityFactory) and x.portal_type == portal_type),
-                    IFactory, 'new-factory', info='plone.dexterity.dynamic')).passthrough()
+        self.expect(
+            site_manager_mock.registerUtility(
+                mocker.MATCH(
+                    lambda x: isinstance(x, DexterityFactory)
+                    and x.portal_type == portal_type
+                ),
+                IFactory,
+                'new-factory',
+                info='plone.dexterity.dynamic'
+            )
+        ).passthrough()
 
         self.replay()
         fti.factory = 'new-factory'
-        ftiModified(fti, ObjectModifiedEvent(fti, DexterityFTIModificationDescription('factory', 'common-factory')))
+        ftiModified(
+            fti,
+            ObjectModifiedEvent(
+                fti,
+                DexterityFTIModificationDescription(
+                    'factory',
+                    'common-factory'
+                )
+            )
+        )
 
     def test_deleted_factory_not_unregistered_if_not_unique(self):
         portal_type = u"testtype"
@@ -808,24 +1160,54 @@ def test_deleted_factory_not_unregistered_if_not_unique(self):
         dummy_site = self.create_dummy()
         self.mock_utility(dummy_site, ISiteRoot)
 
-        site_manager_mock = self.mocker.proxy(PersistentComponents(bases=(getGlobalSiteManager(),)))
-        getSiteManager_mock = self.mocker.replace('zope.component.hooks.getSiteManager')
-        self.expect(getSiteManager_mock(dummy_site)).result(site_manager_mock).count(1,None)
+        site_manager_mock = self.mocker.proxy(
+            PersistentComponents(bases=(getGlobalSiteManager(),))
+        )
+        getSiteManager_mock = self.mocker.replace(
+            'zope.component.hooks.getSiteManager'
+        )
+        self.expect(
+            getSiteManager_mock(dummy_site)
+        ).result(site_manager_mock).count(1, None)
 
         # Pretend two FTIs are registered, both using common-factory
-        # NB: Assuming that "testtype" was already removed when this gets called
-        self.expect(site_manager_mock.registeredUtilities()).result([
-            self.create_dummy(provided=IFactory, name='common-factory', info='plone.dexterity.dynamic'),
-            self.create_dummy(component=fti2, provided=IDexterityFTI, name='testtype2', info='plone.dexterity.dynamic'),
+        # NB: Assuming that "testtype" was already removed when this gets
+        #     called
+        self.expect(
+            site_manager_mock.registeredUtilities()
+        ).result([
+            self.create_dummy(
+                provided=IFactory,
+                name='common-factory',
+                info='plone.dexterity.dynamic'
+            ),
+            self.create_dummy(
+                component=fti2,
+                provided=IDexterityFTI,
+                name='testtype2',
+                info='plone.dexterity.dynamic'
+            ),
         ])
 
         # We shouldn't remove this since fti2 still uses it
-        self.expect(site_manager_mock.unregisterUtility(provided=IFactory, name='common-factory')).count(0)
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IFactory,
+                name='common-factory'
+            )
+        ).count(0)
+
         # The type itself should be removed though
-        self.expect(site_manager_mock.unregisterUtility(provided=IDexterityFTI, name=u"testtype")).count(1)
+        self.expect(
+            site_manager_mock.unregisterUtility(
+                provided=IDexterityFTI,
+                name=u"testtype"
+            )
+        ).count(1)
 
         self.replay()
         ftiRemoved(fti, ObjectRemovedEvent(fti, container_dummy, fti.getId()))
 
+
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_primary.py b/plone/dexterity/tests/test_primary.py
index 29228bb..6019b5a 100644
--- a/plone/dexterity/tests/test_primary.py
+++ b/plone/dexterity/tests/test_primary.py
@@ -1,14 +1,15 @@
-import unittest
+# -*- coding: utf-8 -*-
 from plone.dexterity.content import Item
 from plone.dexterity.fti import DexterityFTI
 from plone.dexterity.interfaces import IDexterityFTI
 from plone.dexterity.primary import PrimaryFieldInfo
 from plone.mocktestcase import MockTestCase
 from plone.rfc822.interfaces import IPrimaryField
-from plone.rfc822.interfaces import IPrimaryFieldInfo
 from zope import schema
 from zope.interface import Interface
 from zope.interface import alsoProvides
+import unittest
+
 
 class PrimaryFieldInfoTestCase(MockTestCase):
     def test_primary_field_info(self):
@@ -21,7 +22,7 @@ class ITest(Interface):
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITest).count(0, None)
         self.expect(fti_mock.behaviors).result([]).count(0, None)
-        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")        
+        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
         self.replay()
 
         item = Item('item')
diff --git a/plone/dexterity/tests/test_schema.py b/plone/dexterity/tests/test_schema.py
index 469fc48..8c07edc 100644
--- a/plone/dexterity/tests/test_schema.py
+++ b/plone/dexterity/tests/test_schema.py
@@ -1,21 +1,17 @@
-import unittest
+# -*- coding: utf-8 -*-
+from plone.dexterity import schema
+from plone.dexterity import utils
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IContentType
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.interfaces import IDexteritySchema
 from plone.mocktestcase import MockTestCase
-
+from plone.supermodel.model import Model
 from zope.interface import Interface
 from zope.interface.interface import InterfaceClass
-
+import unittest
 import zope.schema
 
-from plone.dexterity.interfaces import IContentType
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.interfaces import IDexteritySchema
-
-from plone.dexterity.fti import DexterityFTI
-
-from plone.dexterity import schema
-from plone.dexterity import utils
-
-from plone.supermodel.model import Model
 
 class TestSchemaModuleFactory(MockTestCase):
 
@@ -65,6 +61,7 @@ def test_named_schema(self):
         # Mock schema model
         class IDummy(Interface):
             dummy = zope.schema.TextLine(title=u"Dummy")
+
         class INamedDummy(Interface):
             named = zope.schema.TextLine(title=u"Named")
         mock_model = Model({u"": IDummy,
@@ -80,11 +77,18 @@ class INamedDummy(Interface):
 
         factory = schema.SchemaModuleFactory()
 
-        schemaName = utils.portalTypeToSchemaName('testtype', schema=u"named", prefix='site')
+        schemaName = utils.portalTypeToSchemaName(
+            'testtype',
+            schema=u"named",
+            prefix='site'
+        )
         klass = factory(schemaName, schema.generated)
 
         self.assertTrue(isinstance(klass, InterfaceClass))
-        self.assertFalse(klass.isOrExtends(IDexteritySchema)) # only default schema gets this
+
+        # only default schema gets this:
+        self.assertFalse(klass.isOrExtends(IDexteritySchema))
+
         self.assertFalse(IContentType.providedBy(klass))
         self.assertEqual(schemaName, klass.__name__)
         self.assertEqual('plone.dexterity.schema.generated', klass.__module__)
@@ -139,5 +143,6 @@ class IDummy(Interface):
         # Now we get the fields from the FTI's model
         self.assertEqual(('dummy',), tuple(zope.schema.getFieldNames(klass)))
 
+
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_schema_cache.py b/plone/dexterity/tests/test_schema_cache.py
index cc45528..56f482e 100644
--- a/plone/dexterity/tests/test_schema_cache.py
+++ b/plone/dexterity/tests/test_schema_cache.py
@@ -1,12 +1,11 @@
-import unittest
+# -*- coding: utf-8 -*-
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.schema import SCHEMA_CACHE
 from plone.mocktestcase import MockTestCase
-
 from zope.interface import Interface
+import unittest
 
-from plone.dexterity.interfaces import IDexterityFTI
-
-from plone.dexterity.fti import DexterityFTI
-from plone.dexterity.schema import SCHEMA_CACHE
 
 class TestSchemaCache(MockTestCase):
 
@@ -41,7 +40,7 @@ class ISchema2(Interface):
         # FTI mock
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
         self.expect(fti_mock.lookupSchema()).result(ISchema1)
-        self.expect(fti_mock.lookupSchema()).result(ISchema2).count(0,None)
+        self.expect(fti_mock.lookupSchema()).result(ISchema2).count(0, None)
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
         self.replay()
@@ -62,7 +61,7 @@ class ISchema2(Interface):
         # FTI mock
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
         self.expect(fti_mock.lookupSchema()).result(ISchema1)
-        self.expect(fti_mock.lookupSchema()).result(ISchema2).count(0,None)
+        self.expect(fti_mock.lookupSchema()).result(ISchema2).count(0, None)
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
         self.replay()
@@ -135,5 +134,6 @@ class ISchema1(Interface):
         self.assertTrue(schema1 is None)
         self.assertTrue(schema2 is schema3 is ISchema1)
 
+
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_security.py b/plone/dexterity/tests/test_security.py
index 14a8c54..8bc76ba 100644
--- a/plone/dexterity/tests/test_security.py
+++ b/plone/dexterity/tests/test_security.py
@@ -1,20 +1,15 @@
-import unittest
+# -*- coding: utf-8 -*-
+from plone.autoform.interfaces import READ_PERMISSIONS_KEY
+from plone.dexterity.content import Item, Container
+from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.schema import SCHEMA_CACHE
 from plone.mocktestcase import MockTestCase
-
 from zope.interface import Interface
-import zope.schema
-
 from zope.security.interfaces import IPermission
 from zope.security.permission import Permission
-
-from plone.dexterity.schema import SCHEMA_CACHE
-
-from plone.dexterity.content import Item, Container
-
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.fti import DexterityFTI
-
-from plone.autoform.interfaces import READ_PERMISSIONS_KEY
+import unittest
+import zope.schema
 
 
 class TestAttributeProtection(MockTestCase):
@@ -26,12 +21,15 @@ def tearDown(self):
         SCHEMA_CACHE.cache_enabled = True
 
     def test_item(self):
-        
+
         # Mock schema model
         class ITestSchema(Interface):
             test = zope.schema.TextLine(title=u"Test")
-        ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(test='zope2.View', foo='foo.View'))
-        
+        ITestSchema.setTaggedValue(
+            READ_PERMISSIONS_KEY,
+            dict(test='zope2.View', foo='foo.View')
+        )
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITestSchema)
@@ -41,38 +39,66 @@ class ITestSchema(Interface):
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
 
         # Mock permissions
-        self.mock_utility(Permission(u'zope2.View', u"View"), IPermission, u'zope2.View')
-        self.mock_utility(Permission(u'foo.View', u"View foo"), IPermission, u'foo.View')
+        self.mock_utility(
+            Permission(u'zope2.View', u"View"),
+            IPermission,
+            u'zope2.View'
+        )
+        self.mock_utility(
+            Permission(u'foo.View', u"View foo"),
+            IPermission,
+            u'foo.View'
+        )
 
         # Content item
         item = Item('test')
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         # Check permission
-        
+
         securityManager_mock = self.mocker.mock()
-        self.expect(securityManager_mock.checkPermission("View", item)).result(False)
-        self.expect(securityManager_mock.checkPermission("View foo", item)).result(True)
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
-        self.expect(getSecurityManager_mock()).result(securityManager_mock).count(2)
+        self.expect(
+            securityManager_mock.checkPermission("View", item)
+        ).result(False)
+
+        self.expect(
+            securityManager_mock.checkPermission("View foo", item)
+        ).result(True)
+
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
+        self.expect(
+            getSecurityManager_mock()
+        ).result(securityManager_mock).count(2)
 
         self.mocker.replay()
-        
-        self.assertFalse(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        
+
+        self.assertFalse(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+
         # Unknown attributes are allowed
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_container(self):
-        
+
         # Mock schema model
         class ITestSchema(Interface):
             test = zope.schema.TextLine(title=u"Test")
-        ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(test='zope2.View', foo='foo.View'))
-        
+
+        ITestSchema.setTaggedValue(
+            READ_PERMISSIONS_KEY,
+            dict(test='zope2.View', foo='foo.View')
+        )
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITestSchema)
@@ -82,40 +108,74 @@ class ITestSchema(Interface):
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
 
         # Mock permissions
-        self.mock_utility(Permission(u'zope2.View', u"View"), IPermission, u'zope2.View')
-        self.mock_utility(Permission(u'foo.View', u"View foo"), IPermission, u'foo.View')
+        self.mock_utility(
+            Permission(u'zope2.View', u"View"),
+            IPermission,
+            u'zope2.View'
+        )
+        self.mock_utility(
+            Permission(u'foo.View', u"View foo"),
+            IPermission,
+            u'foo.View'
+        )
 
         # Content item
         container = Container('test')
         container.portal_type = u"testtype"
         container.test = u"foo"
         container.foo = u"bar"
-        
+
         # Check permission
         securityManager_mock = self.mocker.mock()
-        self.expect(securityManager_mock.checkPermission("View", container)).result(False)
-        self.expect(securityManager_mock.checkPermission("View foo", container)).result(True)
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
-        self.expect(getSecurityManager_mock()).result(securityManager_mock).count(2)
+        self.expect(
+            securityManager_mock.checkPermission("View", container)
+        ).result(False)
+        self.expect(
+            securityManager_mock.checkPermission("View foo", container)
+        ).result(True)
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
+        self.expect(
+            getSecurityManager_mock()
+        ).result(securityManager_mock).count(2)
 
         self.mocker.replay()
-        
-        self.assertFalse(container.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(container.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        
+
+        self.assertFalse(
+            container.__allow_access_to_unprotected_subobjects__(
+                'test',
+                u"foo"
+            )
+        )
+        self.assertTrue(
+            container.__allow_access_to_unprotected_subobjects__(
+                'foo',
+                u"bar"
+            )
+        )
+
         # Unknown attributes are allowed
-        self.assertTrue(container.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+        self.assertTrue(
+            container.__allow_access_to_unprotected_subobjects__(
+                'random',
+                u"stuff"
+            )
+        )
 
     def test_subclass(self):
-        
+
         # Mock schema model
         class ITestSchema(Interface):
             test = zope.schema.TextLine(title=u"Test")
-        ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(test='zope2.View', foo='foo.View'))
-        
+        ITestSchema.setTaggedValue(
+            READ_PERMISSIONS_KEY,
+            dict(test='zope2.View', foo='foo.View')
+        )
+
         class Foo(Item):
             pass
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITestSchema)
@@ -125,36 +185,58 @@ class Foo(Item):
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
 
         # Mock permissions
-        self.mock_utility(Permission(u'zope2.View', u"View"), IPermission, u'zope2.View')
-        self.mock_utility(Permission(u'foo.View', u"View foo"), IPermission, u'foo.View')
+        self.mock_utility(
+            Permission(u'zope2.View', u"View"),
+            IPermission,
+            u'zope2.View'
+        )
+        self.mock_utility(
+            Permission(u'foo.View', u"View foo"),
+            IPermission,
+            u'foo.View'
+        )
 
         # Content item
         item = Foo('test')
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         # Check permission
         securityManager_mock = self.mocker.mock()
-        self.expect(securityManager_mock.checkPermission("View", item)).result(False)
-        self.expect(securityManager_mock.checkPermission("View foo", item)).result(True)
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
-        self.expect(getSecurityManager_mock()).result(securityManager_mock).count(2)
+        self.expect(
+            securityManager_mock.checkPermission("View", item)
+        ).result(False)
+        self.expect(
+            securityManager_mock.checkPermission("View foo", item)
+        ).result(True)
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
+        self.expect(
+            getSecurityManager_mock()
+        ).result(securityManager_mock).count(2)
 
         self.mocker.replay()
-        
-        self.assertFalse(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        
+
+        self.assertFalse(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+
         # Unknown attributes are allowed
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_no_tagged_value(self):
-        
+
         # Mock schema model
         class ITestSchema(Interface):
             test = zope.schema.TextLine(title=u"Test")
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITestSchema)
@@ -168,23 +250,29 @@ class ITestSchema(Interface):
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         self.mocker.replay()
-        
+
         # Everything allowed
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+
         # Unknown attributes are allowed
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_no_read_permission(self):
-        
+
         # Mock schema model
         class ITestSchema(Interface):
             test = zope.schema.TextLine(title=u"Test")
         ITestSchema.setTaggedValue(READ_PERMISSIONS_KEY, dict(foo='foo.View'))
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITestSchema)
@@ -194,33 +282,49 @@ class ITestSchema(Interface):
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
 
         # Mock permissions
-        self.mock_utility(Permission(u'foo.View', u"View foo"), IPermission, u'foo.View')
+        self.mock_utility(
+            Permission(u'foo.View', u"View foo"), IPermission, u'foo.View'
+        )
 
         # Content item
         item = Item('test')
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         # Check permission
         securityManager_mock = self.mocker.mock()
-        self.expect(securityManager_mock.checkPermission("View foo", item)).result(True)
-        getSecurityManager_mock = self.mocker.replace('AccessControl.getSecurityManager')
-        self.expect(getSecurityManager_mock()).result(securityManager_mock).count(1)
+        self.expect(
+            securityManager_mock.checkPermission("View foo", item)
+        ).result(True)
+        getSecurityManager_mock = self.mocker.replace(
+            'AccessControl.getSecurityManager'
+        )
+        self.expect(
+            getSecurityManager_mock()
+        ).result(securityManager_mock).count(1)
 
         self.mocker.replay()
-        
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        
+
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+
         # Unknown attributes are allowed
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_no_schema(self):
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
-        self.expect(fti_mock.lookupSchema()).result(None).count(3) # not cached this time
+        self.expect(
+            fti_mock.lookupSchema()
+        ).result(None).count(3)  # not cached this time
 
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
 
@@ -229,18 +333,24 @@ def test_no_schema(self):
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         self.mocker.replay()
-        
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_schema_exception(self):
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
-        
+
         self.expect(fti_mock.lookupSchema()).count(3).throw(AttributeError)
 
         self.mock_utility(fti_mock, IDexterityFTI, u'testtype')
@@ -250,15 +360,21 @@ def test_schema_exception(self):
         item.portal_type = u"testtype"
         item.test = u"foo"
         item.foo = u"bar"
-        
+
         self.mocker.replay()
-        
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('test', u"foo"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('foo', u"bar"))
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('random', u"stuff"))
+
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('test', u"foo")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('foo', u"bar")
+        )
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('random', u"stuff")
+        )
 
     def test_empty_name(self):
-        
+
         # Mock FTI
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).count(0)
@@ -267,10 +383,13 @@ def test_empty_name(self):
         # Content item
         item = Item('test')
         item.portal_type = u"testtype"
-        
+
         self.mocker.replay()
-        
-        self.assertTrue(item.__allow_access_to_unprotected_subobjects__('', u"foo"))
+
+        self.assertTrue(
+            item.__allow_access_to_unprotected_subobjects__('', u"foo")
+        )
+
 
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/tests/test_utils.py b/plone/dexterity/tests/test_utils.py
index 8ee228c..381df39 100644
--- a/plone/dexterity/tests/test_utils.py
+++ b/plone/dexterity/tests/test_utils.py
@@ -1,44 +1,67 @@
-import unittest
+# -*- coding: utf-8 -*-
+from Products.CMFCore.interfaces import ISiteRoot
+from plone.dexterity import utils
 from plone.mocktestcase import MockTestCase
+import unittest
 
-from plone.dexterity import utils
-from Products.CMFCore.interfaces import ISiteRoot
 
 class TestUtils(MockTestCase):
 
     def test_portalTypeToSchemaName_with_schema_and_prefix(self):
-        self.assertEqual('prefix_0_type_0_schema',
-            utils.portalTypeToSchemaName('type', 'schema', 'prefix'))
-        self.assertEqual('prefix_0_type',
-            utils.portalTypeToSchemaName('type', '', 'prefix'))
-        self.assertEqual('prefix_0_type_1_one_2_two',
-            utils.portalTypeToSchemaName('type one.two', '', 'prefix'))
+        self.assertEqual(
+            'prefix_0_type_0_schema',
+            utils.portalTypeToSchemaName('type', 'schema', 'prefix')
+        )
+        self.assertEqual(
+            'prefix_0_type',
+            utils.portalTypeToSchemaName('type', '', 'prefix')
+        )
+        self.assertEqual(
+            'prefix_0_type_1_one_2_two',
+            utils.portalTypeToSchemaName('type one.two', '', 'prefix')
+        )
 
     def test_portalTypeToSchemaName_looks_up_portal_for_prefix(self):
         portal_mock = self.mocker.mock()
-        self.expect(portal_mock.getPhysicalPath()).result(('', 'foo', 'portalid'))
+        self.expect(
+            portal_mock.getPhysicalPath()
+        ).result(('', 'foo', 'portalid'))
         self.mock_utility(portal_mock, ISiteRoot)
 
         self.replay()
 
-        self.assertEqual('foo_4_portalid_0_type',
-            utils.portalTypeToSchemaName('type'))
+        self.assertEqual(
+            'foo_4_portalid_0_type',
+            utils.portalTypeToSchemaName('type')
+        )
 
     def test_schemaNameToPortalType(self):
-        self.assertEqual('type',
-            utils.schemaNameToPortalType('prefix_0_type_0_schema'))
-        self.assertEqual('type',
-            utils.schemaNameToPortalType('prefix_0_type'))
-        self.assertEqual('type one.two',
-            utils.schemaNameToPortalType('prefix_0_type_1_one_2_two'))
+        self.assertEqual(
+            'type',
+            utils.schemaNameToPortalType('prefix_0_type_0_schema')
+        )
+        self.assertEqual(
+            'type',
+            utils.schemaNameToPortalType('prefix_0_type')
+        )
+        self.assertEqual(
+            'type one.two',
+            utils.schemaNameToPortalType('prefix_0_type_1_one_2_two')
+        )
 
     def test_splitSchemaName(self):
-        self.assertEqual(('prefix', 'type', 'schema',),
-            utils.splitSchemaName('prefix_0_type_0_schema'))
-        self.assertEqual(('prefix', 'type', '',),
-            utils.splitSchemaName('prefix_0_type'))
-        self.assertEqual(('prefix', 'type one.two', '',),
-            utils.splitSchemaName('prefix_0_type_1_one_2_two'))
+        self.assertEqual(
+            ('prefix', 'type', 'schema',),
+            utils.splitSchemaName('prefix_0_type_0_schema')
+        )
+        self.assertEqual(
+            ('prefix', 'type', '',),
+            utils.splitSchemaName('prefix_0_type')
+        )
+        self.assertEqual(
+            ('prefix', 'type one.two', '',),
+            utils.splitSchemaName('prefix_0_type_1_one_2_two')
+        )
 
     def test_getAdditionalSchemata(self):
         from plone.dexterity.interfaces import IDexterityFTI
diff --git a/plone/dexterity/tests/test_views.py b/plone/dexterity/tests/test_views.py
index 864be3f..ffb51fe 100644
--- a/plone/dexterity/tests/test_views.py
+++ b/plone/dexterity/tests/test_views.py
@@ -1,39 +1,32 @@
-import unittest
-import mocker
-from plone.mocktestcase import MockTestCase
-
-from zope.interface import implements, Interface, alsoProvides
-from zope.component import adapts, provideAdapter
-
-from z3c.form.interfaces import IWidgets
-from z3c.form.interfaces import IActions
-from z3c.form.action import Actions
-from z3c.form.field import FieldWidgets
-
+# -*- coding: utf-8 -*-
+from AccessControl import Unauthorized
+from Products.statusmessages.interfaces import IStatusMessage
 from plone.autoform.interfaces import IFormFieldProvider
 from plone.behavior.interfaces import IBehaviorAssignable
-
-from plone.dexterity.interfaces import IDexterityFTI
-from plone.dexterity.interfaces import IEditBegunEvent
-from plone.dexterity.interfaces import IAddBegunEvent
-from plone.dexterity.interfaces import IEditCancelledEvent
-from plone.dexterity.interfaces import IAddCancelledEvent
-from plone.dexterity.interfaces import IEditFinishedEvent
-
 from plone.dexterity.browser.add import DefaultAddForm
 from plone.dexterity.browser.add import DefaultAddView
 from plone.dexterity.browser.edit import DefaultEditForm
 from plone.dexterity.browser.view import DefaultView
-
 from plone.dexterity.content import Item, Container
 from plone.dexterity.fti import DexterityFTI
-
-from zope.publisher.browser import TestRequest as TestRequestBase
+from plone.dexterity.interfaces import IAddBegunEvent
+from plone.dexterity.interfaces import IAddCancelledEvent
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.interfaces import IEditBegunEvent
+from plone.dexterity.interfaces import IEditCancelledEvent
+from plone.dexterity.interfaces import IEditFinishedEvent
+from plone.mocktestcase import MockTestCase
+from z3c.form.action import Actions
+from z3c.form.field import FieldWidgets
+from z3c.form.interfaces import IActions
+from z3c.form.interfaces import IWidgets
+from zope.component import adapts, provideAdapter
 from zope.container.interfaces import INameChooser
+from zope.interface import implements, Interface, alsoProvides
+from zope.publisher.browser import TestRequest as TestRequestBase
+import mocker
+import unittest
 
-from AccessControl import Unauthorized
-
-from Products.statusmessages.interfaces import IStatusMessage
 
 class TestRequest(TestRequestBase):
     """Zope 3's TestRequest doesn't support item assignment, but Zope 2's
@@ -42,20 +35,25 @@ class TestRequest(TestRequestBase):
     def __setitem__(self, key, value):
         pass
 
+
 class ISchema(Interface):
     pass
 
+
 class IBehaviorOne(Interface):
     pass
 alsoProvides(IBehaviorOne, IFormFieldProvider)
 
+
 class IBehaviorTwo(Interface):
     pass
 alsoProvides(IBehaviorTwo, IFormFieldProvider)
 
+
 class IBehaviorThree(Interface):
     pass
 
+
 class NoBehaviorAssignable(object):
     # We will use this simple class to check that registering our own
     # IBehaviorAssignable adapter has an effect.
@@ -125,13 +123,15 @@ def test_add(self):
 
         self.expect(container._setObject(u"newid", obj)).result(u"newid")
         self.expect(container._getOb(u"newid")).result(obj)
-        self.expect(container.absolute_url()).result("http://nohost/plone/container")
+        self.expect(
+            container.absolute_url()
+        ).result("http://nohost/plone/container")
 
         obj.id = u"newid"
 
         self.expect(obj.id).result(u"newid")
         self.expect(obj.id).result(u"newid")
-        self.expect(obj.portal_type).result("testtype").count(0,None)
+        self.expect(obj.portal_type).result("testtype").count(0, None)
 
         # New object's FTI
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
@@ -141,15 +141,21 @@ def test_add(self):
         # Container FTI
         container_fti_mock = self.mocker.proxy(DexterityFTI(u"containertype"))
         self.expect(container_fti_mock.allowType(u"testtype")).result(True)
-        self.mock_utility(container_fti_mock, IDexterityFTI, name=u"containertype")
+        self.mock_utility(
+            container_fti_mock,
+            IDexterityFTI,
+            name=u"containertype"
+        )
 
         self.expect(container.getTypeInfo()).result(container_fti_mock)
 
         # Name chooser
         class NameChooser(object):
             implements(INameChooser)
+
             def __init__(self, context):
                 pass
+
             def chooseName(self, name, object):
                 return u"newid"
 
@@ -174,11 +180,13 @@ def test_add_raises_unauthorized_if_construction_not_allowed(self):
 
         # Container FTI
         container_fti_mock = self.mocker.proxy(DexterityFTI(u"containertype"))
-        self.mock_utility(container_fti_mock, IDexterityFTI, name=u"containertype")
+        self.mock_utility(
+            container_fti_mock, IDexterityFTI, name=u"containertype"
+        )
 
         self.expect(container.getTypeInfo()).result(container_fti_mock)
 
-        self.expect(obj.portal_type).result("testtype").count(0,None)
+        self.expect(obj.portal_type).result("testtype").count(0, None)
 
         self.replay()
 
@@ -193,7 +201,7 @@ def test_add_raises_value_error_if_type_not_addable(self):
         obj = self.mocker.mock()
         request = TestRequest()
 
-        self.expect(obj.portal_type).result("testtype").count(0,None)
+        self.expect(obj.portal_type).result("testtype").count(0, None)
 
         # New object's FTI
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
@@ -203,7 +211,11 @@ def test_add_raises_value_error_if_type_not_addable(self):
         # Container FTI
         container_fti_mock = self.mocker.proxy(DexterityFTI(u"containertype"))
         self.expect(container_fti_mock.allowType(u"testtype")).result(False)
-        self.mock_utility(container_fti_mock, IDexterityFTI, name=u"containertype")
+        self.mock_utility(
+            container_fti_mock,
+            IDexterityFTI,
+            name=u"containertype"
+        )
 
         self.expect(container.getTypeInfo()).result(container_fti_mock)
 
@@ -253,9 +265,15 @@ def test_schema_lookup(self):
 
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
         self.expect(fti_mock.lookupSchema()).result(ISchema)
-        self.expect(fti_mock.behaviors).result((IBehaviorOne.__identifier__,
-                                                IBehaviorTwo.__identifier__,
-                                                IBehaviorThree.__identifier__))
+        self.expect(
+            fti_mock.behaviors
+        ).result(
+            (
+                IBehaviorOne.__identifier__,
+                IBehaviorTwo.__identifier__,
+                IBehaviorThree.__identifier__
+            )
+        )
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
         self.expect(fti_mock.behaviors).result([])
 
@@ -267,7 +285,10 @@ def test_schema_lookup(self):
         view.portal_type = u"testtype"
 
         self.assertEqual(ISchema, view.schema)
-        self.assertEqual([IBehaviorOne, IBehaviorTwo], list(view.additionalSchemata,))
+        self.assertEqual(
+            [IBehaviorOne, IBehaviorTwo],
+            list(view.additionalSchemata,)
+        )
 
         # When we register our own IBehaviorAssignable we can
         # influence what goes into the additionalSchemata:
@@ -288,7 +309,11 @@ def test_fires_add_begun_event(self):
         self.mocker.count(0, 100)
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
-        self.mock_adapter(FieldWidgets, IWidgets, (Interface, Interface, Interface))
+        self.mock_adapter(
+            FieldWidgets,
+            IWidgets,
+            (Interface, Interface, Interface)
+        )
 
         self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))
 
@@ -311,14 +336,17 @@ def test_fires_add_cancelled_event(self):
         # Context and request
 
         context_mock = self.create_dummy(portal_type=u'testtype')
-        context_mock.absolute_url = lambda *a, **kw: 'http://127.0.0.1/plone/item'
+        context_mock.absolute_url = \
+            lambda *a, **kw: 'http://127.0.0.1/plone/item'
         request_mock = TestRequest()
 
         # mock status message
         class StatusMessage(object):
             implements(IStatusMessage)
+
             def __init__(self, request):
                 pass
+
             def addStatusMessage(self, msg, type=''):
                 pass
         self.mock_adapter(StatusMessage, IStatusMessage, (Interface,))
@@ -392,7 +420,10 @@ def test_schema_lookup(self):
         view.portal_type = u"testtype"
 
         self.assertEqual(ISchema, view.schema)
-        self.assertEqual([IBehaviorOne, IBehaviorTwo], list(view.additionalSchemata,))
+        self.assertEqual(
+            [IBehaviorOne, IBehaviorTwo],
+            list(view.additionalSchemata,)
+        )
 
         # When we register our own IBehaviorAssignable we can
         # influence what goes into the additionalSchemata:
@@ -413,7 +444,11 @@ def test_fires_edit_begun_event(self):
         self.mocker.count(0, 100)
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
-        self.mock_adapter(FieldWidgets, IWidgets, (Interface, Interface, Interface))
+        self.mock_adapter(
+            FieldWidgets,
+            IWidgets,
+            (Interface, Interface, Interface)
+        )
         self.mock_adapter(Actions, IActions, (Interface, Interface, Interface))
 
         # mock notify
@@ -435,14 +470,17 @@ def test_fires_edit_cancelled_event(self):
         # Context and request
 
         context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
-        context_mock.absolute_url = lambda *a, **kw: 'http://127.0.0.1/plone/item'
+        context_mock.absolute_url = \
+            lambda *a, **kw: 'http://127.0.0.1/plone/item'
         request_mock = TestRequest()
 
         # mock status message
         class StatusMessage(object):
             implements(IStatusMessage)
+
             def __init__(self, request):
                 pass
+
             def addStatusMessage(self, msg, type=''):
                 pass
         self.mock_adapter(StatusMessage, IStatusMessage, (Interface,))
@@ -464,14 +502,17 @@ def test_fires_edit_finished_event(self):
         # Context and request
 
         context_mock = self.create_dummy(portal_type=u'testtype', title=u'foo')
-        context_mock.absolute_url = lambda *a, **kw: 'http://127.0.0.1/plone/item'
+        context_mock.absolute_url = \
+            lambda *a, **kw: 'http://127.0.0.1/plone/item'
         request_mock = TestRequest()
 
         # mock status message
         class StatusMessage(object):
             implements(IStatusMessage)
+
             def __init__(self, request):
                 pass
+
             def addStatusMessage(self, msg, type=''):
                 pass
         self.mock_adapter(StatusMessage, IStatusMessage, (Interface,))
@@ -491,7 +532,6 @@ def addStatusMessage(self, msg, type=''):
         view.handleApply(view, {})
 
 
-
 class TestDefaultView(MockTestCase):
 
     def test_schema_lookup(self):
@@ -505,9 +545,15 @@ def test_schema_lookup(self):
 
         fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
         self.expect(fti_mock.lookupSchema()).result(ISchema)
-        self.expect(fti_mock.behaviors).result((IBehaviorOne.__identifier__,
-                                                IBehaviorTwo.__identifier__,
-                                                IBehaviorThree.__identifier__))
+        self.expect(
+            fti_mock.behaviors
+        ).result(
+            (
+                IBehaviorOne.__identifier__,
+                IBehaviorTwo.__identifier__,
+                IBehaviorThree.__identifier__
+            )
+        )
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
         # Form
@@ -517,7 +563,10 @@ def test_schema_lookup(self):
         view = DefaultView(context_mock, request_mock)
 
         self.assertEqual(ISchema, view.schema)
-        self.assertEqual([IBehaviorOne, IBehaviorTwo], list(view.additionalSchemata,))
+        self.assertEqual(
+            [IBehaviorOne, IBehaviorTwo],
+            list(view.additionalSchemata,)
+        )
 
         # When we register our own IBehaviorAssignable we can
         # influence what goes into the additionalSchemata:
diff --git a/plone/dexterity/tests/test_webdav.py b/plone/dexterity/tests/test_webdav.py
index e762e7f..4c7cc11 100644
--- a/plone/dexterity/tests/test_webdav.py
+++ b/plone/dexterity/tests/test_webdav.py
@@ -1,65 +1,50 @@
-import re
-import unittest
-from StringIO import StringIO
-from email.Message import Message
-from mocker import ANY
-
-from plone.mocktestcase import MockTestCase
-
+# -*- coding: utf-8 -*-
 from OFS.Folder import Folder
 from OFS.SimpleItem import SimpleItem
-from zExceptions import Unauthorized, MethodNotAllowed, Forbidden
-
-from webdav.NullResource import NullResource
-
-from plone.dexterity.content import Item, Container
-from zope.publisher.browser import TestRequest
-
-from zope.interface import Interface
-from zope.interface import implements
-from zope.interface import alsoProvides
-
-from zope.component.interfaces import IFactory
-
-from zope.lifecycleevent.interfaces import IObjectModifiedEvent
-from zope.size.interfaces import ISized
-
-from zope import schema
-
-from zope.filerepresentation.interfaces import IRawReadFile
-from zope.filerepresentation.interfaces import IRawWriteFile
-
-from zope.filerepresentation.interfaces import IDirectoryFactory
-from zope.filerepresentation.interfaces import IFileFactory
-
-from ZPublisher.Iterators import IStreamIterator
+from StringIO import StringIO
 from ZPublisher.HTTPResponse import HTTPResponse
-
-from plone.rfc822.interfaces import IPrimaryField
+from ZPublisher.Iterators import IStreamIterator
+from email.Message import Message
+from mocker import ANY
 from plone.autoform.interfaces import IFormFieldProvider
 from plone.behavior.interfaces import IBehaviorAssignable
-
-from plone.dexterity.interfaces import DAV_FOLDER_DATA_ID
-from plone.dexterity.interfaces import IDexterityFTI
-
-from plone.dexterity.filerepresentation import FolderDataResource
-
+from plone.dexterity.browser.traversal import DexterityPublishTraverse
+from plone.dexterity.content import Item, Container
 from plone.dexterity.filerepresentation import DefaultDirectoryFactory
 from plone.dexterity.filerepresentation import DefaultFileFactory
-
 from plone.dexterity.filerepresentation import DefaultReadFile
 from plone.dexterity.filerepresentation import DefaultWriteFile
-from plone.dexterity.schema import SCHEMA_CACHE
-
+from plone.dexterity.filerepresentation import FolderDataResource
 from plone.dexterity.fti import DexterityFTI
+from plone.dexterity.interfaces import DAV_FOLDER_DATA_ID
+from plone.dexterity.interfaces import IDexterityFTI
+from plone.dexterity.schema import SCHEMA_CACHE
+from plone.mocktestcase import MockTestCase
+from plone.rfc822.interfaces import IPrimaryField
+from webdav.NullResource import NullResource
+from zExceptions import Unauthorized, MethodNotAllowed, Forbidden
+from zope import schema
+from zope.component.interfaces import IFactory
+from zope.filerepresentation.interfaces import IDirectoryFactory
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IRawReadFile
+from zope.filerepresentation.interfaces import IRawWriteFile
+from zope.interface import Interface
+from zope.interface import alsoProvides
+from zope.interface import implements
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
+from zope.publisher.browser import TestRequest
+from zope.size.interfaces import ISized
+import re
+import unittest
 
-from plone.dexterity.browser.traversal import DexterityPublishTraverse
 
 class ITestBehavior(Interface):
     foo = schema.Int()
     bar = schema.Bytes()
 alsoProvides(ITestBehavior, IFormFieldProvider)
 
+
 class DAVTestRequest(TestRequest):
 
     get_header = TestRequest.getHeader
@@ -81,8 +66,10 @@ def test_get_size_wrong_adapter(self):
         class SizedAdapter(object):
             def __init__(self, context):
                 self.context = context
+
             def sizeForSorting(self):
                 return 'lines', 10
+
             def sizeForDisplay(self):
                 '10 lines'
         self.mock_adapter(SizedAdapter, ISized, (Item,))
@@ -96,8 +83,10 @@ def test_get_size_right_adapter(self):
         class SizedAdapter(object):
             def __init__(self, context):
                 self.context = context
+
             def sizeForSorting(self):
                 return 'bytes', 10
+
             def sizeForDisplay(self):
                 '10 bytes'
         self.mock_adapter(SizedAdapter, ISized, (Item,))
@@ -142,8 +131,10 @@ def __init__(self, context):
                 self.context = context
             mimeType = 'text/foo'
             encoding = 'latin1'
+
             def size(self):
                 return 10
+
             def read(self, size=None):
                 return '1234567890'
         self.mock_adapter(ReadFileAdapter, IRawReadFile, (Item,))
@@ -156,7 +147,10 @@ def read(self, size=None):
         self.replay()
 
         self.assertEqual('1234567890', item.manage_DAVget())
-        self.assertEqual('text/foo; charset="latin1"', request.response.getHeader('Content-Type'))
+        self.assertEqual(
+            'text/foo; charset="latin1"',
+            request.response.getHeader('Content-Type')
+        )
         self.assertEqual('10', request.response.getHeader('Content-Length'))
 
     def test_get_minimal_adapter(self):
@@ -165,8 +159,10 @@ def __init__(self, context):
                 self.context = context
             mimeType = None
             encoding = None
+
             def size(self):
                 return None
+
             def read(self, size=None):
                 return '1234567890'
         self.mock_adapter(ReadFileAdapter, IRawReadFile, (Item,))
@@ -185,16 +181,20 @@ def read(self, size=None):
     def test_get_streaming(self):
         class ReadFileAdapter(object):
             implements(IStreamIterator)
+
             def __init__(self, context):
                 self.context = context
             mimeType = None
             encoding = None
+
             def size(self):
                 return 10
+
             def read(self, size=None):
                 return '1234567890'
 
         adapterInstance = ReadFileAdapter(None)
+
         def factory(context):
             return adapterInstance
         self.mock_adapter(factory, IRawReadFile, (Item,))
@@ -236,12 +236,15 @@ def __init__(self, context):
                 self._closed = False
             mimeType = None
             encoding = None
+
             def write(self, data):
                 self._written += data
+
             def close(self):
                 self._closed = True
 
         adapterInstance = WriteFile(None)
+
         def factory(context):
             return adapterInstance
 
@@ -268,23 +271,32 @@ def __init__(self, context):
                 self._closed = False
             mimeType = None
             encoding = None
+
             def write(self, data):
                 self._written += data
+
             def close(self):
                 self._closed = True
 
         adapterInstance = WriteFile(None)
+
         def factory(context):
             return adapterInstance
 
         events = []
+
         def handler(event):
             events.append(event)
 
         self.mock_adapter(factory, IRawWriteFile, (Item,))
         self.mock_handler(handler, (IObjectModifiedEvent,))
 
-        request = DAVTestRequest(environ={'BODYFILE': StringIO('data'), 'HTTP_CONTENT_TYPE': 'text/foo'})
+        request = DAVTestRequest(
+            environ={
+                'BODYFILE': StringIO('data'),
+                'HTTP_CONTENT_TYPE': 'text/foo'
+            }
+        )
 
         item = Item('item')
         item.REQUEST = request
@@ -306,23 +318,32 @@ def __init__(self, context):
                 self._closed = False
             mimeType = None
             encoding = None
+
             def write(self, data):
                 self._written += data
+
             def close(self):
                 self._closed = True
 
         adapterInstance = WriteFile(None)
+
         def factory(context):
             return adapterInstance
 
         events = []
+
         def handler(event):
             events.append(event)
 
         self.mock_adapter(factory, IRawWriteFile, (Item,))
         self.mock_handler(handler, (IObjectModifiedEvent,))
 
-        request = DAVTestRequest(environ={'BODYFILE': StringIO('data'), 'HTTP_CONTENT_TYPE': 'text/foo; charset="latin1"'})
+        request = DAVTestRequest(
+            environ={
+                'BODYFILE': StringIO('data'),
+                'HTTP_CONTENT_TYPE': 'text/foo; charset="latin1"'
+            }
+        )
 
         item = Item('item')
         item.REQUEST = request
@@ -343,9 +364,11 @@ def test_mkcol_no_adapter(self):
 
     def test_mkcol_simple_adapter(self):
         created = []
+
         class DirectoryFactory(object):
             def __init__(self, context):
                 self.context = context
+
             def __call__(self, id):
                 created.append(id)
         self.mock_adapter(DirectoryFactory, IDirectoryFactory, (Container,))
@@ -358,19 +381,27 @@ def __call__(self, id):
     def test_put_factory_no_adapter(self):
         container = Container('container')
         self.replay()
-        self.assertEqual(None, container.PUT_factory('test', 'text/foo', 'body'))
+        self.assertEqual(
+            None,
+            container.PUT_factory('test', 'text/foo', 'body')
+        )
 
     def test_put_factory_simple_adapter(self):
         instance = object()
+
         class FileFactory(object):
             def __init__(self, context):
                 self.context = context
+
             def __call__(self, name, contentType, body):
                 return instance
         self.mock_adapter(FileFactory, IFileFactory, (Container,))
         container = Container('container')
         self.replay()
-        self.assertEqual(instance, container.PUT_factory('test', 'text/foo', 'body'))
+        self.assertEqual(
+            instance,
+            container.PUT_factory('test', 'text/foo', 'body')
+        )
 
     def test_list_without_items(self):
 
@@ -430,14 +461,19 @@ def content_type(self):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
 
         self.assertEqual(response, r.HEAD(request, request.response))
         self.assertEqual(200, response.getStatus())
-        self.assertEqual('close', response.getHeader('Connection', literal=True))
+        self.assertEqual(
+            'close',
+            response.getHeader('Connection', literal=True)
+        )
         self.assertEqual('text/foo', response.getHeader('Content-Type'))
         self.assertEqual('10', response.getHeader('Content-Length'))
 
@@ -453,14 +489,23 @@ def content_type(self):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
 
         self.assertEqual(response, r.OPTIONS(request, request.response))
-        self.assertEqual('close', response.getHeader('Connection', literal=True))
-        self.assertEqual('GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK', response.getHeader('Allow'))
+        self.assertEqual(
+            'close',
+            response.getHeader('Connection', literal=True)
+        )
+        self.assertEqual(
+            'GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, PROPFIND, '
+            'PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK',
+            response.getHeader('Allow')
+        )
 
     def test_TRACE(self):
         class TestContainer(Container):
@@ -474,7 +519,9 @@ def content_type(self):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
 
         self.replay()
 
@@ -493,15 +540,22 @@ def content_type(self):
         container.manage_changeProperties(title="Container")
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
 
         self.assertEqual(response, r.PROPFIND(request, response))
 
-        self.assertEqual('close', response.getHeader('connection', literal=True))
-        self.assertEqual('text/xml; charset="utf-8"', response.getHeader('Content-Type'))
+        self.assertEqual(
+            'close',
+            response.getHeader('connection', literal=True)
+        )
+        self.assertEqual(
+            'text/xml; charset="utf-8"', response.getHeader('Content-Type')
+        )
         self.assertEqual(207, response.getStatus())
 
         body = """\
@@ -541,7 +595,11 @@ def content_type(self):
 """
 
         result = response.getBody()
-        result = re.sub(r'<n:getlastmodified>.+</n:getlastmodified>', '<n:getlastmodified>...</n:getlastmodified>', result)
+        result = re.sub(
+            r'<n:getlastmodified>.+</n:getlastmodified>',
+            '<n:getlastmodified>...</n:getlastmodified>',
+            result
+        )
 
         self.assertEqual(result.strip(), body.strip())
 
@@ -569,7 +627,12 @@ def content_type(self):
 </D:propertyupdate>
 """
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container', 'BODY': requestBody})
+        request = DAVTestRequest(
+            environ={
+                'URL': 'http://example.org/site/container',
+                'BODY': requestBody
+            }
+        )
         response = request.response
 
         self.replay()
@@ -578,8 +641,12 @@ def content_type(self):
 
         self.assertEqual('New title', container.getProperty('title'))
 
-        self.assertEqual('close', response.getHeader('connection', literal=True))
-        self.assertEqual('text/xml; charset="utf-8"', response.getHeader('Content-Type'))
+        self.assertEqual(
+            'close', response.getHeader('connection', literal=True)
+        )
+        self.assertEqual(
+            'text/xml; charset="utf-8"', response.getHeader('Content-Type')
+        )
         self.assertEqual(207, response.getStatus())
 
         body = """\
@@ -614,7 +681,9 @@ def LOCK(self, request, response):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
@@ -633,7 +702,9 @@ def UNLOCK(self, request, response):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
@@ -651,7 +722,9 @@ def PUT(self, request, response):
         container = TestContainer('container')
         r = FolderDataResource('fdata', container).__of__(container)
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.replay()
@@ -665,7 +738,9 @@ def test_MKCOL(self):
 
         self.replay()
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.assertRaises(MethodNotAllowed, r.MKCOL, request, response)
@@ -676,7 +751,9 @@ def test_DELETE(self):
 
         self.replay()
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.assertRaises(MethodNotAllowed, r.DELETE, request, response)
@@ -687,7 +764,9 @@ def test_COPY(self):
 
         self.replay()
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.assertRaises(MethodNotAllowed, r.COPY, request, response)
@@ -698,7 +777,9 @@ def test_MOVE(self):
 
         self.replay()
 
-        request = DAVTestRequest(environ={'URL': 'http://example.org/site/container'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://example.org/site/container'}
+        )
         response = request.response
 
         self.assertRaises(MethodNotAllowed, r.MOVE, request, response)
@@ -737,6 +818,7 @@ def test_listDAVObjects(self):
 
         self.assertEqual([], r.listDAVObjects())
 
+
 class TestFileRepresentation(MockTestCase):
 
     def test_directory_factory(self):
@@ -759,15 +841,32 @@ def test_file_factory_finder_cruft(self):
 
         self.replay()
 
-        self.assertRaises(Unauthorized, factory, '.DS_Store', 'application/octet-stream', 'xxx')
-        self.assertRaises(Unauthorized, factory, '._test', 'application/octet-stream', 'xxx')
-
+        self.assertRaises(
+            Unauthorized,
+            factory,
+            '.DS_Store',
+            'application/octet-stream',
+            'xxx'
+        )
+        self.assertRaises(
+            Unauthorized,
+            factory,
+            '._test',
+            'application/octet-stream',
+            'xxx'
+        )
 
     def test_file_factory_no_ctr(self):
         container = Container('container')
 
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
-        self.expect(getToolByName_mock(container, 'content_type_registry', None)).result(None)
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
+        self.expect(
+            getToolByName_mock(
+                container, 'content_type_registry', None
+                )
+        ).result(None)
 
         factory = DefaultFileFactory(container)
 
@@ -779,10 +878,18 @@ def test_file_factory_no_fti(self):
         container = Container('container')
 
         ctr_mock = self.mocker.mock()
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
-
-        self.expect(getToolByName_mock(container, 'content_type_registry', None)).result(ctr_mock)
-        self.expect(ctr_mock.findTypeName('test.html', 'text/html', '<html />')).result(None)
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
+
+        self.expect(
+            getToolByName_mock(
+                container, 'content_type_registry', None
+            )
+        ).result(ctr_mock)
+        self.expect(
+            ctr_mock.findTypeName('test.html', 'text/html', '<html />')
+        ).result(None)
 
         factory = DefaultFileFactory(container)
 
@@ -798,12 +905,22 @@ def test_file_factory_not_allowed(self):
         container_fti_mock = self.mocker.mock()
         ctr_mock = self.mocker.mock()
         pt_mock = self.mocker.mock()
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
-
-        self.expect(getToolByName_mock(container, 'content_type_registry', None)).result(ctr_mock)
-        self.expect(getToolByName_mock(container, 'portal_types')).result(pt_mock)
-
-        self.expect(ctr_mock.findTypeName('test.html', 'text/html', '<html />')).result('childtype')
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
+
+        self.expect(
+            getToolByName_mock(
+                container, 'content_type_registry', None
+            )
+        ).result(ctr_mock)
+        self.expect(
+            getToolByName_mock(
+                container, 'portal_types')).result(pt_mock)
+
+        self.expect(
+            ctr_mock.findTypeName('test.html', 'text/html', '<html />')
+        ).result('childtype')
 
         self.expect(pt_mock.getTypeInfo('childtype')).result(child_fti_mock)
         self.expect(pt_mock.getTypeInfo(container)).result(container_fti_mock)
@@ -816,7 +933,13 @@ def test_file_factory_not_allowed(self):
 
         self.replay()
 
-        self.assertRaises(Unauthorized, factory, 'test.html', 'text/html', '<html />')
+        self.assertRaises(
+            Unauthorized,
+            factory,
+            'test.html',
+            'text/html',
+            '<html />'
+        )
 
     def test_file_factory_construction_not_allowed(self):
         container = Container('container')
@@ -826,12 +949,22 @@ def test_file_factory_construction_not_allowed(self):
         container_fti_mock = self.mocker.mock()
         ctr_mock = self.mocker.mock()
         pt_mock = self.mocker.mock()
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
-
-        self.expect(getToolByName_mock(container, 'content_type_registry', None)).result(ctr_mock)
-        self.expect(getToolByName_mock(container, 'portal_types')).result(pt_mock)
-
-        self.expect(ctr_mock.findTypeName('test.html', 'text/html', '<html />')).result('childtype')
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
+
+        self.expect(
+            getToolByName_mock(
+                container, 'content_type_registry', None
+            )
+        ).result(ctr_mock)
+        self.expect(
+            getToolByName_mock(
+                container, 'portal_types')).result(pt_mock)
+
+        self.expect(
+            ctr_mock.findTypeName('test.html', 'text/html', '<html />')
+        ).result('childtype')
 
         self.expect(pt_mock.getTypeInfo('childtype')).result(child_fti_mock)
         self.expect(pt_mock.getTypeInfo(container)).result(container_fti_mock)
@@ -839,13 +972,21 @@ def test_file_factory_construction_not_allowed(self):
         self.expect(child_fti_mock.product).result(None)
 
         self.expect(container_fti_mock.allowType('childtype')).result(True)
-        self.expect(child_fti_mock.isConstructionAllowed(container)).result(False)
+        self.expect(
+            child_fti_mock.isConstructionAllowed(container)
+        ).result(False)
 
         factory = DefaultFileFactory(container)
 
         self.replay()
 
-        self.assertRaises(Unauthorized, factory, 'test.html', 'text/html', '<html />')
+        self.assertRaises(
+            Unauthorized,
+            factory,
+            'test.html',
+            'text/html',
+            '<html />'
+        )
 
     def test_file_factory_factory_method(self):
 
@@ -856,17 +997,31 @@ def test_file_factory_factory_method(self):
 
         result_dummy = self.create_dummy()
 
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
 
-        self.expect(getToolByName_mock(container_mock, 'content_type_registry', None)).result(ctr_mock)
-        self.expect(getToolByName_mock(container_mock, 'portal_types')).result(pt_mock)
+        self.expect(
+            getToolByName_mock(
+                container_mock, 'content_type_registry', None
+            )
+        ).result(ctr_mock)
+        self.expect(
+            getToolByName_mock(
+                container_mock, 'portal_types')).result(pt_mock)
 
-        self.expect(ctr_mock.findTypeName('test.html', 'text/html', '<html />')).result('childtype')
+        self.expect(
+            ctr_mock.findTypeName('test.html', 'text/html', '<html />')
+        ).result('childtype')
 
-        self.expect(pt_mock.getTypeInfo('childtype')).result(child_fti_mock)
+        self.expect(
+            pt_mock.getTypeInfo('childtype')
+        ).result(child_fti_mock)
 
         self.expect(child_fti_mock.product).result('FooProduct')
-        self.expect(container_mock.invokeFactory('childtype', 'test.html')).result('test-1.html')
+        self.expect(
+            container_mock.invokeFactory('childtype', 'test.html')
+        ).result('test-1.html')
 
         self.expect(container_mock._getOb('test-1.html')).result(result_dummy)
         self.expect(container_mock._delObject('test-1.html'))
@@ -875,7 +1030,10 @@ def test_file_factory_factory_method(self):
 
         self.replay()
 
-        self.assertEqual(result_dummy, factory('test.html', 'text/html', '<html />'))
+        self.assertEqual(
+            result_dummy,
+            factory('test.html', 'text/html', '<html />')
+        )
 
     def test_file_factory_factory_utility(self):
         container_mock = self.mocker.mock()
@@ -886,18 +1044,39 @@ def test_file_factory_factory_utility(self):
 
         result_dummy = self.create_dummy()
 
-        getToolByName_mock = self.mocker.replace('Products.CMFCore.utils.getToolByName')
+        getToolByName_mock = self.mocker.replace(
+            'Products.CMFCore.utils.getToolByName'
+        )
 
-        self.expect(getToolByName_mock(container_mock, 'content_type_registry', None)).result(ctr_mock)
-        self.expect(getToolByName_mock(container_mock, 'portal_types')).result(pt_mock)
+        self.expect(
+            getToolByName_mock(
+                container_mock, 'content_type_registry', None
+            )
+        ).result(ctr_mock)
 
-        self.expect(ctr_mock.findTypeName('test.html', 'text/html', '<html />')).result('childtype')
+        self.expect(
+            getToolByName_mock(
+                container_mock, 'portal_types')).result(pt_mock)
 
-        self.expect(pt_mock.getTypeInfo('childtype')).result(child_fti_mock)
-        self.expect(pt_mock.getTypeInfo(container_mock)).result(container_fti_mock)
+        self.expect(
+            ctr_mock.findTypeName('test.html', 'text/html', '<html />')
+        ).result('childtype')
 
-        self.expect(container_fti_mock.allowType('childtype')).result(True)
-        self.expect(child_fti_mock.isConstructionAllowed(container_mock)).result(True)
+        self.expect(
+            pt_mock.getTypeInfo('childtype')
+        ).result(child_fti_mock)
+
+        self.expect(
+            pt_mock.getTypeInfo(container_mock)
+        ).result(container_fti_mock)
+
+        self.expect(
+            container_fti_mock.allowType('childtype')
+        ).result(True)
+
+        self.expect(
+            child_fti_mock.isConstructionAllowed(container_mock)
+        ).result(True)
 
         self.expect(child_fti_mock.product).result(None)
         self.expect(child_fti_mock.factory).result('childtype-factory')
@@ -910,7 +1089,10 @@ def factory(*args, **kwargs):
 
         self.replay()
 
-        self.assertEqual(result_dummy, factory('test.html', 'text/html', '<html />'))
+        self.assertEqual(
+            result_dummy,
+            factory('test.html', 'text/html', '<html />')
+        )
 
     def test_readfile_mimetype_no_message_no_fields(self):
 
@@ -1006,6 +1188,7 @@ def test_readfile_mimetype_additional_schemata(self):
 
         class ITest(Interface):
             title = schema.TextLine()
+
         class ITestAdditional(Interface):
             # Additional behavior on an item
             body = schema.Text()
@@ -1013,12 +1196,15 @@ class ITestAdditional(Interface):
         alsoProvides(ITestAdditional['body'], IPrimaryField)
         alsoProvides(ITestAdditional['stuff'], IPrimaryField)
         alsoProvides(ITestAdditional, IFormFieldProvider)
+
         class MockBehavior(object):
             def __init__(self, iface):
                 self.interface = iface
+
         class MockBehaviorAssignable(object):
             def __init__(self, context):
                 self.context = context
+
             def enumerateBehaviors(self):
                 yield MockBehavior(ITestAdditional)
         SCHEMA_CACHE.clear()
@@ -1046,7 +1232,9 @@ class ITest(Interface):
 
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITest).count(0, None)
-        self.expect(fti_mock.behaviors).result([ITestBehavior.__identifier__]).count(0, None)
+        self.expect(
+            fti_mock.behaviors
+        ).result([ITestBehavior.__identifier__]).count(0, None)
 
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
@@ -1061,8 +1249,12 @@ class ITest(Interface):
         message['bar'] = 'xyz'
         message.set_payload('<p>body</p>')
 
-        constructMessageFromSchemata_mock = self.mocker.replace('plone.rfc822.constructMessageFromSchemata')
-        self.expect(constructMessageFromSchemata_mock(item, ANY)).result(message)
+        constructMessageFromSchemata_mock = self.mocker.replace(
+            'plone.rfc822.constructMessageFromSchemata'
+        )
+        self.expect(
+            constructMessageFromSchemata_mock(item, ANY)
+        ).result(message)
 
         self.replay()
 
@@ -1088,7 +1280,7 @@ class ITest(Interface):
         self.assertEqual('tl', readfile.read(2))
         self.assertEqual(4, readfile.tell())
 
-        readfile.seek(0,2)
+        readfile.seek(0, 2)
         self.assertEqual(69, readfile.tell())
 
         readfile.seek(0)
@@ -1118,7 +1310,9 @@ class ITest(Interface):
 
         fti_mock = self.mocker.mock(DexterityFTI)
         self.expect(fti_mock.lookupSchema()).result(ITest).count(0, None)
-        self.expect(fti_mock.behaviors).result([ITestBehavior.__identifier__]).count(0, None)
+        self.expect(
+            fti_mock.behaviors
+        ).result([ITestBehavior.__identifier__]).count(0, None)
 
         self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
 
@@ -1139,8 +1333,17 @@ class ITest(Interface):
 
 <p>body</p>"""
 
-        initializeObjectFromSchemata_mock = self.mocker.replace('plone.rfc822.initializeObjectFromSchemata')
-        self.expect(initializeObjectFromSchemata_mock(item, ANY, self.match_type(Message), 'latin1'))
+        initializeObjectFromSchemata_mock = self.mocker.replace(
+            'plone.rfc822.initializeObjectFromSchemata'
+        )
+        self.expect(
+            initializeObjectFromSchemata_mock(
+                item,
+                ANY,
+                self.match_type(Message),
+                'latin1'
+            )
+        )
 
         self.replay()
 
@@ -1183,10 +1386,15 @@ def test_no_acquire_dav(self):
         outer._setOb('item', SimpleItem('item'))
         outer._setOb('container', container)
 
-        request = DAVTestRequest(environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PUT'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PUT'}
+        )
         request.maybe_webdav_client = True
 
-        traversal = DexterityPublishTraverse(container.__of__(outer), request)
+        traversal = DexterityPublishTraverse(
+            container.__of__(outer),
+            request
+        )
 
         self.replay()
 
@@ -1202,7 +1410,9 @@ def test_acquire_without_dav(self):
         outer._setObject('item', SimpleItem('item'))
         outer._setOb('container', container)
 
-        request = DAVTestRequest(environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'GET'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'GET'}
+        )
         request.maybe_webdav_client = False
 
         traversal = DexterityPublishTraverse(container.__of__(outer), request)
@@ -1216,7 +1426,9 @@ def test_acquire_without_dav(self):
 
     def test_folder_data_traversal_dav(self):
         container = Container('test')
-        request = DAVTestRequest(environ={'URL': 'http://site/test'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test'}
+        )
         request.maybe_webdav_client = True
 
         traversal = DexterityPublishTraverse(container, request)
@@ -1229,17 +1441,23 @@ def test_folder_data_traversal_dav(self):
         self.assertEqual(container, r.__parent__)
         self.assertEqual(container, r.aq_parent)
 
-
     def test_folder_data_traversal_without_dav(self):
         container = Container('test')
-        request = DAVTestRequest(environ={'URL': 'http://site/test'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test'}
+        )
         request.maybe_webdav_client = False
 
         traversal = DexterityPublishTraverse(container, request)
 
         self.replay()
 
-        self.assertRaises(Forbidden, traversal.publishTraverse, request, DAV_FOLDER_DATA_ID)
+        self.assertRaises(
+            Forbidden,
+            traversal.publishTraverse,
+            request,
+            DAV_FOLDER_DATA_ID
+        )
 
     def test_browser_default_dav(self):
         class TestContainer(Container):
@@ -1248,7 +1466,9 @@ def __browser_default__(self, request):
                 return self, ('foo',)
 
         container = TestContainer('container')
-        request = DAVTestRequest(environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PROPFIND'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PROPFIND'}
+        )
         request.maybe_webdav_client = True
 
         traversal = DexterityPublishTraverse(container, request)
@@ -1264,14 +1484,19 @@ def __browser_default__(self, request):
                 return self, ('foo',)
 
         container = TestContainer('container')
-        request = DAVTestRequest(environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'GET'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'GET'}
+        )
         request.maybe_webdav_client = True
 
         traversal = DexterityPublishTraverse(container, request)
 
         self.replay()
 
-        self.assertEqual((container, ('foo',),), traversal.browserDefault(request))
+        self.assertEqual(
+            (container, ('foo',),),
+            traversal.browserDefault(request)
+        )
 
     def test_browser_default_without_dav(self):
         class TestContainer(Container):
@@ -1280,14 +1505,20 @@ def __browser_default__(self, request):
                 return self, ('foo',)
 
         container = TestContainer('container')
-        request = DAVTestRequest(environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PROPFIND'})
+        request = DAVTestRequest(
+            environ={'URL': 'http://site/test', 'REQUEST_METHOD': 'PROPFIND'}
+        )
         request.maybe_webdav_client = False
 
         traversal = DexterityPublishTraverse(container, request)
 
         self.replay()
 
-        self.assertEqual((container, ('foo',),), traversal.browserDefault(request))
+        self.assertEqual(
+            (container, ('foo',),),
+            traversal.browserDefault(request)
+        )
+
 
 def test_suite():
     return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/plone/dexterity/utils.py b/plone/dexterity/utils.py
index c83e1f5..b59b737 100644
--- a/plone/dexterity/utils.py
+++ b/plone/dexterity/utils.py
@@ -1,33 +1,23 @@
-import datetime
-import logging
-
+# -*- coding: utf-8 -*-
+from AccessControl import Unauthorized
 from Acquisition import aq_base
 from Acquisition import aq_inner
-from AccessControl import Unauthorized
 from DateTime import DateTime
-
-from zope.component import getUtility, queryUtility
-from zope.component import createObject
-
-from zope.dottedname.resolve import resolve
-from zope.event import notify
-from zope.lifecycleevent import ObjectCreatedEvent
-
-from plone.behavior.interfaces import IBehavior
+from Products.CMFCore.interfaces import ISiteRoot
+from plone.app.uuid.utils import uuidToObject
 from plone.autoform.interfaces import IFormFieldProvider
+from plone.behavior.interfaces import IBehavior
 from plone.behavior.interfaces import IBehaviorAssignable
 from plone.dexterity.interfaces import IDexterityFTI
-
-from Products.CMFCore.interfaces import ISiteRoot
-
+from plone.uuid.interfaces import IUUID
+from zope.component import createObject
+from zope.component import getUtility, queryUtility
 from zope.container.interfaces import INameChooser
-
-try:
-    from plone.uuid.interfaces import IUUID
-    from plone.app.uuid.utils import uuidToObject
-    HAS_UUID = True
-except ImportError:
-    HAS_UUID = False
+from zope.dottedname.resolve import resolve
+from zope.event import notify
+from zope.lifecycleevent import ObjectCreatedEvent
+import datetime
+import logging
 
 log = logging.getLogger(__name__)
 
@@ -43,8 +33,8 @@ def resolveDottedName(dottedName):
         _dottedCache[dottedName] = resolve(dottedName)
     return _dottedCache[dottedName]
 
-# Schema name encoding
 
+# Schema name encoding
 class SchemaNameEncoder(object):
 
     key = (
@@ -52,15 +42,15 @@ class SchemaNameEncoder(object):
         ('.', '_2_'),
         ('-', '_3_'),
         ('/', '_4_'),
-        )
+    )
 
     def encode(self, s):
-        for k,v in self.key:
+        for k, v in self.key:
             s = s.replace(k, v)
         return s
 
     def decode(self, s):
-        for k,v in self.key:
+        for k, v in self.key:
             s = s.replace(v, k)
         return s
 
@@ -70,6 +60,7 @@ def join(self, *args):
     def split(self, s):
         return [self.decode(a) for a in s.split('_0_')]
 
+
 def portalTypeToSchemaName(portal_type, schema=u"", prefix=None):
     """Return a canonical interface name for a generated schema interface.
     """
@@ -79,12 +70,14 @@ def portalTypeToSchemaName(portal_type, schema=u"", prefix=None):
     encoder = SchemaNameEncoder()
     return encoder.join(prefix, portal_type, schema)
 
+
 def schemaNameToPortalType(schemaName):
     """Return a the portal_type part of a schema name
     """
     encoder = SchemaNameEncoder()
     return encoder.split(schemaName)[1]
 
+
 def splitSchemaName(schemaName):
     """Return a tuple prefix, portal_type, schemaName
     """
@@ -139,13 +132,22 @@ def createContent(portal_type, **kw):
     fields = dict(kw)  # create a copy
 
     for schema in schemas:
+        # schema.names() doesn't return attributes from superclasses in derived
+        # schemas. therefore we have to iterate over all items from the passed
+        # keywords arguments and set it, if the behavior has the questioned
+        # attribute.
         behavior = schema(content)
-        for name in schema.names():
-            if name in fields:
-                setattr(behavior, name, fields[name])
-                del fields[name]
-
-    for (key,value) in fields.items():
+        for name, value in fields.items():
+            try:
+                # hasattr swallows exceptions.
+                if getattr(behavior, name):
+                    setattr(behavior, name, value)
+                    del fields[name]
+            except AttributeError:
+                # fieldname not available
+                pass
+
+    for (key, value) in fields.items():
         setattr(content, key, value)
 
     notify(ObjectCreatedEvent(content))
@@ -170,8 +172,11 @@ def addContentToContainer(container, object, checkConstraints=True):
         if not fti.isConstructionAllowed(container):
             raise Unauthorized("Cannot create %s" % object.portal_type)
 
-        if container_fti is not None and not container_fti.allowType(object.portal_type):
-            raise ValueError("Disallowed subobject type: %s" % object.portal_type)
+        if container_fti is not None \
+           and not container_fti.allowType(object.portal_type):
+            raise ValueError(
+                "Disallowed subobject type: %s" % object.portal_type
+            )
 
     name = getattr(aq_base(object), 'id', None)
     name = INameChooser(container).chooseName(name, object)
@@ -181,18 +186,18 @@ def addContentToContainer(container, object, checkConstraints=True):
     try:
         return container._getOb(newName)
     except AttributeError:
-        if HAS_UUID:
-            # work around edge case where a content rule may have moved the item
-            uuid = IUUID(object)
-            return uuidToObject(uuid)
-        else:
-            # no way to know where it is
-            raise
+        uuid = IUUID(object)
+        return uuidToObject(uuid)
 
 
-def createContentInContainer(container, portal_type, checkConstraints=True, **kw):
+def createContentInContainer(container, portal_type, checkConstraints=True,
+                             **kw):
     content = createContent(portal_type, **kw)
-    return addContentToContainer(container, content, checkConstraints=checkConstraints)
+    return addContentToContainer(
+        container,
+        content,
+        checkConstraints=checkConstraints
+    )
 
 
 def getAdditionalSchemata(context=None, portal_type=None):




-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 274719 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140922/05ad3848/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 87452 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140922/05ad3848/attachment-0003.obj>


More information about the Testbot mailing list