[Zope-CVS] CVS: Products/PageDesign - PageDesign.py:1.4 Slot.py:1.3

Shane Hathaway shane@cvs.zope.org
Mon, 12 Aug 2002 22:42:40 -0400


Update of /cvs-repository/Products/PageDesign
In directory cvs.zope.org:/tmp/cvs-serv25434

Modified Files:
	PageDesign.py Slot.py 
Log Message:
Now the windows are initially not visible except for a blue dashed border.
You just click to make the window appear.  You can still drag and drop without
expanding the windows, though.

Also added an option to pre-expand the windows so that older browsers can cope.


=== Products/PageDesign/PageDesign.py 1.3 => 1.4 ===
--- Products/PageDesign/PageDesign.py:1.3	Mon Aug 12 10:39:29 2002
+++ Products/PageDesign/PageDesign.py	Mon Aug 12 22:42:39 2002
@@ -33,7 +33,7 @@
 from OFS.SimpleItem import SimpleItem
 from OFS.PropertyManager import PropertyManager
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Globals import ImageFile
+from Globals import DTMLFile, ImageFile
 
 from RawFile import RawFile
 from SlotProvider import SlotProvider
@@ -62,6 +62,7 @@
     _slots = None  # { slot_name -> (element_id,) }
     template_id = None
     title = ''
+    pre_expand = 0
     _v_rendering = 0
     slots = SlotProvider()
 
@@ -75,7 +76,7 @@
     scripts_js = RawFile('scripts.js', 'text/javascript', _www)
 
     security.declareProtected(change_page_designs, 'pagedesign_css')
-    pagedesign_css = RawFile('pagedesign.css', 'text/css', _www)
+    pagedesign_css = DTMLFile('pagedesign.css', _www)
 
     security.declareProtected(change_page_designs, 'manage_main')
     manage_main = PageTemplateFile('main.pt', _www)
@@ -95,13 +96,14 @@
 
     head_html = '''
     <!-- Page design scripts and styles -->
-    <link type="text/css" href="%(design_url)s/pagedesign_css"
-          rel="stylesheet" />
     <script type="text/javascript">
       %(scripts)s
       design_url = '%(design_url)s';
     </script>
-    <!-- End page design scripts -->
+    <style type="text/css">
+      %(style)s
+    </style>
+    <!-- End page design scripts and styles -->
     '''
 
     footer_html = '''
@@ -307,7 +309,8 @@
         index = match.end(0)
         head_prefix = self.head_html % {
             'design_url': self.absolute_url(),
-            'scripts': self.scripts_js()
+            'style': self.pagedesign_css(),
+            'scripts': self.scripts_js(),
             }
         s = '%s%s%s' % (s[:index], head_prefix, s[index:])
         match = end_of_body_search(s)
@@ -328,7 +331,7 @@
     def render(self, **kw):
         """Renders the design."""
         if self._v_rendering:
-            raise DesignError, "Recursive page design rendering"
+            raise DesignError, "A page design cannot be embedded in itself"
         self._v_rendering = 1
         try:
             template = self.getTemplate()
@@ -397,6 +400,7 @@
     _properties = (
         {'id': 'title', 'type': 'string', 'mode': 'w'},
         {'id': 'template_id', 'type': 'string', 'mode': 'w'},
+        {'id': 'pre_expand', 'type': 'boolean', 'mode': 'w'},
         )
 
     security.declareProtected(change_page_designs, 'manage_propertiesForm')


=== Products/PageDesign/Slot.py 1.2 => 1.3 ===
--- Products/PageDesign/Slot.py:1.2	Mon Aug 12 10:39:29 2002
+++ Products/PageDesign/Slot.py	Mon Aug 12 22:42:39 2002
@@ -78,7 +78,7 @@
     title="Add element to slot: %(slot_name)s" /></a></div>'''
 
     element_html = '''<div class="design-element" id="%(clipboard_path)s">
-    <table class="design-element-titlebar" width="100%%"><tr>
+    <table class="design-element-titlebar" width="100%%" cellpadding="0"><tr>
     <td align="left">%(titlebar)s</td>
     <td align="right">%(controls)s</td>
     </tr></table>
@@ -111,11 +111,11 @@
         icon_tag = edit_tag = ''
         icon_url = element.getIconURL()
         if icon_url:
-            icon_tag = '<img border="0" src="%s" /> ' % icon_url
+            icon_tag = '<img border="0" src="%s" align="center" /> ' % icon_url
         edit_url = element.getEditURL()
         if edit_url:
-            edit_tag = (' <a href="%s"><img border="0" src="edit_icon" /></a>'
-                        % edit_url)
+            edit_tag = (' <a href="%s"><img border="0" src="edit_icon"'
+                        ' align="center" /></a>' % edit_url)
         
         kw['titlebar'] = icon_tag + escape(kw['title']) + edit_tag
         kw['controls'] = '\n'.join(c)
@@ -175,8 +175,10 @@
                 text = e.render(design, editable, index)
             except:
                 # Show the exception.
-                text = "<i>%s</i>" % (
-                    escape(('%s: %s' % (sys.exc_info()[:2]))[:80]))
+                t, v = sys.exc_info()[:2]
+                t = getattr(t, '__name__', t)
+                text = "<code>%s</code>" % (
+                    escape(('%s: %s' % (t, v))[:80]))
 
             if editable:
                 design_url = design.absolute_url()