Re: [Zope] Newbie question(s)

2000-11-13 Thread Rik Hoekstra



"Bowyer, Alex" wrote:
 
 Hi,
 
 I have what I'm sure is a very simple question about Zope programming style:
 I want to count how many objects are contained in the current container
 object and then do something with that value, but I can't do the bit I need
 to do at the point of reading the count variable because I am in the wrong
 namespace.
 I can't begin a dtml-let because I would need to close dtml-if before
 dtml-let, which is not allowed.
 
 dtml-in objectValues
 dtml-if sequence-end
 dtml-var count-id  !-- this is the value I want to use --
 /dtml-if
 /dtml-in
 !-- this is the scope in which I want to do something with the value. --
 

try (untested):

dtml-call expr="REQUEST.set('countids', _.len(objectValues())"
dtml-in objectValues
dtml-if sequence-end
dtml-var countids
/dtml-if
/dtml-in
!-- do something with the value. --



 What is the "accepted" way of passing a value into a different scope? Do I
 have do a REQUEST.set or is there a tidier way?

dtml-let

 Also I think I read somewhere that you can use the object.subobject or
 object.property syntax but I never got that to work, what's the catch?

dtml-var expr="object.subobject"

note that this is a Python expression and the code between quotes has
Python behaviour.
 

 
 One last thing, I sent a couple of mails to the list about problems I had
 with manage_delObjects. I still haven't got it to work. Since the best way
 to learn Zope is by example, I wonder if anyone could direct me to a sample
 piece of code where a container of some sort deletes one of its children
 subobjects?
 


try (untested):
dtml-call "subobject.manage_delObjects([id1, id2, ..])"


hth

Rik

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] Newbie question(s)

2000-11-12 Thread Bowyer, Alex

Hi,

I have what I'm sure is a very simple question about Zope programming style:
I want to count how many objects are contained in the current container
object and then do something with that value, but I can't do the bit I need
to do at the point of reading the count variable because I am in the wrong
namespace.
I can't begin a dtml-let because I would need to close dtml-if before
dtml-let, which is not allowed.

dtml-in objectValues
dtml-if sequence-end
dtml-var count-id  !-- this is the value I want to use --
/dtml-if
/dtml-in
!-- this is the scope in which I want to do something with the value. --

What is the "accepted" way of passing a value into a different scope? Do I
have do a REQUEST.set or is there a tidier way?
Also I think I read somewhere that you can use the object.subobject or
object.property syntax but I never got that to work, what's the catch?

One last thing, I sent a couple of mails to the list about problems I had
with manage_delObjects. I still haven't got it to work. Since the best way
to learn Zope is by example, I wonder if anyone could direct me to a sample
piece of code where a container of some sort deletes one of its children
subobjects?

Thanks very much for your help,

Alex

==
Alex Bowyer
IT Contractor, Logica Australasia
Tel: +61 2 9202 8130
Fax: +61 2 9922 7466
E-mail : [EMAIL PROTECTED]
WWW: http://www.logica.com.au/
==

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




RE: [Zope] Newbie question(s)

2000-11-12 Thread Max M

From: Bowyer, Alex

I want to count how many objects are contained in the current container
object and then do something with that value, but I can't do the bit I 
need to do at the point of reading the count variable because I am in 
the wrong namespace.

I would try and do it like this (untested):

dtml-call "REQUEST.set('itemCount', len(objectIds()))"

Regards

Max M

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




RE: [Zope] Newbie question(s)

2000-11-12 Thread Bowyer, Alex

 I want to count how many objects are contained in the 
 current container
 object and then do something with that value, but I can't do 
 the bit I 
 need to do at the point of reading the count variable 
 because I am in 
 the wrong namespace.
 
 I would try and do it like this (untested):
 
 dtml-call "REQUEST.set('itemCount', len(objectIds()))"
 
 Regards
 
 Max M

Thanks Max, that is certainly useful in this case.

My query is really more general though, that was just an example, I need to
know what the generally accepted method is for transferring values through
the code (i.e between namespaces)

IMHO as far as Zope documentation goes, the thing that is really lacking is
a document introducing people to how to program in Zope, explaining the
overlaps between Python and Zope/DTML and explaining the different syntaxes
for calling variables, methods etc? There are a lot of references on
specific functions, methods etc but no general overview. Maybe the
forthcoming Zope book will address this better.

I am also still looking for example code using manage_delObjects.

Thanks,

Alex

==
Alex Bowyer
IT Contractor, Logica Australasia
Tel: +61 2 9202 8130
Fax: +61 2 9922 7466
E-mail : [EMAIL PROTECTED]
WWW: http://www.logica.com.au/
==

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Newbie question(s)

2000-11-12 Thread Morten W. Petersen

[Alex Bowyer]

| My query is really more general though, that was just an example, I need to
| know what the generally accepted method is for transferring values through
| the code (i.e between namespaces)

Unless I've misunderstood your problem, wouldn't dtml-let do the trick?
(See DTML manual for more info).

-Morten

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




RE: [Zope] Newbie question(s)

2000-11-12 Thread Max M

From: Bowyer, Alex

My query is really more general though, that was just an example,
I need to know what the generally accepted method is for
transferring values through the code (i.e between namespaces)

I do believe that our ugly friend REQUEST.set() is the way to go here. I
cannot remember having seen any other way of doing it. I expect that better
days will be here with v.2.3 as we will get Python Methods, or whatever they
are called.

I am also still looking for example code using manage_delObjects.

Sorry I cannot help there.

Regards
Max M


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )