I recently asked how to call a ZSQL method in a folder higher up the hierarchy. I can do it if I manually get the parent. This can't be right can it? ### parent = context.REQUEST.PARENTS[0] results = parent.test_sql() t = '' for n in results: t = t + n.project_name + '\n' return t ### Surely, there's a way to do it using acquisition so that it would recursively look higher up the folder structure to find the ZSQL method? Thanks Tom -- tom smith | tom@othermedia.com | http://www.othermedia.com/blog 0207 089 5959 | Floor 3, The Pavilion, Newhams Lane, London SE1 3UZ
+-------[ tom smith ]---------------------- | I recently asked how to call a ZSQL method in a folder higher up the | hierarchy. I can do it if I manually get the parent. This can't be right | can it? Nope, although, the reason it works with your parent is that your parent has an acquisition wrapper. What you want to do is get your own wrapper to play with... | Surely, there's a way to do it using acquisition so that it would | recursively look higher up the folder structure to find the ZSQL method? Yes there is... self = context.this() results=self.test_sql() t = '' for n in results: t = t + n.project_name + '\n' return t -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew,
Yes there is...
self = context.this()
Thank you, thank you, , thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you. This will let me stop keeping all my code objects in the same folder, very messy! Do you know of any documentation about context.this() anywhere? Lord knows, I've looked but missed that one... Also, do you know a way to splat "context" object to screen in a way that would let me browse the attributes and functions. If I could do that I'd be able (pretty much) to work out what or how to call the various objects zope uses. Thanks again tom -- tom smith | tom@othermedia.com | http://www.othermedia.com/blog 0207 089 5959 | Floor 3, The Pavilion, Newhams Lane, London SE1 3UZ
+-------[ tom smith ]---------------------- | Andrew, | | > Yes there is... | > | > self = context.this() | | | Thank you, thank you, , thank you, thank you, thank you, thank you, thank | you, thank you, thank you, thank you, thank you, thank you, thank you, thank | you, thank you. This will let me stop keeping all my code objects in the | same folder, very messy! hehe. | | Do you know of any documentation about context.this() anywhere? Lord knows, | I've looked but missed that one... context is a MultiMapping (Zope Name), (or an object that contains some number of them), which is basically a stack of dictionaries containing your namespace. As you pass through each object between / and you more information is pushed on the namespace stack. Most (Zope) objects contain a this() method that returns self, so this() is simply your container (I'm sure it's not you, but, I might be mistaken here, it makes little difference), which has a full acquisition wrapper. -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
I don't understand. What is the difference between context.this(), context, and container ?? For going a folder up, I use container.aq_parent (has say in the developpers guide). But it should work only with acquisition wrappers, what made me suppose that all the folders have an acquisition wrapper ??? I think this funcion should exist in the folder API, and it "surprises" (still a newbie) to not find it in "ObjectManagerItem" Class. In fact, I ask myself if getPhysicalRoot() is not for this purpose (but reading the documentation it seems to refer to THE 'root' folder ???) On Mon, 1 Oct 2001, Andrew Kenneth Milton wrote:
+-------[ tom smith ]---------------------- | Andrew, | | > Yes there is... | > | > self = context.this() | | | Thank you, thank you, , thank you, thank you, thank you, thank you, thank | you, thank you, thank you, thank you, thank you, thank you, thank you, thank | you, thank you. This will let me stop keeping all my code objects in the | same folder, very messy!
hehe.
| | Do you know of any documentation about context.this() anywhere? Lord knows, | I've looked but missed that one...
context is a MultiMapping (Zope Name), (or an object that contains some number of them), which is basically a stack of dictionaries containing your namespace. As you pass through each object between / and you more information is pushed on the namespace stack.
Most (Zope) objects contain a this() method that returns self, so this() is simply your container (I'm sure it's not you, but, I might be mistaken here, it makes little difference), which has a full acquisition wrapper.
-- __o _ \<_ (_)/(_) Saludos de Julián EA4ACL -.-
+-------[ Julián Muñoz Domínguez ]---------------------- | I don't understand. | What is the difference between context.this(), context, and container ?? context is a stack of all namespaces. If there is a container variable, that is almost certainly the same as context.this(). I haven't done a Python Script for a looooong time. However, if there's a bound object called container, I don't understand why it wasn't plainly obvious how to get to it. Sounded like all there was to work with was context. -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
participants (3)
-
Andrew Kenneth Milton -
Julián Muñoz Domínguez -
tom smith