Author: jmorliaguet Date: Wed Jun 28 11:32:16 2006 New Revision: 3535 Added: cpsskins/branches/paris-sprint-2006/standard/io/location.py (contents, props changed) Modified: cpsskins/branches/paris-sprint-2006/locations/configure.zcml cpsskins/branches/paris-sprint-2006/setup/io/README.txt cpsskins/branches/paris-sprint-2006/setup/io/adapters.py cpsskins/branches/paris-sprint-2006/setup/io/utils.py cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml
Log: - added a DOM adapter for exporting / importing locations Modified: cpsskins/branches/paris-sprint-2006/locations/configure.zcml ============================================================================== --- cpsskins/branches/paris-sprint-2006/locations/configure.zcml (original) +++ cpsskins/branches/paris-sprint-2006/locations/configure.zcml Wed Jun 28 11:32:16 2006 @@ -28,4 +28,21 @@ name="location data" /> + <!-- Typing --> + <interface + interface=".interfaces.ILocation" + type="cpsskins.setup.interfaces.IResourceType" + /> + + <interface + interface=".interfaces.ILocation" + type="zope.app.content.interfaces.IContentType" + /> + + <interface + name="location" + interface=".interfaces.ILocation" + type="cpsskins.setup.interfaces.INameType" + /> + </configure> Modified: cpsskins/branches/paris-sprint-2006/setup/io/README.txt ============================================================================== --- cpsskins/branches/paris-sprint-2006/setup/io/README.txt (original) +++ cpsskins/branches/paris-sprint-2006/setup/io/README.txt Wed Jun 28 11:32:16 2006 @@ -198,15 +198,17 @@ >>> root = getRootFolder() >>> theme = addThemeSkeleton(tmutil) - >>> print toXML(theme, u'themes', attributes=(u'title', ), - ... ignored=(u'slot',)) + >>> print toXML(theme, u'themes', attributes=(u'title', )) <?xml version="1.0" encoding="utf-8"?> <themes> <theme id="..." title="A theme"> + <author value=""/> + <copyright value=""/> + <license value=""/> <themepage id="..." title="A page"> <pageblock id="..." title="A page block"> <cell id="..." title="A cell"/> - </pageblock> + </pageblock> </themepage> </theme> </themes> @@ -331,6 +333,20 @@ <BLANKLINE> +Export of locations +------------------- + + >>> from cpsskins.locations import Location + >>> location = Location(path=u'/folder/A', scope=(1, 3), data=u'd1') + >>> archive = {} + >>> print toXML(location, u'locations', archive=archive, + ... attributes=(u'path', u'scope', u'data', u'root')) + <?xml version="1.0" encoding="utf-8"?> + <locations> + <location data="d1" path="/folder/A" scope="(1, 3)"/> + </locations> + <BLANKLINE> + Teardown: >>> for k in root: Modified: cpsskins/branches/paris-sprint-2006/setup/io/adapters.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/setup/io/adapters.py (original) +++ cpsskins/branches/paris-sprint-2006/setup/io/adapters.py Wed Jun 28 11:32:16 2006 @@ -103,8 +103,11 @@ type = IType(context) element_el = document.createElement(type.resourcename) - element_id = unicode(IRelatable(context)) - element_el.setAttribute(u'id', element_id) + + relatable = IRelatable(context, None) + if relatable is not None: + element_id = unicode(relatable) + element_el.setAttribute(u'id', element_id) if type.contentname != type.resourcename: element_el.setAttribute(u'type', unicode(type.contentname)) Modified: cpsskins/branches/paris-sprint-2006/setup/io/utils.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/setup/io/utils.py (original) +++ cpsskins/branches/paris-sprint-2006/setup/io/utils.py Wed Jun 28 11:32:16 2006 @@ -48,7 +48,7 @@ uri_mapping.update(importPresets(archive, context)) # storages - for name in u'formats', u'portlets': + for name in u'formats', u'portlets', 'locations': uri_mapping.update(importStorage(name, archive, context)) # relations @@ -84,7 +84,7 @@ exportThemes(archive, context) exportPresets(archive, context) - for name in u'formats', u'portlets', u'relations': + for name in u'formats', u'portlets', u'locations', u'relations': exportStorage(name, archive, context) return archive() Modified: cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml ============================================================================== --- cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml (original) +++ cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml Wed Jun 28 11:32:16 2006 @@ -57,4 +57,12 @@ provides="cpsskins.setup.io.interfaces.IDOMAdapter" /> + <!-- locations --> + <adapter + for="cpsskins.locations.interfaces.ILocation *" + factory="cpsskins.standard.io.location.DOMAdapter" + permission="zope.ManageContent" + provides="cpsskins.setup.io.interfaces.IDOMAdapter" + /> + </configure> Added: cpsskins/branches/paris-sprint-2006/standard/io/location.py ============================================================================== --- (empty file) +++ cpsskins/branches/paris-sprint-2006/standard/io/location.py Wed Jun 28 11:32:16 2006 @@ -0,0 +1,31 @@ +############################################################################## +# +# Copyright (c) 2005-2006 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" +__docformat__ = "reStructuredText" + +from zope.interface import implements + +from cpsskins.setup.io.interfaces import IDOMAdapter +from cpsskins.setup.io.adapters import DOMAdapter as GenericDOMAdapter + +class DOMAdapter(GenericDOMAdapter): + """DOM adapter for locations + """ + implements(IDOMAdapter) + + fields_as_attributes = u'path', u'root', u'scope', u'data' + -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins