[Z3lab-checkins] r3534 - cpsskins/branches/paris-sprint-2006/setup/io

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 10:51:00 2006
New Revision: 3534

Modified:
   cpsskins/branches/paris-sprint-2006/setup/io/adapters.py

Log:

- raise an exception if no content type has been registered



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.pyWed Jun 28 
10:51:00 2006
@@ -111,6 +111,8 @@
 
 # properties
 schema = type.getContentType()
+if schema is None:
+raise TypeError(%s has no content type, repr(context))
 for attr, field in zope.schema.getFieldsInOrder(schema):
 if attr in self.ignored_fields:
 continue
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3535 - in cpsskins/branches/paris-sprint-2006: locations setup/io standard/io

2006-06-28 Thread jmorliaguet
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.zcmlWed 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.pyWed 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
+  

[Z3lab-checkins] r3536 - in cpsskins/branches/paris-sprint-2006: locations setup/io storage

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 13:58:07 2006
New Revision: 3536

Modified:
   cpsskins/branches/paris-sprint-2006/locations/configure.zcml
   cpsskins/branches/paris-sprint-2006/setup/io/adapters.py
   cpsskins/branches/paris-sprint-2006/setup/io/utils.py
   cpsskins/branches/paris-sprint-2006/storage/configure.zcml

Log:

- fixed the export of 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.zcmlWed Jun 
28 13:58:07 2006
@@ -16,6 +16,13 @@
 
   /class
 
+  !-- factory --
+  utility
+  name=cpsskins.location
+  component=cpsskins.locations.location.Location
+  provides=zope.component.interfaces.IFactory
+  /
+
   utility
  provides=zope.schema.interfaces.IVocabularyFactory
  component=.interfaces.ScopesVocabulary
@@ -31,6 +38,11 @@
   !-- Typing --
   interface
   interface=.interfaces.ILocation
+  type=cpsskins.elements.interfaces.IElementType
+  /
+
+  interface
+  interface=.interfaces.ILocation
   type=cpsskins.setup.interfaces.IResourceType
   /
 

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.pyWed Jun 28 
13:58:07 2006
@@ -101,8 +101,11 @@
 document = self.document
 
 type = IType(context)
+resourcename = type.resourcename
+if not resourcename:
+raise TypeError(%s has no resource type % repr(context))
 
-element_el = document.createElement(type.resourcename)
+element_el = document.createElement(resourcename)
 
 relatable = IRelatable(context, None)
 if relatable is not None:

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 
13:58:07 2006
@@ -160,7 +160,9 @@
 continue
 
 contentname = el.getAttribute('type') or el.tagName
-factory_name = u'cpsskins.%s.%s' % (typename, contentname)
+factory_name = u'cpsskins.%s' % typename
+if contentname != typename:
+factory_name = u'%s.%s' % (factory_name, contentname)
 obj = createObject(factory_name)
 storage.add(obj)
 

Modified: cpsskins/branches/paris-sprint-2006/storage/configure.zcml
==
--- cpsskins/branches/paris-sprint-2006/storage/configure.zcml  (original)
+++ cpsskins/branches/paris-sprint-2006/storage/configure.zcml  Wed Jun 28 
13:58:07 2006
@@ -49,7 +49,7 @@
 
   !-- Location storage --
   cpsskins:storage
-  id=location
+  id=locations
   title=Location storage
   description=A location storage contains local information about the 
site
   class=.locations.LocationStorage
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3537 - cpsskins/branches/paris-sprint-2006/storage

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 14:48:27 2006
New Revision: 3537

Modified:
   cpsskins/branches/paris-sprint-2006/storage/locations.py

Log:

- fix



Modified: cpsskins/branches/paris-sprint-2006/storage/locations.py
==
--- cpsskins/branches/paris-sprint-2006/storage/locations.py(original)
+++ cpsskins/branches/paris-sprint-2006/storage/locations.pyWed Jun 28 
14:48:27 2006
@@ -142,8 +142,9 @@
 locations.append(value)
 return locations
 
-def getLocation(self, root=u'', path=u'', method=u''):
+def getLocation(self, root=u'', path=u''):
 path = tuple(path.split(u'/'))
+path, method = path[:-1], path[-1]
 key = (root, method) + path
 return self[key]
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3538 - in cpsskins/branches/paris-sprint-2006: . locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 14:50:05 2006
New Revision: 3538

Added:
   cpsskins/branches/paris-sprint-2006/schema.py   (contents, props changed)
Modified:
   cpsskins/branches/paris-sprint-2006/locations/interfaces.py

Log:

- added an IntCoupleChoice field for location scopes



Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original)
+++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 
14:50:05 2006
@@ -24,6 +24,7 @@
 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from cpsskins.utils import getThemeManager
+from cpsskins.schema import IntCoupleChoice
 
 _ = MessageFactory(cpsskins)
 
@@ -38,7 +39,7 @@
 title=uPath,
 )
 
-scope = Choice(
+scope = IntCoupleChoice(
 title=uScope,
 vocabulary=location scopes,
 )

Added: cpsskins/branches/paris-sprint-2006/schema.py
==
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/schema.py   Wed Jun 28 14:50:05 2006
@@ -0,0 +1,37 @@
+##
+#
+# 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 zope.schema.interfaces import IField
+from zope.schema import Choice
+
+class IIntCoupleChoice(IField):
+A choice field containing couples of integers e.g. (0, 1)
+
+class IntCoupleChoice(Choice):
+implements(IIntCoupleChoice)
+
+def fromUnicode(self, text):
+self.validate(text)
+a, b = text[1:-1].split(u', ')
+return (a, b)
+
+def validate(self, value):
+return True
+
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3539 - in cpsskins/branches/paris-sprint-2006: . locations storage ui/screens/sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 14:56:40 2006
New Revision: 3539

Modified:
   cpsskins/branches/paris-sprint-2006/locations/interfaces.py
   cpsskins/branches/paris-sprint-2006/schema.py
   cpsskins/branches/paris-sprint-2006/storage/interfaces.py
   cpsskins/branches/paris-sprint-2006/storage/locations.py
   cpsskins/branches/paris-sprint-2006/storage/storage.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- added a delete() method to storage to delete objects



Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original)
+++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 
14:56:40 2006
@@ -31,7 +31,9 @@
 class ILocation(Interface):
 Location
 
-_path_tuple = Attribute(representation of the path as a tuple)
+_path_tuple = Attribute(Representation of the path as a tuple)
+
+_method = Attribute(Path's method name.)
 
 root = Attribute(Location root)
 

Modified: cpsskins/branches/paris-sprint-2006/schema.py
==
--- cpsskins/branches/paris-sprint-2006/schema.py   (original)
+++ cpsskins/branches/paris-sprint-2006/schema.py   Wed Jun 28 14:56:40 2006
@@ -33,5 +33,6 @@
 return (a, b)
 
 def validate(self, value):
+# FIXME
 return True
 

Modified: cpsskins/branches/paris-sprint-2006/storage/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/storage/interfaces.py   (original)
+++ cpsskins/branches/paris-sprint-2006/storage/interfaces.py   Wed Jun 28 
14:56:40 2006
@@ -24,6 +24,9 @@
 def add(object, name):
 Add an object to the storage. Return the added object.
 
+def delete(object):
+Delete an object
+
 def remove(ids):
 Remove objects from the storage.
 

Modified: cpsskins/branches/paris-sprint-2006/storage/locations.py
==
--- cpsskins/branches/paris-sprint-2006/storage/locations.py(original)
+++ cpsskins/branches/paris-sprint-2006/storage/locations.pyWed Jun 28 
14:56:40 2006
@@ -73,13 +73,17 @@
 locate(object=location, parent=self, name=u'-'.join(key))
 notify(ObjectAddedEvent(location))
 
-def remove(self, locations):
-if not isinstance(locations, (list, tuple)):
-locations = [locations]
-for location in locations:
-if location not in list(self):
+def delete(self, location):
+key = (location.root, location._method) + location._path_tuple
+self.remove(key)
+
+def remove(self, ids):
+if not isinstance(ids, (list, tuple)):
+ids = [ids]
+for id in ids:
+if id not in list(self):
 continue
-del self[location]
+del self[id]
 
 def find(self, path, root=u''):
 if isinstance(path, basestring):

Modified: cpsskins/branches/paris-sprint-2006/storage/storage.py
==
--- cpsskins/branches/paris-sprint-2006/storage/storage.py  (original)
+++ cpsskins/branches/paris-sprint-2006/storage/storage.py  Wed Jun 28 
14:56:40 2006
@@ -60,6 +60,9 @@
 notify(ObjectAddedEvent(object))
 return self[name]
 
+def delete(self, object):
+raise NotImplementedError
+
 def remove(self, ids):
 Remove objects from the storage.
 

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed Jun 
28 14:56:40 2006
@@ -182,7 +182,7 @@
 
 if action == u'delete':
 location = locations.getLocation(root, path)
-locations.remove(location)
+locations.delete(location)
 
 elif action == u'add':
 location = Location(path=path, root=root)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3540 - cpsskins/branches/paris-sprint-2006/storage

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 14:57:51 2006
New Revision: 3540

Modified:
   cpsskins/branches/paris-sprint-2006/storage/locations.py

Log:

- optimization / don't mask key errors



Modified: cpsskins/branches/paris-sprint-2006/storage/locations.py
==
--- cpsskins/branches/paris-sprint-2006/storage/locations.py(original)
+++ cpsskins/branches/paris-sprint-2006/storage/locations.pyWed Jun 28 
14:57:51 2006
@@ -81,8 +81,6 @@
 if not isinstance(ids, (list, tuple)):
 ids = [ids]
 for id in ids:
-if id not in list(self):
-continue
 del self[id]
 
 def find(self, path, root=u''):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3541 - in cpsskins/branches/paris-sprint-2006: ftests locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 17:24:03 2006
New Revision: 3541

Added:
   cpsskins/branches/paris-sprint-2006/ftests/test_location.py   (contents, 
props changed)
   cpsskins/branches/paris-sprint-2006/locations/sources.txt   (contents, props 
changed)
Modified:
   cpsskins/branches/paris-sprint-2006/locations/configure.zcml
   cpsskins/branches/paris-sprint-2006/locations/interfaces.py

Log:

- added a context binder for data sources (not 100% done)



Added: cpsskins/branches/paris-sprint-2006/ftests/test_location.py
==
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/ftests/test_location.py Wed Jun 28 
17:24:03 2006
@@ -0,0 +1,32 @@
+##
+#
+# 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.
+#
+##
+Location tests
+
+$Id$
+
+__docformat__ = reStructuredText
+
+import unittest
+
+from zope.app.testing.functional import FunctionalDocFileSuite
+
+from cpsskins.tests.setup import setUp
+
+def test_suite():
+return unittest.TestSuite((
+FunctionalDocFileSuite('../locations/sources.txt', setUp=setUp),
+))
+
+if __name__ == '__main__':
+unittest.main(defaultTest='test_suite')

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.zcmlWed Jun 
28 17:24:03 2006
@@ -25,16 +25,10 @@
 
   utility
  provides=zope.schema.interfaces.IVocabularyFactory
- component=.interfaces.ScopesVocabulary
+ component=.interfaces.scopesVocabulary
  name=location scopes
   /
 
-  utility
- provides=zope.schema.interfaces.IVocabularyFactory
- component=.interfaces.DataVocabulary
- name=location data
-  /
-
   !-- Typing --
   interface
   interface=.interfaces.ILocation

Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original)
+++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 
17:24:03 2006
@@ -17,10 +17,12 @@
 
 __docformat__ = reStructuredText
 
-from zope.interface import Interface, alsoProvides, Attribute
+from zope.interface import Interface, alsoProvides, Attribute, implements
 from zope.i18nmessageid import MessageFactory
 from zope.schema import TextLine, Tuple, Choice, Int
-from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import ISource
+from zope.schema.interfaces import IVocabularyFactory, IContextSourceBinder
+from zope.schema.interfaces import IBaseVocabulary, IContextSourceBinder
 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from cpsskins.utils import getThemeManager
@@ -28,6 +30,62 @@
 
 _ = MessageFactory(cpsskins)
 
+def scopesVocabulary(context):
+A vocabulary that contains a list of scopes
+
+return SimpleVocabulary(
+[SimpleTerm(value, token, title) for value, token, title in (
+((0, 0), u'0-0', _(uthere and in all sub-folders)),
+((0, 1), u'0-1', _(uonly there)),
+((1, 0), u'1-0', _(uin all sub-folders)),
+)])
+
+alsoProvides(scopesVocabulary, IVocabularyFactory)
+
+class DataSource(object):
+Source for the 'data' field
+
+implements(ISource)
+
+def __init__(self):
+self.context = None
+
+def __iter__(self):
+context = self.context
+if context is None:
+return iter([])
+tmutil = getThemeManager(context)
+root = context.root
+choices = {}
+
+if root == u'pages':
+for theme in tmutil.getThemes():
+theme_name = theme.name
+for page in theme.getPages():
+page_id = u'%s:%s' % (theme_name, page.name)
+choices[page_id] = u'%s / %s' % (theme.title, page.title)
+
+elif root == u'perspectives':
+for perspective in tmutil.listPerspectives():
+choices[perspective.name] = perspective.title
+
+elif root == u'engines':
+# FIXME
+choices[u'default'] = u'default'
+
+return iter(
+[SimpleTerm(value=k, title=v) for k, v 

[Z3lab-checkins] r3542 - cpsskins/branches/paris-sprint-2006/locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 20:03:52 2006
New Revision: 3542

Modified:
   cpsskins/branches/paris-sprint-2006/locations/sources.txt

Log:

- test fix



Modified: cpsskins/branches/paris-sprint-2006/locations/sources.txt
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.txt   (original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.txt   Wed Jun 28 
20:03:52 2006
@@ -9,7 +9,10 @@
 
  from cpsskins.tests.setup import addThemeManager
  from cpsskins.tests.setup import makeSite
+ from cpsskins.utils import addThemeSkeleton
+
  tmutil = addThemeManager(root, makeSite(root))
+ themes = addThemeSkeleton(tmutil)
 
  from zope.schema import Choice
  from cpsskins.locations.interfaces import DataSource
@@ -44,12 +47,11 @@
 
  from cpsskins.locations import Location
  l = Location(root=u'pages')
- root[u'location'] = l
-
- data_choice_in_context = data_choice_in_context.bind(l)
- print list(data_choice_in_context.source)
+ tmutil.getLocationStorage().add(l)
 
+in the context of the location the data source returns a list of pages:
 
-clean up:
+ data_choice_in_context = data_choice_in_context.bind(l)
+ print [t.value for t in data_choice_in_context.source]
+[u'Theme:ThemePage']
 
- del root[u'location']
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3543 - in cpsskins/branches/paris-sprint-2006: locations setup/io ui/screens/sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 20:26:09 2006
New Revision: 3543

Modified:
   cpsskins/branches/paris-sprint-2006/locations/configure.zcml
   cpsskins/branches/paris-sprint-2006/locations/interfaces.py
   cpsskins/branches/paris-sprint-2006/locations/sources.txt
   cpsskins/branches/paris-sprint-2006/setup/io/fields.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- moved sources to a a separate file

- disabled the validation of Choice fields during XML imports since their
  sources depend on a context which doesn't exist yet.



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.zcmlWed Jun 
28 20:26:09 2006
@@ -25,7 +25,7 @@
 
   utility
  provides=zope.schema.interfaces.IVocabularyFactory
- component=.interfaces.scopesVocabulary
+ component=.sources.scopesVocabulary
  name=location scopes
   /
 

Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original)
+++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 
20:26:09 2006
@@ -17,75 +17,15 @@
 
 __docformat__ = reStructuredText
 
-from zope.interface import Interface, alsoProvides, Attribute, implements
+from zope.interface import Interface, Attribute
 from zope.i18nmessageid import MessageFactory
-from zope.schema import TextLine, Tuple, Choice, Int
-from zope.schema.interfaces import ISource
-from zope.schema.interfaces import IVocabularyFactory, IContextSourceBinder
-from zope.schema.interfaces import IBaseVocabulary, IContextSourceBinder
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+from zope.schema import  TextLine, Choice
 
-from cpsskins.utils import getThemeManager
+from cpsskins.locations.sources import data_source_binder
 from cpsskins.schema import IntCoupleChoice
 
 _ = MessageFactory(cpsskins)
 
-def scopesVocabulary(context):
-A vocabulary that contains a list of scopes
-
-return SimpleVocabulary(
-[SimpleTerm(value, token, title) for value, token, title in (
-((0, 0), u'0-0', _(uthere and in all sub-folders)),
-((0, 1), u'0-1', _(uonly there)),
-((1, 0), u'1-0', _(uin all sub-folders)),
-)])
-
-alsoProvides(scopesVocabulary, IVocabularyFactory)
-
-class DataSource(object):
-Source for the 'data' field
-
-implements(ISource)
-
-def __init__(self):
-self.context = None
-
-def __iter__(self):
-context = self.context
-if context is None:
-return iter([])
-tmutil = getThemeManager(context)
-root = context.root
-choices = {}
-
-if root == u'pages':
-for theme in tmutil.getThemes():
-theme_name = theme.name
-for page in theme.getPages():
-page_id = u'%s:%s' % (theme_name, page.name)
-choices[page_id] = u'%s / %s' % (theme.title, page.title)
-
-elif root == u'perspectives':
-for perspective in tmutil.listPerspectives():
-choices[perspective.name] = perspective.title
-
-elif root == u'engines':
-# FIXME
-choices[u'default'] = u'default'
-
-return iter(
-[SimpleTerm(value=k, title=v) for k, v in choices.items()])
-
-def data_source_binder(context):
-source = DataSource()
-if not ILocation.providedBy(context):
-raise ValueError(The data source must be bound with a location as a 
- context.)
-source.context = context
-return source
-
-alsoProvides(data_source_binder, IContextSourceBinder)
-
 class ILocation(Interface):
 Location
 

Modified: cpsskins/branches/paris-sprint-2006/locations/sources.txt
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.txt   (original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.txt   Wed Jun 28 
20:26:09 2006
@@ -15,7 +15,7 @@
  themes = addThemeSkeleton(tmutil)
 
  from zope.schema import Choice
- from cpsskins.locations.interfaces import DataSource
+ from cpsskins.locations.sources import DataSource
  data_choice = Choice(
 ... title=uData,
 ... source=DataSource(),
@@ -27,7 +27,7 @@
 
 let us create a source binder and bind the field to the context:
 
- from cpsskins.locations.interfaces import data_source_binder
+ from cpsskins.locations.sources import data_source_binder
 
  data_choice_in_context = Choice(
 ... title=uData,

Modified: cpsskins/branches/paris-sprint-2006/setup/io/fields.py

[Z3lab-checkins] r3544 - in cpsskins/branches/paris-sprint-2006/ui/screens: common contentauthor elementeditor sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:00:48 2006
New Revision: 3544

Modified:
   cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.css
   
cpsskins/branches/paris-sprint-2006/ui/screens/contentauthor/content_author.css
   
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element-editor.css
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/site_manager.css

Log:

- cosmetic: removed fixed font sizes



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.css
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.css 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/authoring.css Wed Jun 
28 21:00:48 2006
@@ -7,7 +7,7 @@
   padding: 0;
   overflow-y: expression('auto'); /* IE */
   height: expression('100%'); /* IE */
-  font: 12px Arial, Helvetica, sans-serif;
+  font: 13px Arial, Helvetica, sans-serif;
 }
 
 :root {
@@ -40,7 +40,6 @@
 /* toolbar buttons */
 div.locationSelector {
   background-color: #eee;
-  font-size: 12px;
   padding: 0.2em;
   border-bottom: 1px solid #ccc;
   margin-bottom: 0.5em;
@@ -67,7 +66,6 @@
   border-top: 1px solid #666;
   height: 18px;
   z-index: 20;
-  font: 13px arial;
   padding: 2px;
 }
 
@@ -95,7 +93,7 @@
   background-color: #f0f0f0;
   background: #f0f0f0 url(++resource++bg-header.png) repeat-x;
   padding: 2px 0px 2px 30px;
-  font: 14px arial;
+  font-size: 1.1em;
 }
 
 .toolbox .header .button {
@@ -108,7 +106,7 @@
 .toolbox .section {
   border-top: 1px solid #fff;
   border-bottom: 1px solid #999;
-  font: bold 11px arial;
+  font-weight: bold;
   padding: 4px 0px 3px 30px;
   display: block;
   color: #333;
@@ -145,7 +143,7 @@
 
 .toolbox .title {
   font-weight: bold;
-  font-size: 90%;
+  font-size: 0.9em;
   color: #333;
 }
 
@@ -159,7 +157,6 @@
 }
 
 .actionPad a {
-  font-size: 12px;
   color: #000 !important;
   background: #f3f0f0;
   text-decoration: none;
@@ -192,7 +189,6 @@
 .tabs {
   text-align: left;
   text-decoration: none;
-  font-size: 11px;
   padding-left: 1px;
   margin: 0;
 }
@@ -232,7 +228,6 @@
 
 .topTabs, .topTabs a {
   text-decoration: none;
-  font-size: 11px;
   color: #000;
 }
 
@@ -281,6 +276,7 @@
   padding-top: 15px;
   padding-left: 9px;
   margin-left: 0;
+  font-size: 0.9em;
 }
 
 .pageTabs li {
@@ -313,7 +309,6 @@
 /* edit form tabs */
 
 .editTabs {
-  font-size: 13px;
 }
 
 .editTabs li {
@@ -376,7 +371,6 @@
   position: absolute;
   right: 13px;
   top: 8px;
-  font-size: 11px;
   background-repeat: no-repeat;
   background-position: 5% 50%;
   background-color: #fff;
@@ -410,7 +404,7 @@
 /* Macro slots */
 
 .mainContentAreaFrame {
-  font: 14px Trebuchet MS, Verdana, Arial, Sans-Serif;
+  font-size: 1.3em;
   text-align: center;
   background-color: #ffe;
   padding: 0.5em;
@@ -438,7 +432,7 @@
 }
 
 a.back {
-  font-size: 14px;
+  font-size: 1.2em;
   color: #000;
 }
 
@@ -463,6 +457,5 @@
 
 form input {
   padding: 0.1em;
-  font-size: 11px;
   border: 1px solid #ccc;
 }

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/contentauthor/content_author.css
==
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/contentauthor/content_author.css 
(original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/contentauthor/content_author.css 
Wed Jun 28 21:00:48 2006
@@ -20,7 +20,7 @@
 }
 
 .slotFrame .title {
-  font: bold 11px Arial, Sans-Serif;
+  font-weight: bold;
   text-align: center;
   padding: 0 0 1px 0;
   border-style: solid;

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element-editor.css
==
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element-editor.css 
(original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element-editor.css 
Wed Jun 28 21:00:48 2006
@@ -40,7 +40,6 @@
   background-color: #ffd;
   position: absolute;
   width: 100px;
-  font-size: 1em;
 }
 
 fieldset.panel {

Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/site_manager.css
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/site_manager.css 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/site_manager.css 
Wed Jun 28 21:00:48 2006
@@ -46,10 +46,6 @@
   margin: 2px 2px 2px 0;
 }
 
-.sections {
-  font: 13px Arial, sans-serif;
-}
-
 .sections a:hover {
   background-color: #fcc;
   color: #006;
@@ -86,11 +82,11 @@
 }
 
 table.panel td.section {
-  width: 30%;
+  width: 25%;
 }
 
 table.panel td.subsection {
-  width: 70%;
+  width: 75%;
 }
 
 table.panel td.icon {
@@ -113,11 +109,9 @@
 .sections table.items {
   margin: 0;
   padding: 0;
-  font-size: 12px;
 }
 
 .sections table.items th {
-  

[Z3lab-checkins] r3545 - cpsskins/branches/paris-sprint-2006/locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:01:08 2006
New Revision: 3545

Added:
   cpsskins/branches/paris-sprint-2006/locations/sources.py   (contents, props 
changed)

Log:

- added missing file



Added: cpsskins/branches/paris-sprint-2006/locations/sources.py
==
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.pyWed Jun 28 
21:01:08 2006
@@ -0,0 +1,86 @@
+##
+#
+# 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 alsoProvides, implements
+from zope.i18nmessageid import MessageFactory
+from zope.schema.interfaces import ISource
+from zope.schema.interfaces import IVocabularyFactory, IContextSourceBinder
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
+from cpsskins.utils import getThemeManager
+
+_ = MessageFactory(cpsskins)
+
+def scopesVocabulary(context):
+A vocabulary that contains a list of scopes
+
+return SimpleVocabulary(
+[SimpleTerm(value, token, title) for value, token, title in (
+((0, 0), u'0-0', _(uthere and in all sub-folders)),
+((0, 1), u'0-1', _(uonly there)),
+((1, 0), u'1-0', _(uin all sub-folders)),
+)])
+
+alsoProvides(scopesVocabulary, IVocabularyFactory)
+
+class DataSource(object):
+Source for the 'data' field
+
+implements(ISource)
+
+def __init__(self):
+self.context = None
+
+def __iter__(self):
+context = self.context
+if context is None:
+return iter([])
+tmutil = getThemeManager(context)
+root = context.root
+choices = {}
+
+if root == u'pages':
+for theme in tmutil.getThemes():
+theme_name = theme.name
+for page in theme.getPages():
+page_id = u'%s:%s' % (theme_name, page.name)
+choices[page_id] = u'%s / %s' % (theme.title, page.title)
+
+elif root == u'perspectives':
+for perspective in tmutil.listPerspectives():
+choices[perspective.name] = perspective.title
+
+elif root == u'engines':
+# FIXME
+choices[u'default'] = u'default'
+
+return iter(
+[SimpleTerm(value=k, title=v) for k, v in choices.items()])
+
+def data_source_binder(context):
+source = DataSource()
+from cpsskins.locations.interfaces import ILocation
+if not ILocation.providedBy(context):
+raise ValueError(The data source must be bound with a location as a 
+ context.)
+source.context = context
+return source
+
+alsoProvides(data_source_binder, IContextSourceBinder)
+
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3546 - cpsskins/branches/paris-sprint-2006/lib/prototype/src

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:09:46 2006
New Revision: 3546

Modified:
   cpsskins/branches/paris-sprint-2006/lib/prototype/src/prototype.js

Log:

- added the $$() method optimizer to prototype.js



Modified: cpsskins/branches/paris-sprint-2006/lib/prototype/src/prototype.js
==
--- cpsskins/branches/paris-sprint-2006/lib/prototype/src/prototype.js  
(original)
+++ cpsskins/branches/paris-sprint-2006/lib/prototype/src/prototype.js  Wed Jun 
28 21:09:46 2006
@@ -2005,4 +2005,166 @@
 
 return [valueL, valueT];
   }
-}
\ No newline at end of file
+}/
+ *
+ * An add-on to Prototype 1.5 to speed up the $$ function in usual cases.
+ *
+ * 
http://www.sylvainzimmer.com/index.php/archives/2006/06/25/speeding-up-prototypes-selector/
+ *
+ * Authors:
+ *- Sylvain ZIMMER sylvain _at_ jamendo.com
+ *
+ * Changelog:
+ *   v1 (2006/06/25)
+ * - Initial release
+ *
+ * License: AS-IS
+ *
+ * Trivia: Check out www.jamendo.com for some great Creative Commons music ;-)
+ *
+ /
+
+
+
+// We don't extend the Selector class because we want
+// to be able to use it if the expression is too complicated.
+var SelectorLiteAddon=Class.create();
+
+
+SelectorLiteAddon.prototype = {
+
+  // This is the constructor. It parses the stack of selectors.
+  initialize: function(stack) {
+
+this.r=[]; //results
+this.s=[]; //stack of selectors
+this.i=0;  //stack pointer
+
+//Parse the selectors
+for (var i=stack.length-1;i=0;i--) {
+
+  //This is the parsed selector. Format is : [tagname, id, classnames]
+  var s=[*,,[]];
+
+  //The unparsed current selector
+  var t=stack[i];
+
+  //Parse the selector backwards
+  var cursor=t.length-1;
+  do {
+
+var d=t.lastIndexOf(#);
+var p=t.lastIndexOf(.);
+cursor=Math.max(d,p);
+
+//Found a tagName
+if (cursor==-1) {
+  s[0]=t.toUpperCase();
+
+//Found a className
+} else if (d==-1 || p==cursor) {
+  s[2].push(t.substring(p+1));
+
+//Found an ID
+} else if (!s[1]) {
+  s[1]=t.substring(d+1);
+}
+t=t.substring(0,cursor);
+  } while (cursor0);
+  this.s[i]=s;
+}
+  },
+
+  //Returns a list of matched elements below a given root.
+  get:function(root) {
+this.explore(root || document,this.i==(this.s.length-1));
+return this.r;
+  },
+
+  //Recursive function where the actual search is being done.
+  // elt: current root element
+  // leaf: boolean, are we in a leaf of the search tree?
+  explore:function(elt,leaf) {
+
+//Parsed selector
+var s=this.s[this.i];
+
+//Results
+var r=[];
+
+//Selector has an ID, use it!
+if (s[1]) {
+
+  e=$(s[1]);
+  if (e  (s[0]==* || e.tagName==s[0])  e.childOf(elt)) {
+   r=[e];
+  }
+
+//Selector has no ID, search by tagname.
+} else {
+  r=$A(elt.getElementsByTagName(s[0]));
+}
+
+
+//Filter the results by classnames.
+//Todo: by attributes too?
+//Sidenote: The performance hit is often here.
+
+//Single className : that's fast!
+if (s[2].length==1) { //single classname
+  r=r.findAll(function(o) {
+
+//If the element has only one classname too, the test is simple!
+if (o.className.indexOf( )==-1) {
+  return o.className==s[2][0];
+} else {
+  return o.className.split(/\s+/).include(s[2][0]);
+}
+  });
+
+//Multipe classNames, a bit slower.
+} else if (s[2].length0) {
+  r=r.findAll(function(o) {
+
+//If the elemtn has only one classname, we can drop it.
+if (o.className.indexOf( )==-1) {
+  return false;
+} else {
+
+  //Check that all required classnames are present.
+  var q=o.className.split(/\s+/);
+  return s[2].all(function(c) {
+return q.include(c);
+  });
+}
+  });
+}
+
+
+//Append the results if we're in a leaf
+if (leaf) {
+  this.r=this.r.concat(r);
+
+//Continue exploring the tree otherwise
+} else {
+  ++this.i;
+  r.each(function(o) {
+this.explore(o,this.i==(this.s.length-1));
+  }.bind(this));
+}
+  }
+
+}
+
+
+//Overwrite the $$ function.
+var $$old=$$;
+
+var $$=function(a,b) {
+
+  //expression is too complicated, forward the call to prototype's function!
+  if (b || a.indexOf([)=0) return $$old.apply(this,arguments);
+
+  //Otherwise use our addon!
+  return new SelectorLiteAddon(a.split(/\s+/)).get();
+}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3547 - cpsskins/branches/paris-sprint-2006/locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:51:09 2006
New Revision: 3547

Modified:
   cpsskins/branches/paris-sprint-2006/locations/configure.zcml
   cpsskins/branches/paris-sprint-2006/locations/interfaces.py
   cpsskins/branches/paris-sprint-2006/locations/sources.py

Log:

- added missing ITerms view for the data source



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.zcmlWed Jun 
28 21:51:09 2006
@@ -1,6 +1,6 @@
 configure
 xmlns=http://namespaces.zope.org/zope;
-
+xmlns:browser=http://namespaces.zope.org/browser;
 
   class class=.location.Location
 
@@ -51,4 +51,12 @@
   type=cpsskins.setup.interfaces.INameType
   /
 
+  !-- views --
+  browser:view
+  provides=zope.app.form.browser.interfaces.ITerms
+  for=cpsskins.locations.sources.IDataSource
+  class=cpsskins.locations.sources.DataTerms
+  permission=zope.ManageContent
+  /
+
 /configure

Modified: cpsskins/branches/paris-sprint-2006/locations/interfaces.py
==
--- cpsskins/branches/paris-sprint-2006/locations/interfaces.py (original)
+++ cpsskins/branches/paris-sprint-2006/locations/interfaces.py Wed Jun 28 
21:51:09 2006
@@ -21,7 +21,7 @@
 from zope.i18nmessageid import MessageFactory
 from zope.schema import  TextLine, Choice
 
-from cpsskins.locations.sources import data_source_binder
+from cpsskins.locations.sources import data_source_binder, scopesVocabulary
 from cpsskins.schema import IntCoupleChoice
 
 _ = MessageFactory(cpsskins)
@@ -41,7 +41,7 @@
 
 scope = IntCoupleChoice(
 title=uScope,
-vocabulary=location scopes,
+vocabulary=scopesVocabulary(object()),
 )
 
 data = Choice(

Modified: cpsskins/branches/paris-sprint-2006/locations/sources.py
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.py(original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.pyWed Jun 28 
21:51:09 2006
@@ -17,10 +17,11 @@
 
 __docformat__ = reStructuredText
 
-from zope.interface import alsoProvides, implements
+from zope.app.form.browser.interfaces import ITerms
+from zope.interface import alsoProvides, implements, Interface
 from zope.i18nmessageid import MessageFactory
-from zope.schema.interfaces import ISource
 from zope.schema.interfaces import IVocabularyFactory, IContextSourceBinder
+from zope.schema.interfaces import IIterableSource
 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from cpsskins.utils import getThemeManager
@@ -39,10 +40,13 @@
 
 alsoProvides(scopesVocabulary, IVocabularyFactory)
 
+class IDataSource(IIterableSource):
+Data source interface
+
 class DataSource(object):
 Source for the 'data' field
 
-implements(ISource)
+implements(IDataSource)
 
 def __init__(self):
 self.context = None
@@ -84,3 +88,23 @@
 
 alsoProvides(data_source_binder, IContextSourceBinder)
 
+class DataTerms(object):
+ITerms adapter for the data source
+
+implements(ITerms)
+
+def __init__(self, source, request):
+self.source = source
+self.request = request
+
+def getTerm(self, value):
+for term in self.source:
+if term.value == value.value:
+return term
+raise LookupError(value not found in the source: %s % value.value)
+
+def getValue(self, token):
+for term in self.source:
+if term.token == token:
+return term.value
+raise LookupError(token not found in the source: %s % token)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3548 - cpsskins/branches/paris-sprint-2006/locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:57:06 2006
New Revision: 3548

Modified:
   cpsskins/branches/paris-sprint-2006/locations/sources.py

Log:

- use str(value) as token



Modified: cpsskins/branches/paris-sprint-2006/locations/sources.py
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.py(original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.pyWed Jun 28 
21:57:06 2006
@@ -32,10 +32,10 @@
 A vocabulary that contains a list of scopes
 
 return SimpleVocabulary(
-[SimpleTerm(value, token, title) for value, token, title in (
-((0, 0), u'0-0', _(uthere and in all sub-folders)),
-((0, 1), u'0-1', _(uonly there)),
-((1, 0), u'1-0', _(uin all sub-folders)),
+[SimpleTerm(value, title=title) for value, title in (
+((0, 0), _(uthere and in all sub-folders)),
+((0, 1), _(uonly there)),
+((1, 0), _(uin all sub-folders)),
 )])
 
 alsoProvides(scopesVocabulary, IVocabularyFactory)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3549 - cpsskins/branches/paris-sprint-2006

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:57:17 2006
New Revision: 3549

Modified:
   cpsskins/branches/paris-sprint-2006/schema.py

Log:

- conversion fix



Modified: cpsskins/branches/paris-sprint-2006/schema.py
==
--- cpsskins/branches/paris-sprint-2006/schema.py   (original)
+++ cpsskins/branches/paris-sprint-2006/schema.py   Wed Jun 28 21:57:17 2006
@@ -30,7 +30,7 @@
 def fromUnicode(self, text):
 self.validate(text)
 a, b = text[1:-1].split(u', ')
-return (a, b)
+return (int(a), int(b))
 
 def validate(self, value):
 # FIXME
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3550 - cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 21:59:33 2006
New Revision: 3550

Modified:
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- simplifications now that we have a field for Choices containing couples with
  integers.



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed Jun 
28 21:59:33 2006
@@ -19,13 +19,11 @@
 
 from zope.component import getUtility
 from zope.formlib import form
-from zope.schema import getFields
-from zope.schema.interfaces import IVocabularyFactory, IVocabularyTokenized
-from zope.schema.interfaces import ConstraintNotSatisfied
 
 from cpsskins import minjson as json
 from cpsskins.locations import Location
 from cpsskins.locations.interfaces import ILocation
+from cpsskins.locations.sources import data_source_binder, scopesVocabulary
 from cpsskins.setup.interfaces import IType, IIdentifiable
 from cpsskins.setup.interfaces import IResourceManager, IResource
 from cpsskins.setup.io import importSite, exportSite
@@ -143,14 +141,12 @@
 tmutil = getThemeManager(self.context)
 locations = tmutil.getLocationStorage()
 
-scopes_factory = getUtility(IVocabularyFactory, u'location scopes')
-
 info = {}
+scopes = scopesVocabulary(object())
 for root in locations.getRoots():
 info[root] = {}
 for location in locations.getLocations(root):
-scopes = scopes_factory(location)
-data_choices = data_choices_factory(location)
+data_choices = data_source_binder(location)
 path = location.path
 displayed_path = path
 if (u'/' in path and path[-1:] != u'/') or (u'/' not in path):
@@ -197,7 +193,6 @@
 class LocationForm(object):
 form_fields = form.Fields(ILocation, omit_readonly=True,
   render_context=True)
-
 prefix = u'form'
 
 def __init__(self, context, request):
@@ -209,21 +204,10 @@
 
 def submit(self, data):
 context = self.context
-scopes_factory = getUtility(IVocabularyFactory, u'location scopes')
-data_choices_factory = getUtility(IVocabularyFactory, u'location data')
-scopes = scopes_factory(context)
-data_choices = data_choices_factory(context)
 for form_field in self.form_fields:
 field = form_field.field
 name = form_field.__name__
 value = data[u'%s.%s' % (self.prefix, name)]
-if name == u'scope':
-value = scopes.getTermByToken(value).value
-field.validate(value)
-elif name == u'data':
-if value not in data_choices:
-raise ConstraintNotSatisfied(value)
-else:
-value = field.fromUnicode(value)
+value = field.fromUnicode(value)
 field.set(context, value)
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3551 - cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 22:02:21 2006
New Revision: 3551

Modified:
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- fix: must bind the field to the context



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed Jun 
28 22:02:21 2006
@@ -205,7 +205,7 @@
 def submit(self, data):
 context = self.context
 for form_field in self.form_fields:
-field = form_field.field
+field = form_field.field.bind(context)
 name = form_field.__name__
 value = data[u'%s.%s' % (self.prefix, name)]
 value = field.fromUnicode(value)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3552 - in cpsskins/branches/paris-sprint-2006: locations tests ui/screens/sitemanager

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 22:31:56 2006
New Revision: 3552

Modified:
   cpsskins/branches/paris-sprint-2006/locations/sources.py
   cpsskins/branches/paris-sprint-2006/tests/test_locations.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- added __contains__ to the data source. working implementation



Modified: cpsskins/branches/paris-sprint-2006/locations/sources.py
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.py(original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.pyWed Jun 28 
22:31:56 2006
@@ -45,6 +45,11 @@
 
 class DataSource(object):
 Source for the 'data' field
+
+ from zope.interface.verify import verifyClass
+ verifyClass(IDataSource, DataSource)
+True
+
 
 implements(IDataSource)
 
@@ -77,6 +82,15 @@
 return iter(
 [SimpleTerm(value=k, title=v) for k, v in choices.items()])
 
+def __len__(self):
+return len(list(self))
+
+def __contains__(self, value):
+for term in self:
+if term.value == value:
+return True
+return False
+
 def data_source_binder(context):
 source = DataSource()
 from cpsskins.locations.interfaces import ILocation
@@ -89,8 +103,13 @@
 alsoProvides(data_source_binder, IContextSourceBinder)
 
 class DataTerms(object):
-ITerms adapter for the data source
+ITerms adapter for the data source
+
+ from zope.interface.verify import verifyClass
+ verifyClass(ITerms, DataTerms)
+True
 
+
 implements(ITerms)
 
 def __init__(self, source, request):

Modified: cpsskins/branches/paris-sprint-2006/tests/test_locations.py
==
--- cpsskins/branches/paris-sprint-2006/tests/test_locations.py (original)
+++ cpsskins/branches/paris-sprint-2006/tests/test_locations.py Wed Jun 28 
22:31:56 2006
@@ -19,11 +19,12 @@
 
 import unittest
 
-from zope.testing.doctestunit import DocFileSuite
+from zope.testing.doctestunit import DocFileSuite, DocTestSuite
 
 def test_suite():
 return unittest.TestSuite((
 DocFileSuite('../locations/README.txt'),
+DocTestSuite('cpsskins.locations.sources'),
 ))
 
 if __name__ == '__main__':

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed Jun 
28 22:31:56 2006
@@ -206,8 +206,7 @@
 context = self.context
 for form_field in self.form_fields:
 field = form_field.field.bind(context)
-name = form_field.__name__
-value = data[u'%s.%s' % (self.prefix, name)]
+value = data[u'%s.%s' % (self.prefix, form_field.__name__)]
 value = field.fromUnicode(value)
 field.set(context, value)
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3553 - in cpsskins/branches/paris-sprint-2006: . locations

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 22:36:46 2006
New Revision: 3553

Added:
   cpsskins/branches/paris-sprint-2006/schema.py   (contents, props changed)
Modified:
   cpsskins/branches/paris-sprint-2006/locations/sources.py
   cpsskins/branches/paris-sprint-2006/locations/sources.txt

Log:

- fixed infinite recursion

- test updates



Modified: cpsskins/branches/paris-sprint-2006/locations/sources.py
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.py(original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.pyWed Jun 28 
22:36:46 2006
@@ -83,7 +83,7 @@
 [SimpleTerm(value=k, title=v) for k, v in choices.items()])
 
 def __len__(self):
-return len(list(self))
+return len([t for t in self])
 
 def __contains__(self, value):
 for term in self:

Modified: cpsskins/branches/paris-sprint-2006/locations/sources.txt
==
--- cpsskins/branches/paris-sprint-2006/locations/sources.txt   (original)
+++ cpsskins/branches/paris-sprint-2006/locations/sources.txt   Wed Jun 28 
22:36:46 2006
@@ -22,9 +22,12 @@
 ... )
 
 if the field is not bound to a context, no choices will be made available:
- print list(data_choice.source)
+ list(data_choice.source)
 []
 
+ len(data_choice.source)
+0
+
 let us create a source binder and bind the field to the context:
 
  from cpsskins.locations.sources import data_source_binder
@@ -52,6 +55,15 @@
 in the context of the location the data source returns a list of pages:
 
  data_choice_in_context = data_choice_in_context.bind(l)
- print [t.value for t in data_choice_in_context.source]
+ [t.value for t in data_choice_in_context.source]
 [u'Theme:ThemePage']
 
+ len(data_choice_in_context.source)
+1
+
+ u'Theme:ThemePage' in data_choice_in_context.source
+True
+
+ u'unknown' in data_choice_in_context.source
+False
+

Added: cpsskins/branches/paris-sprint-2006/schema.py
==
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/schema.py   Wed Jun 28 22:36:46 2006
@@ -0,0 +1,38 @@
+##
+#
+# 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 zope.schema.interfaces import IField
+from zope.schema import Choice
+
+class IIntCoupleChoice(IField):
+A choice field containing couples of integers e.g. (0, 1)
+
+class IntCoupleChoice(Choice):
+implements(IIntCoupleChoice)
+
+def fromUnicode(self, text):
+self.validate(text)
+a, b = text[1:-1].split(u', ')
+return (int(a), int(b))
+
+def validate(self, value):
+# FIXME
+return True
+
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3554 - cpsskins/branches/paris-sprint-2006/storage

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 22:47:09 2006
New Revision: 3554

Modified:
   cpsskins/branches/paris-sprint-2006/storage/locations.py

Log:

- don't count empty strings as method names



Modified: cpsskins/branches/paris-sprint-2006/storage/locations.py
==
--- cpsskins/branches/paris-sprint-2006/storage/locations.py(original)
+++ cpsskins/branches/paris-sprint-2006/storage/locations.pyWed Jun 28 
22:47:09 2006
@@ -120,7 +120,7 @@
 if key[0] != root:
 continue
 methods.add(key[1])
-return list(methods)
+return list(methods - Set([u'']))
 
 def getPaths(self, root=u''):
 paths = Set()
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins


[Z3lab-checkins] r3556 - cpsskins/branches/paris-sprint-2006/ui/screens/common

2006-06-28 Thread jmorliaguet
Author: jmorliaguet
Date: Wed Jun 28 23:11:03 2006
New Revision: 3556

Modified:
   cpsskins/branches/paris-sprint-2006/ui/screens/common/action_pad.pt

Log:
- optimizations



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/action_pad.pt
==
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/action_pad.pt 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/action_pad.pt Wed Jun 
28 23:11:03 2006
@@ -1,16 +1,14 @@
-div class=actionPad
-
-  ins class=model cite=@@getHint?msgid=hint-site-manager/ins
+div class=actionPad
+ tal:define=hint nocall:context/@@getHint;
+ view nocall:context/@@getView;
+ controller nocall:context/@@getController
+  ins class=model tal:content=python: hint('hint-site-manager') /
   a 
href=javascript:CPSSkins.getControllerById('main-editor-perspectives').switchTo('site-manager')Site
 manager/a
-
-  ins class=model cite=@@getHint?msgid=hint-page-designer/ins
+  ins class=model tal:content=python: hint('hint-page-designer') /
   a 
href=javascript:CPSSkins.getControllerById('main-editor-perspectives').switchTo('page-designer')Page
 designer/a
-
-  ins class=model cite=@@getHint?msgid=hint-content-author/ins
+  ins class=model tal:content=python: hint('hint-content-author') /
   a 
href=javascript:CPSSkins.getControllerById('main-editor-perspectives').switchTo('content-author')Content
 author/a
-
   !-- tooltip --
-  ins class=view cite=@@getView?id=tooltip/ins
-  ins class=controller cite=@@getController?id=show-hide-tooltip/ins
-
+  ins class=view tal:content=python: view('tooltip')/ins
+  ins class=controller tal:content=python: 
controller('show-hide-tooltip')/ins
 /div
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins