[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - field.py:1.11

Jim Fulton jim@zope.com
Mon, 30 Jun 2003 12:24:04 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv18263/src/zope/app/browser/services

Modified Files:
	field.py 
Log Message:
Removed unused component location field and associated widgets and
tests.


=== Zope3/src/zope/app/browser/services/field.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/services/field.py:1.10	Wed Jun 25 17:18:53 2003
+++ Zope3/src/zope/app/browser/services/field.py	Mon Jun 30 12:23:33 2003
@@ -55,154 +55,6 @@
         url += "/@@SelectedManagementView.html"
         return '<a href="%s">%s</a>' % (url, path)
 
-class ComponentLocationWidget(Widget, BrowserView):
-
-    implements(IBrowserWidget)
-
-    # Names used:
-    #
-    #  name.p  the value of the path
-    #  name.d  the value of the dotted module name
-
-    def haveData(self):
-        # do I have name.p xor name.m ?
-        form = self.request.form
-
-        has_p = self.name+'.p' in form
-        has_d = self.name+'.d' in form
-
-        return bool((has_p or has_d) and not (has_p and has_d))
-
-    def getData(self, optional=0):
-        field = self.context
-        form = self.request.form
-        name_p = self.name+'.p'
-        name_d = self.name+'.d'
-
-        path = form.get(self.name+'.p', '').strip()
-        dottedname = form.get(self.name+'.d', '').strip()
-
-        if path and not path.startswith('/'):
-            raise WidgetInputError(
-                self.context.__name__, self.title,
-                'The component path must start with a "/"')
-
-        if dottedname and '/' in dottedname:
-            raise WidgetInputError(
-                self.context.__name__, self.title,
-                'A dotted module name cannot contain a "/"')
-
-        if path and dottedname:
-            location = ''
-        else:
-            location = path or dottedname
-
-        if not location:
-            if path and dottedname:
-                raise WidgetInputError(
-                        self.context.__name__, self.title,
-                        'Either give a module or select a component')
-            # No user input
-            if field.required and not optional:
-                raise MissingInputError(field.__name__, field.title,
-                                        'the field is required')
-            return field.default
-
-        location = unicode(location)
-
-        if not optional:
-            try:
-                field.validate(location)
-            except ValidationError, v:
-                raise WidgetInputError(self.context.__name__,
-                                       self.title, str(v))
-        return location
-
-    def __call__(self):
-        'See IBrowserWidget'
-        field = self.context
-        form = self.request.form
-        name = self.name
-
-        if self._data is None:  # no data has been set with Widget.setData(),
-                                # so use the data in the form
-
-            path = form.get(name+'.p', '').strip()
-            dottedname = form.get(name+'.d', '').strip()
-
-            if path or dottedname:
-                location = path or dottedname
-                # XXX is validation here really needed?
-                #field.validate(location)
-            else:  # otherwise, use the default
-                location = field.default or ''
-                if location.startswith('/'):
-                    path = location
-                    dottedname = ''
-                else:
-                    dottedname = location
-                    path = ''
-        else:
-            # data has been set with Widget.setData()
-            location = self._data
-            if location.startswith('/'):
-                path = location
-                dottedname = ''
-            else:
-                dottedname = location
-                path = ''
-
-        selectmarkup = renderPathSelect(field.context, field.type,
-                                        name+'.p', path)
-        inputmarkup = '<input type="text" name="%s.d" value="%s">' % (
-                      name, dottedname)
-        HTML = 'path: %s<br />dotted name: %s' % (selectmarkup, inputmarkup)
-        return HTML
-
-    def hidden(self):
-        'See IBrowserWidget'
-        if self._data is None:
-            data = self.getData(1)
-        else:
-            data = self._data
-
-        if not data:
-            return ''
-
-        if data.startswith('/'):
-            name = self.name+'.p'
-        else:
-            name = self.name+'.d'
-
-        return '<input type="hidden" name="%s" value=%s />' % (
-               name, quoteattr(data))
-
-    def label(self):
-        return '<label for="%s">%s</label>' % (self.name, self.title)
-
-    def row(self):
-        return '<div class="label">%s</div><div class="field">%s</div>"' % (
-                self.label(), self())
-
-    # --- deprecated methods of IBrowserWidget
-
-    def renderHidden(self, value):
-        'See IBrowserWidget'
-        raise NotImplementedError
-
-    def render(self, value):
-        'See IBrowserWidget'
-        raise NotImplementedError
-
-class ComponentLocationDisplayWidget(ComponentLocationWidget):
-    def __call__(self):
-        if self._data is None:
-            data = self.getData(1)
-        else:
-            data = self._data
-        # location = data
-        return data
-
 def renderPathSelect(context, type, name, selected, empty_message=''):
     service_manager = getServiceManager(context)
     info = service_manager.queryComponent(type)