Re: [Zope] Acquisition, Not! How?

2000-08-24 Thread Jeff Hoffman

On Thu, 24 Aug 2000, Júlio Dinis Silva wrote:

 I know this sound strange but is there a way to,
 during execution of a dtml method, when a with tag is used one
 force acquisition not to be used?
 
 example:
 
 /root/a/b/c
 /root/c
 
 say dtml-with "root.a.c" was a mistake so I dont want the root.c namespace 
 to be imported due to acquisition and instead I want to raise an exception.
 
 How can I "turn off" acquisition?
 
 I love acquisition, I know its great but I dont want it in a specific case. 
 Is there a way to turn off?

Try:

  dtml-with aq_explicit
dtml-var "root.a.c"
  /dtml-with

--Jeff

---
Jeff K. Hoffman   704.849.0731 x108
Chief Technology Officer  mailto:[EMAIL PROTECTED]
Going Virtual, L.L.C. http://www.goingv.com/


___
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] Acquisition, Not! How?

2000-08-24 Thread Júlio Dinis Silva

  I know this sound strange but is there a way to,
  during execution of a dtml method, when a with tag is used one
  force acquisition not to be used?
 
  example:
 
  /root/a/b/c
  /root/c
 
  say dtml-with "root.a.c" was a mistake so I dont want the root.c 
namespace
  to be imported due to acquisition and instead I want to raise an 
exception.
 
  How can I "turn off" acquisition?
 
  I love acquisition, I know its great but I dont want it in a specific 
case.
  Is there a way to turn off?

Try:

   dtml-with aq_explicit
 dtml-var "root.a.c"
   /dtml-with


This result in a system error (infinite loop) :-(
I'll follow this aq_explicit tip.

Thanx anyway,
Júlio Dinis Silva




Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


___
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] Acquisition, Not! How?

2000-08-24 Thread Dieter Maurer

=?ISO-8859-1?Q?J=FAlio?= Dinis Silva writes:
  I know this sound strange but is there a way to,
  during execution of a dtml method, when a with tag is used one
  force acquisition not to be used?
It is possible -- with an external method.

But probably, you should not do it. It may have strange
side effects. Zope uses acquisition for access validation.
If you cut the acquisition chain, Zope may no longer find
the acl_user necessary to determine the identity of the
current user and its roles. You may get unexplanable
Unauthorized exceptions.

Okay, you may try it yourself:

  the external method:

def getBase(obj): return getattr(obj,'aq_base',obj)
   
  it returns "obj" with all acquisition context removed.


As indicated above, I would not use it, but instead use
a test function:

def hasattr_base(obj,attribute):
  base= getBase(obj)
  return hasattr(base,attribute)

I would use this to test in DTML whether a object "O" has
itself at attribute "a" which is not acquired and
raise an exception, if not.



Dieter

___
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 )