Hi, I've writen a product with Archetypes to integrate external html-code into my plone site. Basically I followed the instructions on http://plone.org/documentation/how-to/integrate-external-content. In Plone 2.5 it works fine. Now I switched to Plone 3.0.1 and had to customize a few things to make it run. The only thing that don't work, is setting a PublicationsHTML object as a dafault page. Everything else like install, "View" "Edit" etc. works. I attached a code snippet below. Maybe someone can point me out where I made a fault.
Thanks... -paul What I have done: added "Publications HTML" to default_page_types in portal_properties/site_properties. added a folder called "publikationen" to the root folder added a PublicationsHTML page to the "publikationen" folder called "alle". set "alle" as a default view for "publikationen". then when I click on the "publikationen" folder I get the following error: Request URL http://pc13:8082/inb-website/publikationen/alle/publications_view_py Exception Type AttributeError Exception Value 'NoneType' object has no attribute 'Title' Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module Products.CMFCore.FSPythonScript, line 140, in __call__ Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPythonScript, line 196, in _exec Module None, line 12, in publications_view_py - <FSPythonScript at /inb-website/publications_view_py used for /inb-website/publikationen/alle> - Line 12 Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPageTemplate, line 216, in _exec Module Products.CMFCore.FSPageTemplate, line 155, in pt_render Module Products.PageTemplates.PageTemplate, line 89, in pt_render Module zope.pagetemplate.pagetemplate, line 117, in pt_render Module zope.tal.talinterpreter, line 271, in __call__ Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 891, in do_useMacro Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 957, in do_defineSlot Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 861, in do_defineMacro Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 534, in do_optTag_tal Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal Module zope.tales.tales, line 696, in evaluate - URL: file:/opt/Plone-3.0.1/zeocluster/client1/Products/CMFPlone/skins/plone_templates/main_template.pt - Line 103, Column 18 - Expression: <StringExpr u'plone.contentviews'> - Names: {'container': <PloneSite at /inb-website>, 'context': <PublicationsHTML at /inb-website/publikationen/alle>, 'default': , 'here': <PublicationsHTML at /inb-website/publikationen/alle>, 'loop': {}, 'nothing': None, 'options': {'args': (), 'contents': "left out, was too big", 'extpath': u'/nfshome/panzer/work/html/INB.html/'}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x451c22ac>, 'request': <HTTPRequest, URL=http://pc13:8082/inb-website/publikationen/alle/publications_view_py>, 'root': <Application at >, 'template': <FSPageTemplate at /inb-website/publications_view used for /inb-website/publikationen/alle>, 'traverse_subpath': [], 'user': <PloneUser 'peter'>} Module Products.Five.browser.providerexpression, line 37, in __call__ Module plone.app.viewletmanager.manager, line 140, in render Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.PageTemplates.PageTemplateFile, line 129, in _exec Module Products.PageTemplates.PageTemplate, line 89, in pt_render Module zope.pagetemplate.pagetemplate, line 117, in pt_render Module zope.tal.talinterpreter, line 271, in __call__ Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 855, in do_condition Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 534, in do_optTag_tal Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal Module zope.tales.tales, line 696, in evaluate - URL: contentactions - Line 31, Column 8 - Expression: <StringExpr 'plone.contentmenu'> - Names: {'container': <PublicationsHTML at /inb-website/publikationen/alle>, 'context': <PublicationsHTML at /inb-website/publikationen/alle>, 'default': , 'here': <PublicationsHTML at /inb-website/publikationen/alle>, 'loop': {}, 'nothing': None, 'options': {'args': ()}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x43bd212c>, 'request': <HTTPRequest, URL=http://pc13:8082/inb-website/publikationen/alle/publications_view_py>, 'root': <Application at >, 'template': <ImplicitAcquirerWrapper object at 0x4449314c>, 'traverse_subpath': [], 'user': <PloneUser 'peter'>, 'view': <Products.Five.viewlet.metaconfigure.ContentActionsViewlet object at 0x44a4954c>, 'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x450b540c>} Module Products.Five.browser.providerexpression, line 37, in __call__ Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.PageTemplates.PageTemplateFile, line 129, in _exec Module Products.PageTemplates.PageTemplate, line 89, in pt_render Module zope.pagetemplate.pagetemplate, line 117, in pt_render Module zope.tal.talinterpreter, line 271, in __call__ Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 586, in do_setLocal_tal Module zope.tales.tales, line 696, in evaluate - URL: contentmenu - Line 1, Column 0 - Expression: <PathExpr standard:'view/menu'> - Names: {'container': <PublicationsHTML at /inb-website/publikationen/alle>, 'context': <PublicationsHTML at /inb-website/publikationen/alle>, 'default': , 'here': <PublicationsHTML at /inb-website/publikationen/alle>, 'loop': {}, 'nothing': None, 'options': {'args': ()}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x42845dec>, 'request': <HTTPRequest, URL=http://pc13:8082/inb-website/publikationen/alle/publications_view_py>, 'root': <Application at >, 'template': <ImplicitAcquirerWrapper object at 0x43ec706c>, 'traverse_subpath': [], 'user': <PloneUser 'peter'>, 'view': <plone.app.contentmenu.view.ContentMenuProvider object at 0x44273a2c>, 'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x4487fc4c>} Module zope.tales.expressions, line 217, in __call__ Module Products.PageTemplates.Expressions, line 161, in _eval Module Products.PageTemplates.Expressions, line 123, in render Module plone.app.contentmenu.view, line 41, in menu Module zope.app.publisher.browser.menu, line 66, in getMenuItems Module zope.app.publisher.browser.menu, line 176, in getMenu Module plone.app.contentmenu.menu, line 286, in getMenuItems AttributeError: 'NoneType' object has no attribute 'Title' code snippet: PublicationsHTML.py: Archetypes code. in skins/PublicationsHTML/: publications_view_py.py: script to put the external page through a page template publications_view.pt: this is the page template that defines the look of the external content PublicationsHTML.py: from AccessControl import ClassSecurityInfo from Products.Archetypes.public import * from Products.CMFCore import permissions import re class PublicationsHTML(BaseContent): security = ClassSecurityInfo() portal_type = meta_type = 'PublicationsHTML' archetype_name = 'Publications HTML' allowed_content_types = [] __implements__ = getattr(BaseContent,'__implements__',()) #generation of id from title _at_rename_after_creation = True schema=BaseSchema + Schema(( StringField('link', required='True', widget=StringWidget(description='Enter a absolute path to an publications html', description_msgid='PublicationsHTML_help_link', i18n_domain='PublicationsHTML', label='Link', label_msgid='PublicationsHTML_label_link', size='120', ), ), StringField('linkdescription', searchable=1, widget=TextAreaWidget(label='Description', description='Enter a brief description of the page', ), ), ), ) #Methods def getLinkdescription(self): #linkdescription is just the Description from the dublin core # the accessor for dublin core metadata is a bit inconsistent # with Archetype, so these accessor/settor methods are required return self.Description() def setLinkdescription(self, val): return self.setDescription(val) def extractBody(self, file_name,REQUEST): """extracts the Body of a HTML document from REQUEST""" try: page = open(file_name,'rb') data = page.read() page.close() except IOError: data = '<html> <body> <p> file not found </p> </body> </html>' contents = 'text/html' REQUEST.RESPONSE.setHeader('Content-Type', contents) #check that it is an html document if re.search('<(h|H)(t|T)(m|M)(l|L)',data): #find start of body conents start = re.search('<(b|B)(o|O)(d|D)(y|Y)[^>]*>',data).end() end = re.search('</(b|B)(o|O)(d|D)(y|Y)',data).start() return {'data': data[start:end], 'Content-Type': contents} else: return {'data': data, 'Content-Type': contents} factory_type_information={ 'allowed_content_types':allowed_content_types, 'allow_discussion': 0, 'content_icon':'pub_icon.gif', 'immediate_view':'base_view', 'global_allow':1, 'filter_content_types':1, } actions = ({ 'id': 'view', 'name': 'View', 'action': 'string:${object_url}/publications_view_py', 'permissions': (permissions.View,) },) aliases = { '(Default)' : 'publications_view_py', 'view' : 'publications_view_py', } registerType(PublicationsHTML) //////////////////////////////////////////////////////////////////////////////////////////////////// publications_view_py.py: import string from string import join request = context.REQUEST url = context.link basepath = join(url.split('/')[0:-1],'/') exturl = url obj = context.extractBody(exturl,request) return context.publications_view(contents=(obj['data']), extpath=url+'/') /////////////////////////////////////////////////////////////////////////////////////////////////// publications_view.pt: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" metal:use-macro="here/main_template/macros/master"> <head metal:use-macro="here/header/macros/html_header"> <metal:block metal:fill-slot="base"> <base href="" tal:attributes="href string:${options/extpath}" /> </metal:block> </head> <body> <div metal:fill-slot="main"> <div style="margin-top: 0.5em"> <div metal:use-macro="here/document_actions/macros/document_actions"> Document actions (print, sendto etc) </div> <div tal:replace="structure options/contents"> replaced site contents </div> </div> </div> </body> </html> -- View this message in context: http://www.nabble.com/Error-when-making-a-custom-Archetype-product-available-as-a-default-view-using-Plone-3.0.1-tf4607783s20094.html#a13157632 Sent from the Product Developers mailing list archive at Nabble.com. _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
