[Zope] <dtml-tree> from multiple SQL tables

Will Stephenson lists at stevello.free-online.co.uk
Sun Nov 23 04:55:20 EST 2003


On Thursday 20 November 2003 18:37, Dieter Maurer wrote:
> Will Stephenson wrote at 2003-11-19 17:28 +0000:
>  > ...
>  > However anthony's page mentions a missing 'tpId' attribute, but stops
>  > before explaining how to set this, or to spoof it.  My tree expands very
>  > strangely - expanded branches always contain the top level Categories
>  > recursively, not the subcategories.
>
> Look at the "id" attribute of "dtml-tree".
> More generally, read the "dtml-tree" documentation.

I had set id=objectid, but my level 2 query didn't return a field called 
'objectid', 

<p>Category tree view (not working)
<p>
<dtml-let objectid="0">
<dtml-tree id=objectid branches_expr="makeTree(parentId=objectid)">
 <b><dtml-var name></b>
</dtml-tree>
</dtml-let>

I was confused and called it 'tpId'.  So now I have a tree which appears to 
obtain level 2 branches correctly, because it only shows + expander signs 
next to the level 1 branches that have children.  But when I try to expand 
these branches, I get a "Error Type: TypeError
Error Value: object of type 'long int' is not callable" error.  I'm running in 
debug mode but there isn't a backtrace in the error page as rendered or its 
source.  

I can see I'm passing an int to a method that requires a callable object, but 
I can't find out what the parameter name my queries' output is getting wrong 
is, or what the correct type for it is.

How can I get a slightly more informative error?

TIA 

Will

makeTree:
if int(parentId) == 0:
    return container.treeCats()
elif int(parentId) > 0:
    return container.treeSubCats(category=int(parentId))

treeCats:
select id as objectid, 0 as parent, concat('/viewCategory?category=', id) as 
tpURL, name from category

treeSubCats:
SELECT id + 1000 * <dtml-sqlvar category type=int> as objectid, name, 
<dtml-sqlvar category type=int> as parent, 'foo' as tpURL
FROM subcategory
WHERE
<dtml-sqltest category type=int>

-- 
Will Stephenson
IRC: Bille



More information about the Zope mailing list