[Zope-CVS] CVS: Products/CompositePage - rawfile.py:1.2 slot.py:1.6 transformers.py:1.5

Shane Hathaway shane at zope.com
Mon Dec 22 12:28:41 EST 2003


Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv10853

Modified Files:
	rawfile.py slot.py transformers.py 
Log Message:
Changed to use images for insertion points and element handles.

Test with IE, but we could simplify somewhat.  I think the handles can
be simple image objects.


=== Products/CompositePage/rawfile.py 1.1 => 1.2 ===
--- Products/CompositePage/rawfile.py:1.1	Fri Sep 26 17:21:05 2003
+++ Products/CompositePage/rawfile.py	Mon Dec 22 12:28:10 2003
@@ -21,6 +21,7 @@
 from time import time
 
 import Acquisition
+from Acquisition import aq_inner, aq_parent
 import Globals
 from Globals import package_home
 from App.Common import rfc1123_date
@@ -89,6 +90,12 @@
         f = open(self.path, 'rb')
         data = f.read()
         f.close()
+        data = self.interp(data)
+        return data
+
+    def interp(self, data):
+        """Hook point for subclasses that modify the file content.
+        """
         return data
 
     index_html = None  # Tells ZPublisher to use __call__
@@ -99,4 +106,16 @@
         RESPONSE.setHeader('Content-Type', self.content_type)
         RESPONSE.setHeader('Last-Modified', self.lmh)
         return ''
+
+
+class InterpolatedFile(RawFile):
+    """Text data, stored in a file, with %(xxx)s interpolation.
+    """
+
+    def interp(self, data):
+        parent_url = aq_parent(aq_inner(self)).absolute_url()
+        d = {
+            "parent_url": parent_url,
+            }
+        return data % d
 


=== Products/CompositePage/slot.py 1.5 => 1.6 ===
--- Products/CompositePage/slot.py:1.5	Tue Oct 14 18:40:04 2003
+++ Products/CompositePage/slot.py	Mon Dec 22 12:28:10 2003
@@ -43,6 +43,17 @@
 _www = os.path.join(os.path.dirname(__file__), "www")
 
 
+EDIT_TAG = '''<div class="slot_element" source_path="%s">
+<div class="slot_element_header"></div>
+<div class="slot_element_body">%s</div>
+</div>'''
+
+# VIEW_TAG includes a <div> just to ensure that the element is
+# rendered as an HTML block in both editing mode and view mode.
+VIEW_TAG = '''<div>
+%s
+</div>'''
+
 class NullElement(SimpleItem):
     """Temporary slot content
     """
@@ -161,13 +172,9 @@
 
             if editing:
                 path = escape('/'.join(obj.getPhysicalPath()))
-                tag = '<div class="slot_element" source_path="%s">' % path
+                res.append(EDIT_TAG % (path, text))
             else:
-                # Output a <div> just to ensure that the element
-                # is rendered as an HTML block in both editing mode
-                # and rendering mode.
-                tag = "<div>"
-            res.append("%s\n%s\n</div>" % (tag, text))
+                res.append(VIEW_TAG % text)
 
         if editing and allow_add:
             index = len(items)


=== Products/CompositePage/transformers.py 1.4 => 1.5 ===
--- Products/CompositePage/transformers.py:1.4	Thu Oct  9 17:29:15 2003
+++ Products/CompositePage/transformers.py	Mon Dec 22 12:28:10 2003
@@ -26,7 +26,7 @@
 from AccessControl import ClassSecurityInfo
 from AccessControl.ZopeGuards import guarded_getattr
 
-from rawfile import RawFile
+from rawfile import RawFile, InterpolatedFile
 
 
 _common = os.path.join(os.path.dirname(__file__), "common")
@@ -63,7 +63,13 @@
     pdlib_js = RawFile("pdlib.js", "text/javascript", _common)
     edit_js = RawFile("edit.js", "text/javascript", _common)
     pdstyles_css = RawFile("pdstyles.css", "text/css", _common)
-    editstyles_css = RawFile("editstyles.css", "text/css", _common)
+    editstyles_css = InterpolatedFile("editstyles.css", "text/css", _common)
+    grip_horizontal = RawFile("grip_horizontal.gif", "image/gif", _common)
+    grip_horizontal_active = RawFile("grip_horizontal_active.gif",
+                                     "image/gif", _common)
+    grip_vertical = RawFile("grip_vertical.gif", "image/gif", _common)
+    grip_vertical_active = RawFile("grip_vertical_active.gif",
+                                   "image/gif", _common)
 
     header_templates = (PageTemplateFile("header.pt", _common),)
     top_templates = ()




More information about the Zope-CVS mailing list