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

Reply via email to