[Zope] ZDiscussions Problem under Zope 2.6.2b3
Dennis Allison
allison@sumeru.stanford.EDU
Fri, 18 Jul 2003 12:51:18 -0700 (PDT)
Dieter,
I've moved on to the new TAL/Python version of ZUBB which looks like it
will do just fine. We need to make some mods to give the functionality we
had in the ZDiscussions product, but it looks like it's not overmuch work.
The problem we encountered is with the old product. The diagnostic came
from the access to _[id].threadMessageCount() near the end of the code
snippet below. This portion of the code is pure vanilla, exactly as
distributed as ZDiscussions and has been working for ages. Zope 2.6.2b3
appears to break it. Is this a bug? or a feature? Presumably Zope 2.5.1
was able to do a getObject() as needed.
Anyhow, the immediate problem has been resolved by moving to a new version
of the same product (if rebuilding from the ground floor counts as a
revision).. But there remains the question as to why one Zope runs the
code and a later one does not.
[snip]
<dtml-var standard_html_header>
<dtml-call expr="debugWindow(id)">
<dtml-unless batch_size>
<dtml-call "REQUEST.set('batch_size',20)">
</dtml-unless>
<dtml-in "searchResults(in_reply_to=[''])" size=batch_size reverse sort=id
start=query_start>
<dtml-if sequence-start>
<dtml-if "AUTHENTICATED_USER.has_permission('Delete objects', '')">
<form action="" method="get">
</dtml-if>
<!-- main table -->
<table class="content">
<tr> <td> </td>
<td align="left" valign="middle" class="tablehead">Subject</td>
<td valign="middle" class="tablehead">Author</td>
<td valign="middle" class="tablehead">Posts</td>
<td valign="middle" class="tablehead">Posted</td>
<td valign="middle" class="tablehead">Last Post</td>
</tr>
</dtml-if>
<tr class="<dtml-if
sequence-even>zubbrownormal<dtml-else>zubbrowhilite</dtml-if>">
<td align="center" valign="middle">
<dtml-if "AUTHENTICATED_USER.has_permission('Delete objects', '')">
<input type="checkbox" name="ids" value="<dtml-var id>" />
<dtml-else>
<a href="<dtml-var id>"><img src="<dtml-var
absolute_url>/icon_folder" width="14" height="12" border="0"></a>
</dtml-if>
</td>
<td class="tabledata" align="left" valign="middle"><a class="tablehead"
href="<dtml-var id>"><dtml-if "title==''">(no subject)<dtml-else><dtml-var
title html_quote size="30" missing="subject"></dtml-if></a></td>
<td class="tabledata"><dtml-if
"author==''">Anonymous<dtml-else><dtml-var author html_quote size="30"
missing="Anonymous"></dtml-if></td>
<td class="tabledata" valign="middle"><dtml-var
"_[id].threadMessageCount()"></td>
<td class="tabledata" valign="middle"><dtml-var created
fmt="%m/%d/%y"></td>
<td class="tabledata" valign="middle"><dtml-var
"_[id].threadNewestMessageDate()" fmt="%m/%d/%y"></td>
</tr>
<dtml-if sequence-end>
[snip]
On Fri, 18 Jul 2003, Dieter Maurer wrote:
> Dennis Allison wrote at 2003-7-18 08:08 -0700:
> > ....
> > Error Type: AttributeError
> > Error Value: LazyMap instance has no attribute 'threadMessageCount'
> >
> > Traceback (innermost last):
> > Module ZPublisher.Publish, line 98, in publish
> > Module ZPublisher.mapply, line 88, in mapply
> > Module ZPublisher.Publish, line 39, in call_object
> > Module OFS.DTMLMethod, line 126, in __call__
> > Module DocumentTemplate.DT_String, line 474, in __call__
> > Module DocumentTemplate.DT_In, line 604, in renderwb
> > Module DocumentTemplate.DT_Util, line 201, in eval
> > - __traceback_info__: id
> > Module <string>, line 2, in f
> > Module AccessControl.DTML, line 29, in guarded_getattr
> > Module AccessControl.ZopeGuards, line 47, in guarded_getattr
> > AttributeError: LazyMap instance has no attribute 'threadMessageCount'
>
> It seems that your DTMLMethod performs a catalog query (this
> returns a "LazyMap" instance) and tries to access
> the "threadMessageCount" attribute on it.
>
> Of course, this will not work.
> Almost surely, you need to access a single hit (this is a BrainObject),
> then call its method "getObject" (to get the true object) and
> only then access "threadMessageCount".
>
>
> Dieter
>