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=u"Path",
         )
 
-    scope = Choice(
+    scope = IntCoupleChoice(
         title=u"Scope",
         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

Reply via email to