[Zope] Namespaces? DTML Methods? Properties? Oh my.

Gary Perez garyp@asti-usa.com
Fri, 19 May 2000 14:41:54 -0400


Hello all.

First, a warning: I'm probably the newest of all Zope newbies. I'll do
my best to formulate some semblance of an intelligent question.

I'm having a namespace meltdown. Here's what's going on...

I have a ZClass called "Company" which has attribute "id", and a ZClass
called "Project" which has attribute "CompanyID" among others.

I'm trying to call and render only those Projects that have a CompanyID
that matches the Company object's "id" attribute. I'm doing this in the
"index_html" of the Company ZClass by calling a DTML Method
"retrieveCompanyProjects"... which resides in the folder "Company_List".
Here's the pertinent tree structure:

/
	Company_List/
		Company1/
		Company2/
		retrieveCompanyProjects (DTML Method)

	Control Panel/
		Products/
			ASTi/
				Company (ZClass)
					index_html
				Project (ZClass)

	Projects/
		Project1/
		Project2/

Now... the procedure is successful when rendering only those Projects
that match a specific FSSession userid, as such:

## DTML Method 1 Excerpt:

<dtml-in "Projects.retrieveUsersProjects(_.None, _)">

## "retrieveUsersProjects" DTML Method Excerpt:

<dtml-call "REQUEST.set('list', [])">

<dtml-in "Projects.objectItems(['Project'])">
<dtml-with sequence-item>

<dtml-if "Engineer == FSSession['userid']">

	<dtml-let x=sequence-key>
	<dtml-call "list.append(absolute_url())">
	</dtml-let>
	succeed <dtml-var ApplicationEngineer>, <dtml-var "this()">
<dtml-else>
	fail <dtml-var ApplicationEngineer>
</dtml-if>
</dtml-with>
</dtml-in>

##

I've tried to use the same mechanism in the "retrieveCompanyProjects"
DTML Method, and here's where the namespace meltdown turns my brain to mush.

Here's the "retrieveCompanyProjects" DTML Method, which (to reiterate)
is called from the "index_html" method inside the Company ZClass:

##
<dtml-call "REQUEST.set('list', [])">

<dtml-in "Projects.objectItems(['Project'])">
<dtml-with sequence-item>

<dtml-if "CompanyID == COMPANY_ATTRIBUTE_NAMED_ID">

	<dtml-let x=sequence-key>
	<dtml-call "list.append(absolute_url())">
	</dtml-let>
	succeed <dtml-var CompanyID>, <dtml-var "this()">
<dtml-else>
	fail <dtml-var CompanyID>
</dtml-if>
</dtml-with>
</dtml-in>

<dtml-return "REQUEST['list']">
##

My problem is that I can't for the life of me figure out what to replace
the "COMPANY_ATTRIBUTE_NAMED_ID" with in order to make it work.
User-specific is easy... it's simply FSSession['userid'].

Due to the position of the <dtml-if> following the <dtml-in>, however,
I'm in the namespace of Projects, right? That being considered, the
property "id" is at that point the "id" of the Project, and not of the
Company anymore, no?

How can I go out, and snag a Company's property "id" from within that
namespace? Can I do a <dtml-with> ??? </dtml-with> to pop the Company
namespace on the top of the stack & kick it out after getting the "id"?

Or, alternatively, is there a way that I can pass the variable "id" from
the Company namespace into the DTML method so it's there, recognized,
and used to filter the Projects?

Sorry this was so long, but any help would be greatly appreciated. I'm confused.

Thanks,
-Gary
-- 
Gary Perez
Advanced Simulation Technology, inc.
http://www.asti-usa.com/