[Zope-CMF] Page view without CMF framing

Ausum Studio ausum_studio@hotmail.com
Sat, 24 Aug 2002 12:10:33 -0500


Make sure that you're running a CMF supporting object actions (like CMF
1.3). Within portal_types, each object has a tab called "actions". You'll se
how easy is to define and add a new action (meaning a method tailored for a
specific object) that will appear within the action_box of your document.
You can use the method you're currently working at.

About the other subject, it looks like your problem is at your definition of
"html":

self.meta_type == 'Folder' won't work at the root of your CMF site because
its meta_type is precisely  'CMF site'. Generally speaking you should use
the "isPrincipiaFolderish" property when you want to detect a folder-like
object.


Ausum



----- Original Message -----
From: "J C Lawrence" <claw@kanga.nu>
To: "Ausum Studio" <ausum_studio@hotmail.com>
Cc: <zope-cmf@zope.org>
Sent: Saturday, August 24, 2002 3:42 AM
Subject: Re: [Zope-CMF] Page view without CMF framing


> On Sat, 24 Aug 2002 03:13:10 -0500
> Ausum Studio <ausum_studio@hotmail.com> wrote:
>
> > Just write a skin (use the name you want, 'pdf_friendly' for example)
> > to render the content of your current document as clean as you desire
> > it, by carefully including just your relevant content, getting rid of
> > navigational aids like 'action_box', for example.
>
> > Then within portal_types add it as an action to every wiki or wiki
> > page object.
>
> That sounds neater than what I ended up doing.  However I've yet to
> figure out how to do what I want with a portal_types action.  Care to
> give a hint how to clean up the below with portal_types?
>
> Using:
>
>   http://cmf.zope.org/Members/jshell/News/PrintablePage
>   http://www.easysw.com/htmldoc/
>   http://www.zope.org/Members/mjablonski/howtoPDF/
>
> Getting it all to work took four steps:
>
>   1) Installed htmldoc.  (There's a Debian package)
>
>   2) Getting html2pdf.py happy with Plone.  The essential changes were
>   to change the condition to:
>
>         if self.meta_type=='Folder':
>                 html = self.index_html(self,self.REQUEST,self.REQUEST.R$
>         else:
>                 html = self()
>
>   3) Creating a new, "printable" skin:
>
>     a) Created a "printable" folder under portal_skins.
>
>     b) Copied main_template from portal_skins/plone_templates to the new
>     printable folder.
>
>     c) Edited main_template in the printable folder such that the guts
>     looks like:
>
> --<cut>--
> <table class="columns">
>     <tbody>
>         <tr>
>             <td class="main"
>                 tal:define="global show_border
python:here.showEditableBorder(template_id=template.getId(),
actions=actions);">
>
>                 <metal:block metal:define-slot="super"
>              tal:condition="show_border" >
>
>                 <div class="contentBar">
>                 &nbsp;
>                 </div>
>
>                 </metal:block>
>
>                 <div class="document"
>                      tal:attributes="class python:test(show_border,
'editableDocument', 'document')">
>
>                     <metal:block metal:define-slot="main"
tal:content="nothing">
>                     Page body text
>                     </metal:block>
>
>                     <metal:block metal:define-slot="sub">
>                     <tal
metal:use-macro="here/viewThreadsAtBottom/macros/discussionView" />
>                     </metal:block>
>                 </div>
>             </td>
>         </tr>
>     </tbody>
> </table>
> --<cut>--
>
>     d) In portal_skins Properties added a new skin, "printable", and
>     copied the value of the Plone Skin, "Plone Default" to it.
>
>     e) Prepended "printable" to the new printable skin value.
>
>   4) Getting a PDF link on all pages:
>
>     a) Copy, "navigation_slot" from
>     portal_skins/plone_templates/ui_slots to the custom folder.
>
>     b) Edit, "navigation_slot" to add the following section at the end
>     of the tbody tag:
>
> --<cut>--
>         <tr class="odd">
>             <td colspan="2">
>
>                <a href="../folder_contents"
>                   tal:attributes="href
string:${here/absolute_url}/html2pdf?plone_skin=printable">
>                    <img src="dummy.gif"
>                         alt=">"
>                         border="0"
>                         tal:attributes="src
string:$portal_url/linkTransparent.gif" />
>                   PDF
>                </a>
>             </td>
>         </tr>
> --<cut>--
>
> Done.
>
> Caveats: On very brief checking it seems to work everywhere EXCEPT for
> the root of a Plone site where it gives an AttributeError on:
>
>   Traceback (innermost last):
>     File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
>     File /var/lib/zope/Products/Localizer/__init__.py, line 57, in
new_publish
>     File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 114, in
publish
>     File /usr/lib/zope/lib/python/Zope/__init__.py, line 159, in
zpublisher_exception_hook
>       (Object: site)
>     File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 98, in
publish
>     File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
>       (Object: html2pdf)
>     File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 39, in
call_object
>       (Object: html2pdf)
>     File
/usr/lib/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line
198, in __call__
>       (Object: html2pdf)
>       (Info: ((&lt;CMFSite instance at 8eaf7c8&gt;,), {}, None))
>     File /var/lib/zope/Extensions/html2pdf.py, line 20, in html2pdf
>       (Object: site)
>   AttributeError: (see above)
>
> Where line 20 is a call to self() in my edited html2pdf.py.
>
> I haven't attempted to debug this.  Its late, I'm tired.  Directions on
> how to make this cleaner via portal_types would be most appreciated.
> Heck, I'll promise to doc this all on the dogbowl for some cleanup
> assistance...
>
> --
> J C Lawrence
> ---------(*)                Satan, oscillate my metallic sonatas.
> claw@kanga.nu               He lived as a devil, eh?
> http://www.kanga.nu/~claw/  Evil is a name of a foeman, as I live.
>