emily | 9 Jun 2004 03:23
Picon

BayPIG meeting (and Emily intro).

Hello!

I added this to the news part of the page, but there is a Bay Area 
Python Users Group meeting Thurs, 6/10.  More details on their site at 
http://baypiggies.net/
It might be hard to go, cause it is at Stanford, but if anyone is 
interested, please let me know, cause maybe I'll try to go with you.

By the way, for those of you know don't know me, I am Emily, and I use 
zope. :P ("Hiiii Emily!").  All of the language sites for UC Davis are 
run on it. (You can look at philo.ucdavis.edu if you want; I think 
spanish and religious studies are the prettiest).  Our real zope hacker 
abandoned us for a new job (but I guess thats good for me, since I got 
this one ;) ) .  Anyways, I mostly have used the Wiki and Epoz and DB 
adapter products (man that Oracle one :P) and Formulator is kinda cool 
too. La la la, I guess I can go on and on because nobody else really 
says anything so maybe there aren't really even any people on this list!

-- Emily

emily | 20 Jun 2004 08:46
Picon

Error Value: global name ... is not defined

Evenin,

I am having some dtml-grokking issues, and I was wondering if anyone 
would be knowledgeable and kind enough to help me. 

I have:

1) An sql method, Query,  which takes one variable, "id",  and does a 
lookup for me.
2) A dtml method, Display,  which calls Query and then displays what its 
returned from the DB.
Display also takes one variable, "id", which it passes to Query.
3) A dtml method, Test,  which calls Display with the line<dtml-call 
"Display(id=3)">.

If I test Query on its own with a value of 3 for "id", it works.
If I have Display explicitely pass 3 into Query, it works
If I run Test, I get this error:

Error Value: global name "Query" is not defined.
So Test is obviously getting into Display, but once its there, it can't 
find Query all of a sudden..

Please let me know if you need any more information or if you have any 
ideas about where I am going wrong here.

Thanks!

-- Emily

(Continue reading)

Steve McMahon | 20 Jun 2004 17:46
Gravatar

Re: Error Value: global name ... is not defined

Hi Emily,

Your DTML call:

<dtml-call "Display(id=3)">

is passing the explicit parameter (id=3), but not the name space, which 
you might think of as the context of operation. Since there's no context 
available inside the called method, it can't find "Query".

If you call a DTML method without the quotes, e.g. <dtml-call Display>, 
the context is automatically passed. But the moment you use quotes 
you'll cause zope to interpret your expression as Python, and you need 
to supply all the parameters, including the name space (i.e., context). 
The canonical way to do this is:

<dtml-var "aDTMLMethod(_.None, _)">

In your case, it might be:

<dtml-call "Display(_.None, _, id=3)">

"_" is the DTML name space variable.

Also, note that using "dtml-call" rather than "dtml-var", will result in 
whatever's returned from Display being thrown away. If that's 
intentional, you might want to rewrite Display as a python script. If 
not, use dtml-var instead.

Steve
(Continue reading)

emily | 23 Jun 2004 03:41
Picon

Re: Error Value: global name ... is not defined

Thank you Steve, using <dtml-call "Display(_.None, _, id=3)"> worked 
perfectly :)

You said that _ is the DTML name space variable.  Do you think you could 
explain about the two parameters _.None, and _ a little bit more?  Would 
you say a DTML function with these two weird looking parameters passed 
in is the best way to return an html-formatted version of a database entry?

-- Emily

Steve McMahon wrote:

> Hi Emily,
> 
> Your DTML call:
> 
> <dtml-call "Display(id=3)">
> 
> is passing the explicit parameter (id=3), but not the name space, which 
> you might think of as the context of operation. Since there's no context 
> available inside the called method, it can't find "Query".
> 
> If you call a DTML method without the quotes, e.g. <dtml-call Display>, 
> the context is automatically passed. But the moment you use quotes 
> you'll cause zope to interpret your expression as Python, and you need 
> to supply all the parameters, including the name space (i.e., context). 
> The canonical way to do this is:
> 
> <dtml-var "aDTMLMethod(_.None, _)">
> 
(Continue reading)

David Siedband | 23 Jun 2004 07:56
Gravatar

Plone base properties for table dimensions

I wanted to remove the right column from the default Plone2 layout.

while it seems workable to do the following in 
portal_skins/ploneColumns.css

  #portal-column-two {
display:none;
  }

I'm wondering if there's an advantage to setting columnTwoWidth to '0' 
in portal_skins/base_properties instead.

thoughts on this?

thx
--
David

steve | 23 Jun 2004 20:21
Favicon

Re: Error Value: global name ... is not defined

I'm out of town, and don't have the source or other docs available, but I'll do
my best.

When Zope itself calls a DTML method (say as a result of a request to render a
page), it builds the name space that gives access to all the global variables
(like REQUEST) and passes it as a parameter in a normal python method call. I've
forgotten what the first parameter is, but it's something that's not meaningful
when we call a DTML method from inside another method; so, None (Python for
nothing) is used instead. _.None is finding 'None' in the _ namespace. I think
None is always available these days, so that you may use a bare 'None'.

Is this the best way to do it? A common alternative is to put your variable in
the REQUEST pseudo dictionary and make a simple call:

<dtml-call "REQUEST.set('myid', 3)">
<dtml-var Display>

Note the lack of quotes around 'Display'; this will cause Zope to set up the
name space itself. Then, your Display method can look up 'myid' in REQUEST.

By the way, it's probably a good idea to stear away from using 'id' for your own
purposes, as you'll override the id property of the current method. Probably not
what you want. For the same reason, you'll want to avoid using 'title' for your
own variable.

You're experiencing some pain with this now, but it's well worth learning how to
call methods from within methods. It will help you structure and re-use code.

Steve

(Continue reading)

steve | 23 Jun 2004 20:31
Favicon

Re: Plone base properties for table dimensions

This may not be the solution you're after, but if you remove all the portlets
from the right column, it will disappear automatically.

Quoting David Siedband <technique@...>:

> I wanted to remove the right column from the default Plone2 layout.
> 
> while it seems workable to do the following in 
> portal_skins/ploneColumns.css
> 
>   #portal-column-two {
> display:none;
>   }
> 
> I'm wondering if there's an advantage to setting columnTwoWidth to '0' 
> in portal_skins/base_properties instead.
> 
> thoughts on this?
> 
> thx
> --
> David
> 
> 
> _______________________________________________
> ZUGOD-Discuss mailing list
> ZUGOD-Discuss@...
> http://www2.dcn.org/mailman/listinfo/zugod-discuss
> 
> 
(Continue reading)

emily | 24 Jun 2004 19:19
Picon

Re: Error Value: global name ... is not defined

Thanks!

*Sigh* Why can't I just say myfun(var1, var2) like the good old days...
Also, while we're talking about REQUEST, and global variables, is there 
a quick way to dump out all of the global variables and their values so 
that I can see whats there?  I guess the <dtml-call "REQUEST.set..."> 
one is nice, but I guess I still don't see why thats better then just 
being able to say "myid=3".

Anyways, back to work again.  I hope some day I can answer something for 
you!

-- Emily

steve@... wrote:

> I'm out of town, and don't have the source or other docs available, but I'll do
> my best.
> 
> When Zope itself calls a DTML method (say as a result of a request to render a
> page), it builds the name space that gives access to all the global variables
> (like REQUEST) and passes it as a parameter in a normal python method call. I've
> forgotten what the first parameter is, but it's something that's not meaningful
> when we call a DTML method from inside another method; so, None (Python for
> nothing) is used instead. _.None is finding 'None' in the _ namespace. I think
> None is always available these days, so that you may use a bare 'None'.
> 
> Is this the best way to do it? A common alternative is to put your variable in
> the REQUEST pseudo dictionary and make a simple call:
> 
(Continue reading)


Gmane