[Zope3-dev] base tags and structured text rendering
Craig Ewington
ewington at adelphia.net
Tue Nov 16 14:58:43 EST 2004
On Nov 16, 2004, at 11:37 AM, Jim Fulton wrote:
> Craig Ewington wrote:
>> I have a document
>
> What do you mean by a document?
Sorry - loose terminology on my part. I have created a new content
component with the following interface and configuration directives:
a) Interface:
class IContentPage(Interface):
"""A page of content that can be written in either structured text
or html."""
header = TextLine(...)
ctent = Text(...)
b) Configuration:
<content class=".contentpage.ContentPage">
<implements
interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
<factory id="excoursia.contentpage.ContentPage" description="Content
Page" />
<require permission="zope.View" interface=".interfaces.IContentPage"
/>
<require permission="zope.ManageContent"
set_schema=".interfaces.IContentPage" />
</content>
>
> > 'index.html' that contains a single line of structured
>> text:
>> "a":a.html
>> to render the structured text, I have a page template that causes the
>> following lines of code to be invoked:
>
> Is this a content-space page template? One added to a folder?
I guess it's a content-space component which I had added to the content
space root (the folder referred to as 'top' in the breadcrumb trail).
>
>> source = zapi.createObject(None, u'zope.source.stx', text)
>> view = zapi.getView(removeAllProxies(source), '', self.request)
>> return view.render()
>> When rendered, the following html is produced:
>> <a href="a.html">
>> The browser interprets this as
>> http://localhost:9080/index.html/a.html instead of
>> http://localhost:a.html. This seems to be related to the absence of a
>> <base...> tag in the generated document. Should I
>> a) Insert a base tag in my skin's template file e.g. <base
>> tal:attributes="href context/@@absolute_url />
>> b) Patch the structured text classes to take a base url and generate
>> absolute references instead of relative ones
>> c) Something else..?
>
> I suspect that this is due to a bug in content-space
> page templates. Most objects want to be the base for their
> views. Content objects that are themselves "documents"
> want to treat themselves as their base.
>
> The fix is pretty simple, although not as simple as it
> should be. There's a marker interface that should be
> declared for objects like this that given them browser-
> traversal adapters that give them correct interpretation
> of URLs ending in / and bases. Unfortunately, this interface
> is in the wrong place. :( (This happened when some files
> were rearranged a long tme ago.)
>
> ZPT pages need to provide an interface named IFileContent.
> Also, this interface needs to be moved to a different place.
I added the IFileContent marker interface by changing my configuration
file to read as follows:
<content class=".contentpage.ContentPage">
<implements
interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
<implements interface="zope.app.file.interfaces.IFileContent" />
<factory id="excoursia.contentpage.ContentPage" description="Content
Page" />
<require permission="zope.View" interface=".interfaces.IContentPage"
/>
<require permission="zope.ManageContent"
set_schema=".interfaces.IContentPage" />
</content>
Interestingly this does not seem to change the behavior I originally
described, but I'm happy to report that Tonico Strasser's observation
about trailing slashes on URLs seems to be my problem (thanks Tonico!).
When I view one of these new content space objects using a URL with a
trailing slash, then indeed the rendered html is incorrect, but it's
okay when I omit the slash i.e:
bad: http://localhost:9080/index.html/
good: http://localhost:9080/index.html
From this I conclude I should omit the IFileContent marker interface
and avoid the trailing slash.
- Craig.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 10651 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20041116/93d0ef1b/attachment.bin
More information about the Zope3-dev
mailing list