[Zope-Perl] Perl Internal Methods -- accessing PARENTS?

Joseph Wayne Norton norton@alum.mit.edu
Wed, 9 Aug 2000 02:25:38 +0900 (JST)


Gisle -

Using the Perl Internal Method, I'm trying to access the "PARENTS"
object and to allow me access to the properties of parent folders. I'm
having trouble with the GetItem method and not sure how to access the
properties of the parent objects.


Here is what I have done so far:

1. I made the following modification to methodTry.dtml to define all
Zope-defined Web request variables.

# diff methodTry.dtml methodTry.dtml.orig  
22c22 
<         <dtml-if "_['sequence-item'] in ('self', 'REQUEST', 'RESPONSE', 'AUTHENTICATED_USER', 'AUTHENTICATION_PATH', 'PARENTS', 'URL')"> 
--- 
>         <dtml-if "_['sequence-item'] in ('self', 'REQUEST', 'RESPONSE')"> 
[root@atum2 PerlMethod]#  



2. I created the following internal perl method:

Name: foo
Arguments: REQUEST, PARENTS
Code:

my $req = shift;
my $par = shift;
my $ret;

foreach ($req->keys) {
 $ret .= "<p>" . $_ . "</p><br>\n";
}

for (my $i = 0; $i < $par->Length; $i++) {
 $ret .= "<p>" . $par->GetItem(0 + $i) . "</p><br>\n";
}
 
$ret;
 

3. I'm facing the following difficulties

  a. I can't seem to use the GetItem interface when passing either
    ($i) or (0 + $i). The following error is given:

 # The following does not work.
 # Error Type: TypeError
 # Error Value: sequence index must be integer

  b. I hard-coded the GetItem to return item #1($par->GetItem(1)) but
  once I have a handle on the parent, I am not sure how to access the
  properties, etc. of the parent objects.

Do you have any pointers?

thanks,

- joe n.


--
Joseph Norton

norton@alum.mit.edu
+81-3-3822-6936
2-10-7 Tabata, Kita-ku, Tokyo 114-0014, Japan ($B")(B114-0014  $BEl5~ETKL6hEDC<#2CzL\(B10-7)