[Zope3-checkins] CVS: Zope3/src/zope/app/services - view.py:1.7

Albertas Agejevas alga@codeworks.lt
Fri, 21 Feb 2003 09:50:35 -0500


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

Modified Files:
	view.py 
Log Message:
Added calling the validation of PageConfiguration to its edit form.


=== Zope3/src/zope/app/services/view.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/view.py:1.6	Tue Feb 11 10:59:56 2003
+++ Zope3/src/zope/app/services/view.py	Fri Feb 21 09:50:04 2003
@@ -256,20 +256,20 @@
         self.template = template
         self.attribute = attribute
 
-    def _validate(self):
-        if self.template is not None and self.attribute is not None:
+    def validate(self):
+        if self.template and self.attribute:
             raise ConfigurationError(
                 "PageConfiguration for %s view name %s: "
                 "Cannot have both 'template' and 'attribute' at the same time." %
                 (self.forInterface, self.viewName))
 
-        if self.template is None and self.attribute is None:
+        if not self.template and not self.attribute:
             raise ConfigurationError(
                 "PageConfiguration for %s view name %s: "
                 "Should have a 'template' or 'attribute' attribute." %
                 (self.forInterface, self.viewName))
 
-        if self.class_ is None and self.attribute is not None:
+        if not self.class_ and self.attribute:
             raise ConfigurationError(
                 "PageConfiguration for %s view name %s: "
                 "Cannot have an 'attribute' without a 'class_'." %
@@ -278,7 +278,7 @@
     def getView(self, object, request):
 
 
-        self._validate()
+        self.validate()
 
         sm = getServiceManager(self)
 
@@ -293,7 +293,7 @@
         # This is needed because we need to do an unrestricted traverse
         root = removeAllProxies(getPhysicalRoot(sm))
 
-        if self.attribute is not None:
+        if self.attribute:
             template = getattr(view, self.attribute)
         else:
             template = traverse(root, self.template)