Re: [Zope] Acquisition / proxying object

2008-02-27 Thread Dieter Maurer
Joerg Baach wrote at 2008-2-25 19:45 +:
 ...
I am trying to have a folderish object that acquires from a user object
(ldapuserfolder). It should have its own properties and contents, but
fall back to the ones of the ldap user.

I have created an object, extending Folder, and it behaves nicely in
zopectl debug. When I try to access it through e.g. a python script  I
get an:

Error Type: Unauthorized
Error Value: Unable to find __roles__ in the container and the container
is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
/testfolder/ldapproxy), denied.

When you access attribute x (with value xv) on object o,
Zope will first check whether xv has security declarations (more
precisely, a __roles__ attribute). If it has, they are used.
Otherwise, Zope checks for o.x__roles__. If found, they are used.
Otherwise, o.__roles__ may be examined (under some circumstances).

Note that for most security declarations,
o needs to be fully acquisition wrapped.
Otherwise, there may be two problems:

  *  Zope cannot find the information to map permissions to roles
 (as this mapping is defined on the acquisition path leading
 to the root)

  *  o does is not covered by the user folder which
 has identified the current user.

 A user has only special roles on objects covered by
 its user folder.

 A object is covered by a user folder, when the object
 lies in the subtree rooted in the user folder's container.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-27 Thread Dieter Maurer
Joerg Baach wrote at 2008-2-25 22:03 +:
 ...
Error Type: Unauthorized
Error Value: Your user account is defined outside the context of the
object being accessed.

This is a different spelling for what I called in the last
message object not covered by the user folder identifying the current
user.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-26 Thread Peter Sabaini
On Monday 25 February 2008 23:52:26 Joerg Baach wrote:
 Hi *,

  But somehow I have the feeling it has more to do with the 'and the
  container is not wrapped' part of the message. Not that I can make sense
  of it ;-)

 Mmm, after even more searching, and not understanding I found

 http://www.mail-archive.com/[EMAIL PROTECTED]/msg11438.html

 and changed my code to:


 def __of__(self, parent):
 '''foo'''
 if not hasattr(parent,'aq_base'):
 return self

 folder,id = self.remoteid.split(':')
 acl = parent.unrestrictedTraverse(folder)

You're now doing no security checks on traversal, probably thats why you don't 
get any Unauthorized exceptions :-)

- peter.


 remote = acl.getUser(id)

 return Acquisition.ImplicitAcquisitionWrapper(aq_base(self),

  aq_base(remote).__of__(parent))

 Now, this actually seems to work. If only I knew why


 Cheers,

   Joerg


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


Re: [Zope] Acquisition / proxying object

2008-02-26 Thread Joerg Baach
Hi Peter,

 acl = parent.unrestrictedTraverse(folder)

when changing to

   acl = parent.restrictedTraverse(folder)

I still don't get the Unauthorized exceptions. Anyhow, I will have to do
a bit more wrapping, and then see if the solutions survive the security
testing ;-)

Cheers,

  Joerg



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-26 Thread Peter Bengtsson
This is maybe a naive suggestion but if Zope's TTW execution (e.g. 
Python Scripts) can't find a __roles__ on the object at hand doesn't 
that just mean that the class wasn't initialized with any security.



class LDAPProxy(Folder):
...

from Globals import InitializeClass
InitializeClass(LDAPProxy)

That should set the *__roles__ on all it's methods.


Joerg Baach wrote:

Hi *,

I am trying to have a folderish object that acquires from a user object
(ldapuserfolder). It should have its own properties and contents, but
fall back to the ones of the ldap user.

I have created an object, extending Folder, and it behaves nicely in
zopectl debug. When I try to access it through e.g. a python script  I
get an:

Error Type: Unauthorized
Error Value: Unable to find __roles__ in the container and the container
is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
/testfolder/ldapproxy), denied.

I am sure its my lack of understanding of acquisition. I am trying to
bascially put ldap user object 'on top' of the aquisition line (with the
ldapproxy at the bottom), but obviously failing in doing so. Any ideas?

Cheers,

  Joerg



8 excerpt from code ---

class LDAPProxy(Folder):

meta_type='LDAPProxy'

def __init__(self, id, remoteid,title='',REQUEST=None):
self.id = id
self.title = title
self.remoteid = remoteid

def __of__(self, parent):
if not hasattr(parent,'aq_base'):
return self
folder,id = self.remoteid.split(':')
acl = parent.restrictedTraverse(folder)
remote = acl.getUser(id)
return Folder.__of__(self,parent.__of__(remote))

--- teststructure--

/testfolder/
   ldapproxy (LDAPProxy)
   acl_users/
   testscript (.py)


8 testscript -
return context.ldapproxy.dn

traceback--
Traceback (most recent call last):
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 113, in publish
request, bind=1)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/mapply.py,
line 88, in mapply
if debug is not None: return debug(object,args,context)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 40, in call_object
result=apply(object,args) # Type scr to step into published object.
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 311, in __call__
return self._bindAndExec(args, kw, None)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 348, in _bindAndExec
return self._exec(bound_data, args, kw)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Products/PythonScripts/PythonScript.py,
line 323, in _exec
result = f(*args, **kw)
  File Script (Python), line 1, in testscript
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 727, in guarded_getattr
aq_acquire(inst, name, aq_validate, validate)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 669, in aq_validate
return validate(inst, object, name, v)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 563, in validate
self._context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 293, in validate
accessed, container, name, value, context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 808, in raiseVerbose
raise Unauthorized(text)
Unauthorized: Unable to find __roles__ in the container and the
container is not wrapped.  Access to 'dn' of test, acquired through
(LDAPProxy at /testfolder/ldapproxy), denied.





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce

 http://mail.zope.org/mailman/listinfo/zope-dev )


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Acquisition / proxying object

2008-02-25 Thread Joerg Baach
Hi *,

I am trying to have a folderish object that acquires from a user object
(ldapuserfolder). It should have its own properties and contents, but
fall back to the ones of the ldap user.

I have created an object, extending Folder, and it behaves nicely in
zopectl debug. When I try to access it through e.g. a python script  I
get an:

Error Type: Unauthorized
Error Value: Unable to find __roles__ in the container and the container
is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
/testfolder/ldapproxy), denied.

I am sure its my lack of understanding of acquisition. I am trying to
bascially put ldap user object 'on top' of the aquisition line (with the
ldapproxy at the bottom), but obviously failing in doing so. Any ideas?

Cheers,

  Joerg



8 excerpt from code ---

class LDAPProxy(Folder):

meta_type='LDAPProxy'

def __init__(self, id, remoteid,title='',REQUEST=None):
self.id = id
self.title = title
self.remoteid = remoteid

def __of__(self, parent):
if not hasattr(parent,'aq_base'):
return self
folder,id = self.remoteid.split(':')
acl = parent.restrictedTraverse(folder)
remote = acl.getUser(id)
return Folder.__of__(self,parent.__of__(remote))

--- teststructure--

/testfolder/
   ldapproxy (LDAPProxy)
   acl_users/
   testscript (.py)


8 testscript -
return context.ldapproxy.dn

traceback--
Traceback (most recent call last):
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 113, in publish
request, bind=1)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/mapply.py,
line 88, in mapply
if debug is not None: return debug(object,args,context)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 40, in call_object
result=apply(object,args) # Type scr to step into published object.
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 311, in __call__
return self._bindAndExec(args, kw, None)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 348, in _bindAndExec
return self._exec(bound_data, args, kw)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Products/PythonScripts/PythonScript.py,
line 323, in _exec
result = f(*args, **kw)
  File Script (Python), line 1, in testscript
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 727, in guarded_getattr
aq_acquire(inst, name, aq_validate, validate)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 669, in aq_validate
return validate(inst, object, name, v)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 563, in validate
self._context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 293, in validate
accessed, container, name, value, context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 808, in raiseVerbose
raise Unauthorized(text)
Unauthorized: Unable to find __roles__ in the container and the
container is not wrapped.  Access to 'dn' of test, acquired through
(LDAPProxy at /testfolder/ldapproxy), denied.



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Peter Sabaini
On Monday 25 February 2008 20:45:37 Joerg Baach wrote:
 Hi *,

 I am trying to have a folderish object that acquires from a user object
 (ldapuserfolder). It should have its own properties and contents, but
 fall back to the ones of the ldap user.

 I have created an object, extending Folder, and it behaves nicely in
 zopectl debug. When I try to access it through e.g. a python script  I
 get an:

 Error Type: Unauthorized
 Error Value: Unable to find __roles__ in the container and the container
 is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
 /testfolder/ldapproxy), denied.

 I am sure its my lack of understanding of acquisition. I am trying to
 bascially put ldap user object 'on top' of the aquisition line (with the
 ldapproxy at the bottom), but obviously failing in doing so. Any ideas?

I'm not familiar with LDAPUserFolder (its not really a user object but a user 
container, isn't it?) but the error you're getting is a security error -- the 
Python Script checks for security attributes before it accesses attributes. 
You need to add the appropriate security declarations in your product before 
it can be used inside PyScript

You might try the verbose-security directive in zope.conf to debug stuff like 
that; I hope it is available in the version of Zope you're running (I'm on 
2.10)

As a hack to disable all security checks on a class you can add the attribute 
__allow_access_to_unprotected_subobjects__ = 1 , effectively disabling 
security. This of course should only be done if you trust your users!

hth
peter.



 Cheers,

   Joerg



 8 excerpt from code ---

 class LDAPProxy(Folder):

 meta_type='LDAPProxy'

 def __init__(self, id, remoteid,title='',REQUEST=None):
 self.id = id
 self.title = title
 self.remoteid = remoteid

 def __of__(self, parent):
 if not hasattr(parent,'aq_base'):
 return self
 folder,id = self.remoteid.split(':')
 acl = parent.restrictedTraverse(folder)
 remote = acl.getUser(id)
 return Folder.__of__(self,parent.__of__(remote))

 --- teststructure--

 /testfolder/
ldapproxy (LDAPProxy)
acl_users/
testscript (.py)


 8 testscript -
 return context.ldapproxy.dn

 traceback--
 Traceback (most recent call last):
   File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
 line 113, in publish
 request, bind=1)
   File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/mapply.py,
 line 88, in mapply
 if debug is not None: return debug(object,args,context)
   File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
 line 40, in call_object
 result=apply(object,args) # Type scr to step into published object.
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
 line 311, in __call__
 return self._bindAndExec(args, kw, None)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
 line 348, in _bindAndExec
 return self._exec(bound_data, args, kw)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/Products/PythonScripts/PythonScript
.py, line 323, in _exec
 result = f(*args, **kw)
   File Script (Python), line 1, in testscript
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
 line 727, in guarded_getattr
 aq_acquire(inst, name, aq_validate, validate)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
 line 669, in aq_validate
 return validate(inst, object, name, v)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
 line 563, in validate
 self._context)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
 line 293, in validate
 accessed, container, name, value, context)
   File
 /home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
 line 808, in raiseVerbose
 raise Unauthorized(text)
 Unauthorized: Unable to find __roles__ in the container and the
 container is not wrapped.  Access to 'dn' of test, acquired through
 (LDAPProxy at /testfolder/ldapproxy), denied.


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


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Joerg Baach
Hi Peter,
 I'm not familiar with LDAPUserFolder (its not really a user object but a user 
 container, isn't it?) but the error you're getting is a security error -- the 
 Python Script checks for security attributes before it accesses attributes. 
 You need to add the appropriate security declarations in your product before 
 it can be used inside PyScript

Well, even with: __allow_access_to_unprotected_subobjects__ = 1 I get
the same error. VerboseSecurity is also on. :-(

Cheers,

  Joerg



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Joerg Baach

 I should have mentioned that in order for verbose-security to work you also 
 need to switch to the python security implementation -- did you do that? 

Yes, I did.

 If yes, you should see lines like these in your event.log:

No, don't :-(

But somehow I have the feeling it has more to do with the 'and the
container is not wrapped' part of the message. Not that I can make sense
of it ;-)

Cheers,

  Joerg



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Peter Sabaini
On Monday 25 February 2008 22:45:24 Joerg Baach wrote:
  I should have mentioned that in order for verbose-security to work you
  also need to switch to the python security implementation -- did you do
  that?

 Yes, I did.

  If yes, you should see lines like these in your event.log:

 No, don't :-(

Strange... 

 But somehow I have the feeling it has more to do with the 'and the
 container is not wrapped' part of the message. Not that I can make sense
 of it ;-)

Yes, definitely. Its just with VerboseSecurity its easier to debug...

Another option: put a debugger breakpoint (eg. import pdb; pdb.set_trace()) 
at the place where the Unauthorized exception is raised and inspect the 
objects 

peter.



 Cheers,

   Joerg


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


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Peter Sabaini
On Monday 25 February 2008 21:31:46 Joerg Baach wrote:
 Hi Peter,

  I'm not familiar with LDAPUserFolder (its not really a user object but a
  user container, isn't it?) but the error you're getting is a security
  error -- the Python Script checks for security attributes before it
  accesses attributes. You need to add the appropriate security
  declarations in your product before it can be used inside PyScript

 Well, even with: __allow_access_to_unprotected_subobjects__ = 1 I get
 the same error. VerboseSecurity is also on. :-(

I should have mentioned that in order for verbose-security to work you also 
need to switch to the python security implementation -- did you do that? 

security-policy-implementation python in zope.conf

If yes, you should see lines like these in your event.log:

2008-02-25T22:30:18 DEBUG ImplPython Unauthorized: Your user account does not 
have the required permission.  Access to 'manage' of (Application at ) 
denied. Your user account, Anonymous User, exists at /acl_users. Access 
requires one of the following roles: ['Manager']. Your roles in this context 
are ['Anonymous'].

peter.


 Cheers,

   Joerg


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


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Peter Sabaini
ps.: http://www.zope.org/Documentation/Books/ZDG/current/Security.stx has old 
but AFAIK still good info

On Monday 25 February 2008 22:45:24 Joerg Baach wrote:
  I should have mentioned that in order for verbose-security to work you
  also need to switch to the python security implementation -- did you do
  that?

 Yes, I did.

  If yes, you should see lines like these in your event.log:

 No, don't :-(

 But somehow I have the feeling it has more to do with the 'and the
 container is not wrapped' part of the message. Not that I can make sense
 of it ;-)

 Cheers,

   Joerg


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


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Joerg Baach
Hi again,

 2008-02-25T22:30:18 DEBUG ImplPython Unauthorized: Your user account does not 
 have the required permission.  Access to 'manage' of (Application at ) 
 denied. Your user account, Anonymous User, exists at /acl_users. Access 
 requires one of the following roles: ['Manager']. Your roles in this context 
 are ['Anonymous'].

Actually, if I change my code to something like:


def __of__(self, parent):
'''foo'''
if not hasattr(parent,'aq_base'):
return self

folder,id = self.remoteid.split(':')
acl = parent.restrictedTraverse(folder)
remote = acl.getUser(id)
self = Acquisition.ImplicitAcquisitionWrapper(self, remote)
self = Acquisition.ImplicitAcquisitionWrapper(self, parent)
return self

(idea taken from
http://www.mail-archive.com/[EMAIL PROTECTED]/msg11713.html)

I get a

Error Type: Unauthorized
Error Value: Your user account is defined outside the context of the
object being accessed. Access to 'ldapproxy' of (Folder at /testfolder)
denied. Your user account, admin, exists at /acl_users. Access requires
one of the following roles: ['Manager'].

Well, admin has 'Manager'.

/me scratches his head

Cheers,

  Joerg



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition / proxying object

2008-02-25 Thread Joerg Baach
Hi *,

 But somehow I have the feeling it has more to do with the 'and the
 container is not wrapped' part of the message. Not that I can make sense
 of it ;-)

Mmm, after even more searching, and not understanding I found

http://www.mail-archive.com/[EMAIL PROTECTED]/msg11438.html

and changed my code to:


def __of__(self, parent):
'''foo'''
if not hasattr(parent,'aq_base'):
return self

folder,id = self.remoteid.split(':')
acl = parent.unrestrictedTraverse(folder)
remote = acl.getUser(id)

return Acquisition.ImplicitAcquisitionWrapper(aq_base(self),

 aq_base(remote).__of__(parent))

Now, this actually seems to work. If only I knew why


Cheers,

  Joerg



signature.asc
Description: OpenPGP digital signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] acquisition failure puuzzle or maybe something else

2007-07-27 Thread Dennis Allison

Zope 2.9.X
Python 2.4
Centos 4.4 Linux
Firefox 2.0.0.5  (Linux and Win XP)


I have a dtml method is a folder C and a folder setup  

/ 
  A
  B
  C
  scripts


In the dtml method, there is a call to a script passing in a composed 
string made up of variables passed in through request inside of a 
dtml-let, 

dtml-let  someval=scripts.cleanfilename(cgivar1+'_'+cgivar2) 

 --- methods that use someval ---
/dtml-let

a pattern we have used in many places without a problem.

In this particular case, Zope throws an error

   Traceback (most recent call last):
 File /usr/local/src/zope/Zope2.9/lib/python/ZPublisher/Publish.py, 
   line 115, in publish
   request, bind=1)
 File /usr/local/src/zope/Zope2.9/lib/python/ZPublisher/mapply.py, line 
   88, in mapply
   if debug is not None: return debug(object,args,context)
 File /usr/local/src/zope/Zope2.9/lib/python/ZPublisher/Publish.py, 
   line 41, in call_object
   result=apply(object,args) # Type scr to step into published object.
 File /usr/local/src/zope/Zope2.9/lib/python/OFS/DTMLMethod.py, line 
   144, in __call__
   r=apply(HTML.__call__, (self, client, REQUEST), kw)
 File 
   /usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_String.py, 
   line 476, in __call__
   try: result = render_blocks(self._v_blocks, md)
 File /usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_In.py, 
   line 630, in renderwob
   if self.elses: return render_blocks(self.elses, md)
 File /usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_In.py, 
   line 703, in renderwob
   try: append(render(section, md))
 File 
   /usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_Let.py, line 
   75, in render
   else: d[name]=expr(md)
 File 
   /usr/local/src/zope/Zope2.9/lib/python/DocumentTemplate/DT_Util.py, line 
   196, in eval
   return eval(code, d)
 File string, line 1, in expression
   AttributeError: cleanfilename
   
The failing line is (literally)

  dtml-let sname=scripts.cleanfilename(user_lastname+'_'+user_firstname)

which is part of a dtml-let with several components.


Now, the failing element is part of a method that fundamentally has a
if-elif structure and the actual code fragment is embedded in a pair of
nested dtml-in blocks which have internal try-except-else blocks,
but that is all control structure and should not impact name/attribute
resolution, or so I believe.  A trace through the executing method shows
the control flow is functioning as expected.  Security settings appear to
be correct--and the correct execution of simple test methods (see below)
tend to support that conclusion.

Moving the script into the same folder as the method (that is, moving it from 
the folder scripts to the folder C in the layout above) is a workaround, but it
breaks our coding conventions.  i

Simple test methods in folder C 

   dtml-var standard_html_header
   dtml-let sss=scripts.cleanfilename('able baker charlie  ')
   dtml-var sss
   /dtml-let
   dtml-var standard_html_footer

work fine and do not throw the attribute error.

I suspect that this is a problem caused by some trivial error, but we've been
unable to find it.  Any help/suggestions as to how to resolve this puzzle would
be appreciated.



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


Re: [Zope] acquisition failure puuzzle or maybe something else

2007-07-27 Thread Jonathan


- Original Message - 
From: Dennis Allison [EMAIL PROTECTED]

To: zope@zope.org
Sent: Friday, July 27, 2007 1:18 PM
Subject: [Zope] acquisition failure puuzzle or maybe something else


I have a dtml method is a folder C and a folder setup

/
 A
 B
 C
 scripts


In the dtml method, there is a call to a script passing in a composed
string made up of variables passed in through request inside of a
dtml-let,

dtml-let  someval=scripts.cleanfilename(cgivar1+'_'+cgivar2)
   
--- methods that use someval ---
   /dtml-let

a pattern we have used in many places without a problem.

In this particular case, Zope throws an error
File string, line 1, in expression
  AttributeError: cleanfilename

The failing line is (literally)

 dtml-let sname=scripts.cleanfilename(user_lastname+'_'+user_firstname)


What are the values of cgivar1 and cgivar2 when the error is thrown? (ie. 
does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - possible 
if someone enters a name with a character that will kill your code, such as 
o'neil)



Jonathan


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] acquisition failure puuzzle or maybe something else

2007-07-27 Thread Jonathan


- Original Message - 
From: Dennis Allison [EMAIL PROTECTED]

To: Jonathan [EMAIL PROTECTED]
Cc: zope@zope.org
Sent: Friday, July 27, 2007 2:35 PM
Subject: Re: [Zope] acquisition failure puuzzle or maybe something else




The values are validated and are simple strings.  For our testing purpose
they are things like 'aaa'.  Also, if that were the problem, eval would
have thrown a different error since it most likely evaluates the
parameters before trying to bind the call.  In our testing we have
replaced the catenation with a static string but still get the error.


In your previous message you said:

snip
Simple test methods in folder C

  dtml-var standard_html_header
  dtml-let sss=scripts.cleanfilename('able baker charlie  ')
  dtml-var sss
  /dtml-let
  dtml-var standard_html_footer

work fine and do not throw the attribute error.
/snip

Now you are saying that the static string does cause the error?


To remove the acquisition issue:  if you can get the cleanfilename routine 
to just return the input parameter (as a test, don't do anything else in 
cleanfilename) without error, then that means that you have a coding error 
somewhere within cleanfilename.



Jonathan



On Fri, 27 Jul 2007, Jonathan wrote:



- Original Message - 
From: Dennis Allison [EMAIL PROTECTED]

To: zope@zope.org
Sent: Friday, July 27, 2007 1:18 PM
Subject: [Zope] acquisition failure puuzzle or maybe something else

 I have a dtml method is a folder C and a folder setup

 /
  A
  B
  C
  scripts


 In the dtml method, there is a call to a script passing in a composed
 string made up of variables passed in through request inside of a
 dtml-let,

 dtml-let  someval=scripts.cleanfilename(cgivar1+'_'+cgivar2)

 --- methods that use someval ---
/dtml-let

 a pattern we have used in many places without a problem.

 In this particular case, Zope throws an error
 File string, line 1, in expression
   AttributeError: cleanfilename

 The failing line is (literally)

  dtml-let 
 sname=scripts.cleanfilename(user_lastname+'_'+user_firstname)


What are the values of cgivar1 and cgivar2 when the error is thrown? (ie.
does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - 
possible
if someone enters a name with a character that will kill your code, such 
as

o'neil)


Jonathan




--





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] acquisition failure puuzzle or maybe something else

2007-07-27 Thread Dennis Allison

The values are validated and are simple strings.  For our testing purpose 
they are things like 'aaa'.  Also, if that were the problem, eval would 
have thrown a different error since it most likely evaluates the 
parameters before trying to bind the call.  In our testing we have 
replaced the catenation with a static string but still get the error.


On Fri, 27 Jul 2007, Jonathan wrote:

 
 - Original Message - 
 From: Dennis Allison [EMAIL PROTECTED]
 To: zope@zope.org
 Sent: Friday, July 27, 2007 1:18 PM
 Subject: [Zope] acquisition failure puuzzle or maybe something else
 
  I have a dtml method is a folder C and a folder setup
 
  /
   A
   B
   C
   scripts
 
 
  In the dtml method, there is a call to a script passing in a composed
  string made up of variables passed in through request inside of a
  dtml-let,
 
  dtml-let  someval=scripts.cleanfilename(cgivar1+'_'+cgivar2)
 
  --- methods that use someval ---
 /dtml-let
 
  a pattern we have used in many places without a problem.
 
  In this particular case, Zope throws an error
  File string, line 1, in expression
AttributeError: cleanfilename
 
  The failing line is (literally)
 
   dtml-let sname=scripts.cleanfilename(user_lastname+'_'+user_firstname)
 
 What are the values of cgivar1 and cgivar2 when the error is thrown? (ie. 
 does the cgivar1+'_'+cgivar2 code evaluate to an illegal string - possible 
 if someone enters a name with a character that will kill your code, such as 
 o'neil)
 
 
 Jonathan
 
 

-- 

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


Re: [Zope] acquisition

2006-12-14 Thread Peter Bengtsson



Dennis Schulz wrote:
I found no example how to define it in the class generally for all 
instances


i would like to access the supplier container under a different name 
inside one instance of Purchase Requisition.


class PurchaseRequisition( SimpleItem, Implicit ):

suppliers = property ( lambda self: str( 
self.context.aq_inner.aq_parent.supplier) )



Keep it simple like Andreas suggested::

from Acquisition import aq_inner, aq_parent
class PurchaseRequisition( SimpleItem, Implicit ):

def suppliers(self):
parent = aq_parent(aq_inner(self))
return parent.supplier

# does exactly the same thing thanks to automatic
# acquisition:
def suppliers(self):
return self.supplier






Andreas Jung escribió:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz 
[EMAIL PROTECTED] wrote:


 

Hi

I want to acquire an persistent zope object (supplier) that is inside my
productfolder

myproductfolder/supplier

How to get a reference to this object? Also, Is there a method to get 
the

product root?




context.myproductfolder.supplier?

That's basic acquisition and should be documented in the Zope Book:

http://www.plope.com/Books/2_7Edition/Acquisition.stx

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66
BUalSLllgOaxmn4C0kBiCns=
=E1/0
-END PGP SIGNATURE-


  



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



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] acquisition

2006-12-13 Thread Dennis Schulz

Hi

I want to acquire an persistent zope object (supplier) that is inside my 
productfolder


myproductfolder/supplier

How to get a reference to this object? Also, Is there a method to get 
the product root?


I would like to have that all instances of my class can be traversed like

prinstance/suppliers



The class has to be derived from SimpleItem. What do I have to add to 
get it work?


class PurchaseRequisition( SimpleItem, Implicit ):

   suppliers = aq_inner(self).aq_acquire(reference_to_container)




Dennis

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] acquisition

2006-12-13 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz [EMAIL PROTECTED] 
wrote:

 Hi

 I want to acquire an persistent zope object (supplier) that is inside my
 productfolder

 myproductfolder/supplier

 How to get a reference to this object? Also, Is there a method to get the
 product root?


context.myproductfolder.supplier?

That's basic acquisition and should be documented in the Zope Book:

http://www.plope.com/Books/2_7Edition/Acquisition.stx

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66
BUalSLllgOaxmn4C0kBiCns=
=E1/0
-END PGP SIGNATURE-

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


Re: [Zope] acquisition

2006-12-13 Thread Dennis Schulz

I found no example how to define it in the class generally for all instances

i would like to access the supplier container under a different name 
inside one instance of Purchase Requisition.


class PurchaseRequisition( SimpleItem, Implicit ):

suppliers = property ( lambda self: str( 
self.context.aq_inner.aq_parent.supplier) )


Andreas Jung escribió:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz [EMAIL PROTECTED] 
wrote:


  

Hi

I want to acquire an persistent zope object (supplier) that is inside my
productfolder

myproductfolder/supplier

How to get a reference to this object? Also, Is there a method to get the
product root?




context.myproductfolder.supplier?

That's basic acquisition and should be documented in the Zope Book:

http://www.plope.com/Books/2_7Edition/Acquisition.stx

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66
BUalSLllgOaxmn4C0kBiCns=
=E1/0
-END PGP SIGNATURE-


  



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] acquisition

2006-12-13 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 13. Dezember 2006 19:56:40 +0100 Dennis Schulz [EMAIL PROTECTED] 
wrote:

 I found no example how to define it in the class generally for all
 instances

 i would like to access the supplier container under a different name
 inside one instance of Purchase Requisition.

 class PurchaseRequisition( SimpleItem, Implicit ):

  suppliers = property ( lambda self: str(
 self.context.aq_inner.aq_parent.supplier) )

No idea what this (nonsense) code should do. Follow the standard road
and write a method

   def getSuppliers(self):
   return self.foo.bar.supplier


or use self.restrictedTraverse(path) if you are working with path
information.

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFFgFVOCJIWIbr9KYwRAsSEAKDiitYhxB+/rcE/L/+Cw2f4reJmKwCfZljA
pBe8OXA5jWK9w7waXXC2V+o=
=zZf0
-END PGP SIGNATURE-

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


Re: [Zope] Acquisition question

2006-08-29 Thread Chris Withers

Ferhat Ayaz wrote:

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee

here the result of employee_by_id (param is emp_id=2)
is used by viewEmployee.

But I want to use it in a page template like

td tal:content=
   structure mployee_by_id/emp_id/2/viewEmployee
/td

Unfortunatly this will not work like the above
example.


You need to provide us with the traceback you got if you want us to be 
able to help ;-)


Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition question

2006-08-29 Thread Garito

Ferhat Ayaz escribió:

Hi list,

I'm a newby to zope. Sorry if the question is to
dummy.
Here my question:

You can do acquisition on URL like

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee

here the result of employee_by_id (param is emp_id=2)
is used by viewEmployee.

But I want to use it in a page template like

td tal:content=
   structure mployee_by_id/emp_id/2/viewEmployee
/td

Unfortunatly this will not work like the above
example.

Is it possible to do acquisition in this way, or is
there a way to this?

Thanks,
Ferhat




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___

Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce

 http://mail.zope.org/mailman/listinfo/zope-dev )
  
At this point if employee_by_id is the first param then all are on 
traverse_subpath list like:


['employee_by_id', 'emp_id', 2, 'viewEmployee']

then you could use this list to know what your user is asking for

Sorry for my poor english

--
Mis Cosas
http://blogs.sistes.net/Garito


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition question

2006-08-29 Thread Ferhat Ayaz
Thanks for the answers.
The example was from the Zope Book.

employee_by_id - Z SQL Method
emp_id - Parameter key for employee_by_id
2 - Parameter value for emp_id

The result of employee_by_id(emp_id=2) is a SQL
result. 

viewEmployee - DTML Method

viewEmployee will use the result of the above
employee_by_id Z SQL Method and render the variables
first,last and salary to HTML, if I call the URL from
a browser.

But, giving the same URL
employee_by_id/emp_id/2/viewEmployee as a tal
expression like

tal:content=structure
employee_by_id/emp_id/2/viewEmployee

will render nothing. There is also no error messages. 
Do you know what happens?

Thanks,
Ferhat


--- Garito [EMAIL PROTECTED] wrote:

 Ferhat Ayaz escribió:
  Hi list,
 
  I'm a newby to zope. Sorry if the question is to
  dummy.
  Here my question:
 
  You can do acquisition on URL like
 
 

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee
 
  here the result of employee_by_id (param is
 emp_id=2)
  is used by viewEmployee.
 
  But I want to use it in a page template like
 
  td tal:content=
 structure
 mployee_by_id/emp_id/2/viewEmployee
  /td
 
  Unfortunatly this will not work like the above
  example.
 
  Is it possible to do acquisition in this way, or
 is
  there a way to this?
 
  Thanks,
  Ferhat
 
 
 
 
  __
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam
 protection around 
  http://mail.yahoo.com 
  ___
  Zope maillist  -  Zope@zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists - 
  
 http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )

 At this point if employee_by_id is the first param
 then all are on 
 traverse_subpath list like:
 
 ['employee_by_id', 'emp_id', 2, 'viewEmployee']
 
 then you could use this list to know what your user
 is asking for
 
 Sorry for my poor english
 
 -- 
 Mis Cosas
 http://blogs.sistes.net/Garito
 
 
 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope-dev )
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition question

2006-08-29 Thread Dieter Maurer
Ferhat Ayaz wrote at 2006-8-28 11:06 -0700:
Here my question:

You can do acquisition on URL like

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee

here the result of employee_by_id (param is emp_id=2)
is used by viewEmployee.

But I want to use it in a page template like

td tal:content=
   structure mployee_by_id/emp_id/2/viewEmployee
/td

Unfortunatly this will not work like the above
example.

The reason for this different behaviour is that a
ZSQL method uses a traversal hook to implement the
method/parameter feature.
This traversal hook is only activated during URL traversal
but not for path expression evaluation.

Fortunately, you do not need this hook in TALES.
You can instead use a Python expression to call
the ZSQL Method explicitely:

td tal:content=
  structure python:employee_by_id(emp_id=2).viewEmployee()
   /

This will work only (reliably) when viewEmployee is
a PageTemplate (not a DTML object).

For a DTML object viewEmployee you could use:

   td tal:define=employee python:employee_by_id(emp_id=2)
 tal:content=employee/viewEmployee
 /

You find the reason for this strange DTML object behaviour
in the Calling DTML objects section of

  http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition question

2006-08-29 Thread Ferhat Ayaz
wow. Thanks. This is exactly that what I need. :)

--- Dieter Maurer [EMAIL PROTECTED] wrote:

 Ferhat Ayaz wrote at 2006-8-28 11:06 -0700:
 Here my question:
 
 You can do acquisition on URL like
 

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee
 
 here the result of employee_by_id (param is
 emp_id=2)
 is used by viewEmployee.
 
 But I want to use it in a page template like
 
 td tal:content=
structure mployee_by_id/emp_id/2/viewEmployee
 /td
 
 Unfortunatly this will not work like the above
 example.
 
 The reason for this different behaviour is that a
 ZSQL method uses a traversal hook to implement the
 method/parameter feature.
 This traversal hook is only activated during URL
 traversal
 but not for path expression evaluation.
 
 Fortunately, you do not need this hook in TALES.
 You can instead use a Python expression to call
 the ZSQL Method explicitely:
 
 td tal:content=
   structure
 python:employee_by_id(emp_id=2).viewEmployee()
/
 
 This will work only (reliably) when viewEmployee
 is
 a PageTemplate (not a DTML object).
 
 For a DTML object viewEmployee you could use:
 
td tal:define=employee
 python:employee_by_id(emp_id=2)
  tal:content=employee/viewEmployee
  /
 
 You find the reason for this strange DTML object
 behaviour
 in the Calling DTML objects section of
 
  

http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
 
 
 
 -- 
 Dieter
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Acquisition question

2006-08-28 Thread Ferhat Ayaz
Hi list,

I'm a newby to zope. Sorry if the question is to
dummy.
Here my question:

You can do acquisition on URL like

http://localhost:8080/employee_by_id/emp_id/2/viewEmployee

here the result of employee_by_id (param is emp_id=2)
is used by viewEmployee.

But I want to use it in a page template like

td tal:content=
   structure mployee_by_id/emp_id/2/viewEmployee
/td

Unfortunatly this will not work like the above
example.

Is it possible to do acquisition in this way, or is
there a way to this?

Thanks,
Ferhat




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition? problem

2006-08-15 Thread Hans Then
Hi Jonathan,

 if you have a python script in the middle of your path, eg:
 folder/pythonscript/somethingelse
 then the pythonscript routine will get executed and 'somethingelse' will
be
 passed in a variable called 'traverse_subpath'
 Create a test python script and try it out (look for traverse_subpath in
the
 REQUEST namespace)

What if I don't want that? I can, for instance, call
/folder/pythonscript/title_or_id
/folder/pythonscript/manage_workspace

There the behaviour you describe does not occur.

Regards,

Hans Then

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


[Zope] Acquisition and self arguements of methods

2006-07-22 Thread Mohsen Moeeni

Hello;

As far as I see, the `self` argument, when a method
is called, is not dependent on how the method was
acquired.

Consider I have an instance of class B which is named
b and has a method named `method_b`. In either of
these calls:

a.b.c.method_b()
a.b.method_b()

`self` argument will be `a.b` if I am not wrong. Is there
any way to get the acquisition context where a
method is called inside that method? In the other
words, how to get `a.b.c` within `method_b` when I
call `a.b.c.method_b` and `a.b` when I call
`a.b.method_b`?

Regards,
M. Moeini
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Acquisition? problem

2006-06-30 Thread Hans Then
Hi all,

I am writing a small object browser for the EPOZ toolbox. In the browser I
have a tree of object references. Clicking on the tree should show more
details of the selected object. I have created a template details that
should show the details of the object, like this:

/folder/selected_object/details

This is all TTW code by the way. The template works fine for most values of
selected_object, but for some it fails. It fails for at least PageTemplates
and Python Scripts. For those objects, calling the details template will
simply show the normal output of the object.

Any ideas on how to solve this?

Regards,

Hans Then

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


Re: [Zope] Acquisition? problem

2006-06-30 Thread Jonathan


- Original Message - 
From: Hans Then [EMAIL PROTECTED]

I am writing a small object browser for the EPOZ toolbox. In the browser I
have a tree of object references. Clicking on the tree should show more
details of the selected object. I have created a template details that
should show the details of the object, like this:

/folder/selected_object/details

This is all TTW code by the way. The template works fine for most values 
of
selected_object, but for some it fails. It fails for at least 
PageTemplates

and Python Scripts. For those objects, calling the details template will
simply show the normal output of the object.


if you have a python script in the middle of your path, eg:

folder/pythonscript/somethingelse

then the pythonscript routine will get executed and 'somethingelse' will be 
passed in a variable called 'traverse_subpath'


Create a test python script and try it out (look for traverse_subpath in the 
REQUEST namespace)




Jonathan 


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition? problem

2006-06-30 Thread Jonathan


- Original Message - 
From: Hans Then [EMAIL PROTECTED]

if you have a python script in the middle of your path, eg:
folder/pythonscript/somethingelse
then the pythonscript routine will get executed and 'somethingelse' will

be

passed in a variable called 'traverse_subpath'
Create a test python script and try it out (look for traverse_subpath in

the

REQUEST namespace)


What if I don't want that? I can, for instance, call
/folder/pythonscript/title_or_id
/folder/pythonscript/manage_workspace


If you want to be sure about the behaviour of your display template I would 
change the URL to something like:


folder/displayroutine?id=objectid

and have displayroutine (a script or method) access the object via the 
parameter id ad generate the appropriate display (based on the type of 
object it is given). This way you are not going to run into differences in 
aquisition handling for different types of objects that you are trying to 
display.



Jonathan 


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] acquisition uml modelisation

2006-03-20 Thread thomas desvenain
hello,

do you know where i may find tools for acquisition representation in uml ?

thanks

thomas desvenain
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] acquisition uml modelisation

2006-03-20 Thread Dieter Maurer
thomas desvenain wrote at 2006-3-20 15:43 +0100:
do you know where i may find tools for acquisition representation in uml ?

I fear, UML does not know about this type of relation (and therefore,
tools will not support it).

You will need to look for an UML extension mechanism and use it
to represent acquisition type relationships.


-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-04 Thread Dieter Maurer
Roman Klesel wrote at 2006-3-3 10:26 +0100:
 ...
Yes, this is what I understood (at least I think so) now. So the question is:

How will the method find out what object I want it to operate on if I call it 
in this way

context/genGraphs or objref/genGraphs

It cannot.

It works for a PythonScript because in this case you acquire
an object (and not a method) and then call its method (__call__).
The difference is that an object is acquired, not a method.

You can try to arrange things this way even with classes defined
in products:

   You define a new class WC, derived from Implicit.
   Its __call__ method does, what you would like to happen.
   In __call__, you access the acquisition context with
   self.aq_parent.

   In your class C, you instantiate WC:

  test3 = WC()

   You can then acquire test3 (it now is an object, no longer
   a method) and call it. In test3.__call__, self.aq_parent
   will be the object, from which you acquired test3.

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Roman Klesel
Andrew Milton schrieb:
 
 Perhaps if you describe the problem you're trying to solve, we can actually
 help you.
 

Yes, thank you!

I just want to be able to do what I'm used to do from TTW:

- There is a hirarchy of Folder/File objects
- In the root directory there is an python script (showData.py)
- the python script operates on context eg.

return context.data

From a ZPT I can now loop over a Folder and call the python script on every 
object in the folder:

ul
 li tal:repeat=elem context/objectValues
 tal:content=elem/showDatadata/li
ul

Depending on the URL I call this on I will get a list of data of all files 
present here.

This is just what I want to do in the fs product I'm writing:

I have a folderish object that holds a collection of File objects nicely sorted 
in a hirarchy of Folders objects.
This folderish object has methods to display the data in the File objects 
(underneth it self) in differnt ways eg.

def genGraph(self):
plot graph from self.data and return a png image
...

def getDataMatrix(self):
return self.data as a list of rows where every field is a list element
...

just as in my example above I want to be able to call this methods on any File 
objects from a ZPT like this:

ul
 li tal:repeat=elem context/objectValues
  img tal:attributes=src string: ${elem/absolute_url}/genGraph plot /img
 /li
ul

Therefore I started the thread:
[Zope] context in fs product

The answer I got:

'self' inside the a Zope product is the _same_ as 'context' or 'here' within
ZPT or PythonScripts.

So now I'm stuck.

Of course I could pass the object or its id to the methods as an argument eg.

span tal:define=data python:context.genGraphs(elem)sdf/span

and in the method get the the object with getattr() or something ...

But this wouldn't be nearly as nice and I'd like to avoid this.


(The code examples here might have errors, I just typed them in as an 
illustration of my thougts)

Greetings Roman


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


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Andrew Milton
+---[ Roman Klesel ]--
| Andrew Milton schrieb:
|  
|  Perhaps if you describe the problem you're trying to solve, we can actually
|  help you.
|  
| 
| Yes, thank you!

| just as in my example above I want to be able to call this methods on any 
File objects from a ZPT like this:
| 
| ul
|  li tal:repeat=elem context/objectValues
|   img tal:attributes=src string: ${elem/absolute_url}/genGraph plot /img
|  /li
| ul

In what way doesn't this work? I've certainly used this pattern in my FS
products without problems.

| 'self' inside the a Zope product is the _same_ as 'context' or 'here' within
| ZPT or PythonScripts.

It IS in the context of that object. However, if you call a method that is
acquired, self in that method is the acquired object, not the acquiring object.

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


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Roman Klesel
Andrew Milton schrieb:
  | ul
 |  li tal:repeat=elem context/objectValues
 |   img tal:attributes=src string: ${elem/absolute_url}/genGraph plot 
 /img
 |  /li
 | ul
 
 In what way doesn't this work? I've certainly used this pattern in my FS
 products without problems.


Hmm? Did I miss something? A few posts above we recoginzed that when I would do:

def genGraph(self):
bla
return self.data

then genGraph would return data from the class where it is defined and not from 
the object acquiring it. So it would fail.

 | 'self' inside the a Zope product is the _same_ as 'context' or 'here' within
 | ZPT or PythonScripts.
 
 It IS in the context of that object. However, if you call a method that is
 acquired, self in that method is the acquired object, not the acquiring 
 object.
 

Yes, this is what I understood (at least I think so) now. So the question is:

How will the method find out what object I want it to operate on if I call it 
in this way

context/genGraphs or objref/genGraphs

I actually want it to operate on the object I called it on, but this is not 
what self inside the method represents.

Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Andrew Milton
+---[ Roman Klesel ]--
| Andrew Milton schrieb:
|   | ul
|  |  li tal:repeat=elem context/objectValues
|  |   img tal:attributes=src string: ${elem/absolute_url}/genGraph plot 
/img
|  |  /li
|  | ul
|  
|  In what way doesn't this work? I've certainly used this pattern in my FS
|  products without problems.
| 
| 
| Hmm? Did I miss something? A few posts above we recoginzed that when I would 
do:
| 
| def genGraph(self):
| bla
| return self.data
| 
| then genGraph would return data from the class where it is defined and not 
from the object acquiring it. So it would fail.

How about you forget about Acquisition for now.

Define the method in the class you want to call it on.

Once you're happy with the way that works, you can use Acquisition to keep
things like state or configuration for a particular path.

If you CAN'T define the method in the class (not sure why you couldn't), then
you will have to define a method and pass an instance or a reference.

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


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Roman Klesel
Andrew Milton schrieb:
 How about you forget about Acquisition for now.


Well, hmmm ... this will be hard ... I was just about to fall in love with it 
...

 Define the method in the class you want to call it on.

Then I will have to subclass from OFS.Image.File and I was told that this is 
somehow evil. From a previous thread:

Roman Klesel wrote:
 form OFS.Image import File

 - I build a class _File(File):

I really doubt you need to do that...

 - pimped it up a little bit.

What, specifically, did you add?

 - _setObject'ed it

You shouldn't be calling that directly...


 If you CAN'T define the method in the class (not sure why you couldn't), then
 you will have to define a method and pass an instance or a reference.
 

This makes the code in the ZPT all messy...

The third option is to somehow construct the the object the method should 
operate on from self.REQUEST.
I think I will try that ...

I was really hoping to get to understand this acquisition thing.
Am I really that far away from getting it? What does it take to grasp it?

Thanks anyway for your time and efforts!

Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Andrew Milton
+---[ Roman Klesel ]--
| Andrew Milton schrieb:
|  How about you forget about Acquisition for now.
| 
| 
| Well, hmmm ... this will be hard ... I was just about to fall in love with it 
...

It's definitely useful, but, you have to pick your moments to use it.

|  Define the method in the class you want to call it on.
| 
| Then I will have to subclass from OFS.Image.File and I was told that this is 
somehow evil. From a previous thread:
| 
| Roman Klesel wrote:
|  form OFS.Image import File
| 
|  - I build a class _File(File):
| 
| I really doubt you need to do that...
| 
|  - pimped it up a little bit.
| 
| What, specifically, did you add?
| 
|  - _setObject'ed it
| 
| You shouldn't be calling that directly...

Well you have to decide who to believe then won't you ? d8)

| I was really hoping to get to understand this acquisition thing.
| Am I really that far away from getting it? What does it take to grasp it?

Think of Acquisition this way; read-only, run-time, inheritance.

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


Re: [Zope] Acquisition not working as expected

2006-03-03 Thread Dieter Maurer
Roman Klesel wrote at 2006-3-3 08:20 +0100:
 ...
 In your case, the method test3 is not defined by Folder
 but by what you call your product instance (still a wrong term!).
 Therefore, its self is necessarily an instance of your product
 (I keep your wrong term). And self.getId() gives (consequently)
 its (and not the Folder's) id.
 

What would then be the right term? (I suspect I'll have to discuss this 
further)

An instance of my class defining test3.

Note again:

  A product is an extension mechanism for Zope usually
  defining and registering various classes to be instantiated
  as (what I call) site building objects.

  Thus, there is no product instance (in your Zope hierarchy).
  Instead you have instances of classes defined in your product.

  I would give the classes articifical names, say C, C1, C2 ...

E.g. a perfect description of your problem could have been:

  In a product I defined a class C deriving from
  Folder with method test3 which prints self.getId().

  I can call test3 (via acquistion) on objects contained
  in an instance I of C. However, the printed id is
  always the id of I and not that of the object on which test3
  has been called on.

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-02 Thread Roman Klesel
Hello,

Roman Klesel schrieb:
  I can call this method on whatever folder inside the product instance I 
  want, it will always return the id of the
 product and not the id of the product I call it on.

In order to make my problem more obvious I created a minimal product. See 
attachmet.

It displays exactly the problem I'm facing:

A method in the base class that returns self.id, returns the id of the base 
class on all subfolders it is called.

Code:

 __doc__=This is Minimal
__version__='0.1'

from Globals import InitializeClass, Persistent
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from AccessControl import ClassSecurityInfo
from Acquisition import Implicit
from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import SimpleItem
import OFS


class minimal(Persistent,Implicit,ObjectManager,SimpleItem):
minimal object
security = ClassSecurityInfo()
meta_type = 'minimal'

def __init__(self, id):
initialise a new instance of Minimal
self.id = id

index_html=PageTemplateFile('zpt/index.html',globals())

security.declarePublic('sayHello')
def sayHello(self):
just says hello
return 'Hello'
def showId(self):
return self.id

def manage_addMinimal(self, REQUEST=None):
Add a Minimal to a folder.
self._setObject('minimal_id', minimal('minimal_id'))
min_obj = getattr(self,'minimal_id')
min_obj.manage_addFolder('tfolder')
if REQUEST is not None:
try:
destURL=self.DestinationURL()
except:
destURL=REQUEST['URL1']

REQUEST.RESPONSE.redirect(destURL+'/manage_main')   
return ''   

InitializeClass(minimal)


Any ideas anyone?

Greetings Roman



minimal.tar.gz
Description: GNU Zip compressed data
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-02 Thread Dieter Maurer
Roman Klesel wrote at 2006-3-2 08:13 +0100:
 ...
I can call this method on whatever folder inside the product instance 
(instance of the base class ZLTMS) I want, it will
always return the id of the instace of the base class (where the method is 
defined) and not the id of the object (Folder
object or File object)

This is how acquistion works (and should work):

  When you acquire a method, the self this method is called
  with is usually *NOT* the object acquisition is applied on.

If you think about it, you will recognize that this must be the case:

  For any method m of class C, its first argument *MUST* be
  a C instance.

  If you acquire the method m starting from o, then
  o may have a completely different class then m.


In your case, the method test3 is not defined by Folder
but by what you call your product instance (still a wrong term!).
Therefore, its self is necessarily an instance of your product
(I keep your wrong term). And self.getId() gives (consequently)
its (and not the Folder's) id.


You cannot do with acquisition what you want to do...

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-02 Thread Andrew Milton
+---[ Roman Klesel ]--
| Hello,
| 
| Roman Klesel schrieb:
|   I can call this method on whatever folder inside the product instance I 
want, it will always return the id of the
|  product and not the id of the product I call it on.
| 
| In order to make my problem more obvious I created a minimal product. See 
attachmet.
| 
| It displays exactly the problem I'm facing:
| 
| A method in the base class that returns self.id, returns the id of the base 
class on all subfolders it is called.

That's the way acquisition works. I'm not sure why you want this, since
everything you're adding has an id already, so there's no need to acquire any
method to get the id.

Perhaps if you describe the problem you're trying to solve, we can actually
help you.

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


[Zope] Acquisition not working as expected

2006-03-01 Thread Roman Klesel
Hello,

sorry to come up with this again. I startet 2 pretty confused threads on the 
same problem allready:

[Zope] Error Value: 'File'  object  has no  attribute   
'manage_fixupOwnershipAfterAdd'
Re: [Zope] context in fs product

Unfortunatly I'm still not getting it right.
I implemeted the good advices I got in the 2 Threads, slept over it a couple of 
nights. Looked at the code again,
cleaned it up ... still: no success.

Here is what I'm doing:

I'm about to write a fs product to report on data generated by the grinder 
load test tool
The load tests produce various log files and sar outputs that will have to be 
parsed and imported into Zope.

The instance of the product is created:

def manage_addZLTMS(self,id,title='',REQUEST=None,submit=None):
Add a ZLMTS to a folder.
id=id.replace(' ','_')
zltmsObj=ZLTMS(id,title)
id=self._setObject(id, zltmsObj)
folder=getattr(self, id)
folder.manage_addFolder(id='LoadTests',title='Collection')

The LoadTest folder is the place where the imported data will be stored.

The base class ...

class ZLTMS(Lasttest,Implicit, Persistent, PropertyManager, ObjectManager, 
SimpleItem):
ZLMTS object

... has an import method

def newLasttest(self, REQUEST=None):
 new 
ltc=getattr(self,'LoadTests')
ltid = self.genId(ltc)
lt=Lasttest()
lt.id=ltid
ltc._setObject(ltid,lt)
self.lt = getattr(ltc,ltid)
self.lt.importData(self.manage_targets)

This generates and instance of the Lasttest() class and imports the data.
Lasttest() subclasses from Folder() and store all imported data in a folder 
hirarchy under itself.

This all works fine and I can browse the imported data in the ZMI. The problems 
start when I want to access the data.

eg.:

In the base class I created a test3() method:

def test3(self):
dsaf
return self.getId()

I can call this method on whatever folder inside the product instance I want, 
it will always return the id of the
product and not the id of the product I call it on.

Why is that?

So I thought for some reasons the objects in the folder hirarchy are not 
acquisition wrapped. So I created another
testspace() method in the base class:

def testspace(self,REQUEST=None):
tests
if hasattr(self, 'aq_base'):
return 'aq wraped'
return 'not aq wraped'

I can call this on any object in the folder hirarchy and it returns:
'aq wrapped'.

Can so. please help me get this straight or hint towards further analysis that 
I can do.

Thanks in advance.

Greetings Roman

BTW: I did not post any code of the Lattest() class since the problem is 
allready present in the folder that holds its
instances. Of course I will post any part of the code you want me to.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-01 Thread Andrew Milton
+---[ Roman Klesel ]--
| Hello,

| class ZLTMS(Lasttest,Implicit, Persistent, PropertyManager, ObjectManager, 
SimpleItem):
|   ZLMTS object
| 
| ... has an import method
| 
|   def newLasttest(self, REQUEST=None):
|new 
|   ltc=getattr(self,'LoadTests')
|   ltid = self.genId(ltc)
|   lt=Lasttest()
|   lt.id=ltid
|   ltc._setObject(ltid,lt)
|   self.lt = getattr(ltc,ltid)
|   self.lt.importData(self.manage_targets)
| 
| This generates and instance of the Lasttest() class and imports the data.
| Lasttest() subclasses from Folder() and store all imported data in a folder 
hirarchy under itself.
| 
| This all works fine and I can browse the imported data in the ZMI. The 
problems start when I want to access the data.
| 
| eg.:
| 
| In the base class I created a test3() method:
| 
|   def test3(self):
|   dsaf
|   return self.getId()
| 
| I can call this method on whatever folder inside the product instance I want, 
it will always return the id of the
| product and not the id of the product I call it on.
| 
| Why is that?

Are you sure your genId() method works?

what does return self.id return instead of self.getId() ?

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


Re: [Zope] Acquisition not working as expected

2006-03-01 Thread Roman Klesel
Hello Andrew,

Andrew Milton schrieb:
 Are you sure your genId() method works?
 

Well, yes, it does what it's ment to do. It generates an id, a string.

Here it is:

def genId(self,context):
asdf
items = [ int(e[2:]) for e in context.objectIds('Folder') ]
if items == []:
return 'lt10'
return 'lt%s' % str(max(items)+1

 what does return self.id return instead of self.getId() ?
 

I just checked, there is no difference. Both return the id of the product 
instance as string.

Greetings Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-01 Thread Roman Klesel
Andrew Milton schrieb:
 Did you paste this code, because it has errors...

Ahh sorry, I missed the last charakter, a ).

Here it is again:

def genId(self,context):
asdf
items = [ int(e[2:]) for e in context.objectIds('Folder') ]
if items == []:
return 'lt10'
return 'lt%s' % str(max(items)+1)

Greetings Roman
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-01 Thread Dieter Maurer
Roman Klesel wrote at 2006-3-1 13:24 +0100:
 ...
I can call this method on whatever folder inside the product instance I want, 
it will always return the id of the
product and not the id of the product I call it on.

I fear you will need to more clearly describe what you mean
with the product (on one hand) and the product I call it on
(on the other hand).
You should clearly state which classes the objects
the product and the product I call it on have (classes
are the primary influence, the acquisition relation is the
secondary influence -- this should should state clearly as well).


Note also that objects in your Zope hiearchy are not products
(a product is a Zope extension mechanisms usually defining and
registering various classes that can be use to create persistent
Zope objects).



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition not working as expected

2006-03-01 Thread Roman Klesel
Dieter Maurer schrieb:
I can call this method on whatever folder inside the product instance I want, 
it will always return the id of the
product and not the id of the product I call it on.
 
 
 I fear you will need to more clearly describe what you mean
 with the product (on one hand) and the product I call it on
 (on the other hand).

Yes sorry I got this wrong. The sentence should be like that:

I can call this method on whatever folder inside the product instance (instance 
of the base class ZLTMS) I want, it will
always return the id of the instace of the base class (where the method is 
defined) and not the id of the object (Folder
object or File object) I call it on.

Once again:

The module that holds the base class looks like this:

__doc__=Das ist ZLMTS
__version__='0.1'

from Globals import InitializeClass, Persistent
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
from Acquisition import Implicit
from OFS.SimpleItem import SimpleItem
from OFS.PropertyManager import PropertyManager
from OFS.ObjectManager import ObjectManager
from OFS.Folder import Folder
from Lasttest import Lasttest

manage_addZLTMSForm=PageTemplateFile('zpt/manage_addZLTMSForm',globals())


def manage_addZLTMS(self,id,title='',REQUEST=None,submit=None):
Add a ZLMTS to a folder.

id=id.replace(' ','_')
#Jetzt wird das Product als Instanz erzeugt ...
zltmsObj=ZLTMS(id,title)
#... und persitiert
id=self._setObject(id, zltmsObj)
folder=getattr(self, id)
#Create a container for the Loadtests
folder.manage_addFolder(id='LoadTests',title='Collection')

#irgned ein WODOO falls jemand das PRoduct programmatisch hinzufuegt.
if REQUEST is not None:
try:
destURL=self.DestinationURL()
except:
destURL=REQUEST['URL1']

REQUEST.RESPONSE.redirect(destURL+'/manage_main')   
return ''


class ZLTMS(Lasttest,Implicit, Persistent, PropertyManager, ObjectManager, 
SimpleItem):
ZLMTS object

security = ClassSecurityInfo()
meta_type = 'ZLMTS'

manage_options = ObjectManager.manage_options + (
 {'label' : 'View', 'action' : ''},
 {'label' : 'Settings', 'action' : 
'manage_editSettingsForm'},
 ) + PropertyManager.manage_options + 
SimpleItem.manage_options

_properties=({'id':'title','type':'string','mode':'w'},
 {'id':'description','type':'text','mode':'w'},
 )


def __init__(self, id, title='', description='' ):
initialise a new instance of ZLMTS
self.id=id
self.title=title
self.description=description
self.location_types=['http','path']
self.manage_targets={'gr_sys' : {'name' : '',

 'phy_mem' : '',

 'location_sar' : '',

 'grinder_home' : '',

 'server_start_url' : ''},
 'sys1' : {'name' : '',
   
'phy_mem' : '',
   
'location_sar' : '',
   
'server_start_url' : ''}}

and so on ...
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] acquisition probleme

2005-09-16 Thread chetzacoalt


hello

I'm trying an aquisition, but I must be doing something wrong..

I'd got a setting like this :

/dir1/dir2
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Acquisition Algebra; interaction of containment and acquisition is confusing

2001-01-26 Thread Evan Simpson

From: Fred Yankowski [EMAIL PROTECTED]
 for the very last case, "a.b.c.x".  I just can't follow why the
 equivalent expression isn't

 x.__of__(a).__of__(c.__of__(b.__of__(a)))

 rather than the more complex answer given:

 x.__of__(a).__of__(b.__of__(a)).__of__(c.__of__(b.__of__(a)))

You can expand any access path into an acquisition expression using the
following 3-1/2 rules:

1. Given an unwrapped object 'x', x.child = (child o x)
2. Given a wrapper (self o parent),
  a. (self o parent).child = self.child o (self o parent) if 'child' is
found in 'self'.
  a. (self o parent).child = parent.child o (self o parent) if 'child' is
found in 'parent'.
3. Reduce ((a o b) o (b o c)) to (a o (b o c)) as soon as it appears.

So, a.b = (b o a).  a.b.c = (b o a).c = (b.c o (b o a)) = (c o (b o a)).
Finally, a.b.c.x = (c o (b o a)).x = ((b o a).x o (c o (b o a))) =
   ((a.x o (b o a)) o (c o (b o a))) = (((x o a) o (b o a)) o (c o (b o a)))

 When I run the test cases given in the document I see that the latter
 does match the behavior, but I find that baffling.  In particular, why
 is the effective search order x-a-b-c rather than x-a-c-b?  It almost
 looks like the effective search order could be described as "up
 through the containment heirarchy, then down through the remaining
 acquired path", but I'm not at all sure if that's a valid
 generalization.

Almost.  It's "up through the containment hierarchy, then the rest of it
somehow".  Trying to control or predict the exact search order for any but
the simplest acquisition trees is a dangerous game.  You can read it off
directly from the algebra form, as in (((x o a) o (b o a)) o (c o (b o a)))
= x, a, b, c (ignoring duplicates), but it's unlikely to be useful, as you
saw.

Cheers,

Evan @ digicool  4-am


___
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 Algebra; interaction of containment and acquisition is confusing

2001-01-26 Thread Fred Yankowski

Thank you for describing the transformation rules in detail.  With those
I can mechanically create the same acquisition expression that you get. 
Working some further examples with this knowledge [and how can I use
this knowledge to make mo' money?], I find that given a containment tree
like this:

  a -- b -- c
   \-- x -- y

the access path a.b.c.x.y results in a search order of (y, x, a, b, c)

Evan Simpson wrote:
 Trying to control or predict the exact search order for any but
 the simplest acquisition trees is a dangerous game.  You can read it off
 directly from the algebra form, as in (((x o a) o (b o a)) o (c o (b o a)))
 = x, a, b, c (ignoring duplicates), but it's unlikely to be useful, as you
 saw.

Now, does that bother anyone besides me?  Since acquisition is intrinsic
and ubiquitous in Zope, shouldn't we be concerned that it is hard to
control or predict?

-- 
Fred Yankowski   [EMAIL PROTECTED]  tel: +1.630.879.1312
Principal Consultant www.OntoSys.com   fax: +1.630.879.1370
OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA

___
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 Algebra; interaction of containment and acquisition is confusing

2001-01-26 Thread Evan Simpson

From: Fred Yankowski [EMAIL PROTECTED]
 Now, does that bother anyone besides me?  Since acquisition is intrinsic
 and ubiquitous in Zope, shouldn't we be concerned that it is hard to
 control or predict?

Keep in mind that it is only the *order after containment* that has this
problem. For instance, schemes to "skin" a subfolder by changing access
paths should ensure that there is always exactly one "skin" implementation
in the acquisition path.  It is tempting to provide a "default skin" in the
containment path, but then you can't override it.

Cheers,

Evan @ digicool  4-am


___
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] Acquisition Algebra; interaction of containment and acquisition is confusing

2001-01-25 Thread Fred Yankowski

Can anyone help me understand what's going on in the last example of
the main "Acquisition" document,
http://www.digicool.com/releases/ExtensionClass/Acquisition.html?
I think I understand how the various "complex expressions" relate to
the equivalent expression in terms of the '__of__' operator, except
for the very last case, "a.b.c.x".  I just can't follow why the
equivalent expression isn't

x.__of__(a).__of__(c.__of__(b.__of__(a)))

rather than the more complex answer given:

x.__of__(a).__of__(b.__of__(a)).__of__(c.__of__(b.__of__(a)))

When I run the test cases given in the document I see that the latter
does match the behavior, but I find that baffling.  In particular, why
is the effective search order x-a-b-c rather than x-a-c-b?  It almost
looks like the effective search order could be described as "up
through the containment heirarchy, then down through the remaining
acquired path", but I'm not at all sure if that's a valid
generalization.

Can anyone shed some light on this for me?

-- 
Fred Yankowski   [EMAIL PROTECTED]  tel: +1.630.879.1312
Principal Consultant www.OntoSys.com   fax: +1.630.879.1370
OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA

___
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] Acquisition loops and web robots

2001-01-11 Thread Andrews, Martin

I have run into several cases where authors at our site have accidentally
employed acquisition to link documents in such a way that an infinite tree
of URLS are possible - for example:

/a/foo contains a link to "b/bar"
/b/bar contains a link to "a/foo"

This really causes a problem with our web indexer (htdig) hits the site and
indexes pages like:

/a/b/a/b/a/b/a/b/a/b/a/b ... a/foo

Has anyone found a way to avoid these sort of problems - other then just not
indexing zope sites? I already limit htdig with the max_hop_count setting,
but that it tricky to tune correctly (and still index all valid files).

Martin

---
Martin Andrews
[EMAIL PROTECTED]

___
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: DTML Methods vs Documents

2001-01-09 Thread Oleg Broytmann

Hello!

   Many thanks to all who replied! Sorry for late answer - twas XMas
holidays in Russia (Russian Orthodox church celebrates XMas Jan 7).

On Fri, 5 Jan 2001, Rik Hoekstra wrote:
 If I call http://machine:port/top/middle/AFolder/ADocument (in terms of
  this HOWTO), and ADocument calls dtml-var AMethod, what is acquisition
  path for AMethod?

 what might come handy in your case is the howto "Shane's Aquisition
 Understander" at

  http://www.zope.org/Members/chrisw/showaq
 it'll help you visualize the acquisition path from your document.

   I used it for sometime, sure...

 You may also want to look at my howto Changing Contexts in Zope
 http://www.zope.org/Members/Hoekstra/ChangingZopeContexts

   Read and reread it many times, sure. Cannot live without it :) The thing
that I didn't understand from this (and the thing is still cloudy) is that
there is One Acquisition Path for a request. When I call a Method through
the web, I have proper path, so I can call Documents and Methods from each
other. But when I call a Document through the web, I have "wrong" path -
static path, and when I try to call a Method from the Document, the Method
will use this static path. I thought the Method will use dynamic path,
based on request (URL). That was my mistake.

 Or Jim's acquisition algebra from a Python point of view of these matters:
 http://www.zope.org/Members/jim/Info/IPC8/AcquisitionAlgebra/index.html

   Of course.

Oleg.

 Oleg Broytmann http://www.zope.org/Members/phd/ [EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.


___
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: DTML Methods vs Documents

2001-01-06 Thread Tim Cook

Oleg Broytmann wrote:

 
There are many Documents on my site, not only index_html. Should I make
 them all Methods? Why after this I need Documents at all?

The ONLY time I use a Document is, as a container for properties. 
For example a patient is seen by a doctor. The date/time, vital
signs etc. would be recorded in properties of a DTML Document.
The DTML code in the Document is used to display this information
anytime later.
(Okay, FreePM is really more complicated than that but it's the
basic idea. g)


-- Tim Cook  --
Help the new U.S. President (and your Country).
Visit http://www.petitiononline.com/sphinx84/petition.html
Censorship: The reaction of the ignorant to freedom.

___
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] Acquisition: DTML Methods vs Documents

2001-01-05 Thread Oleg Broytmann

Hello!

   Can anyone here explain clearly what is the difference between DTML
Methods and DTML Documents regarding acquisition?

   Well, in simple cases I think I understand it. When I call a Method
through the web, it use dynamic (based on current URL) acquisition path. A
Document uses static (based on its position in ZODB) path.

   But what if I want to look a bit deeper? What are acquision paths for a
Method called from a Document, not directly from the web? I beleive when a
Document called from a Method it always uses static acquisition path. But
what about a Method called from a Document? It seems my Methods stopped
using dynamic paths and use static paths, provided by its callee. Right?

   Let's see a running demo. The site http://phd.russ.ru/pcgi/TEST/
constructed as follows:

/TEST - folder
   index_html - standard DTML Document with default content
   standard_html_header - DTML Method
   standard_html_footer - DTML Method
   2 - folder, empty

Both folders /TEST and /TEST/2 have a property "foobar". In /TEST its value
is "First test!", in /TEST/2 - "This is SECOND test." standard_html_header
show the property with dtml-var foobar.

   When I call standard_html_header directly through the web, it acquires
foobar using dynamic acquisition path:

http://phd.russ.ru/pcgi/TEST/standard_html_header
   show foobar from root (/TEST)
http://phd.russ.ru/pcgi/TEST/2/standard_html_header
   show foobar from /TEST/2

But then I call standard_html_header from DTML Document index_html:

http://phd.russ.ru/pcgi/TEST/index_html
   show foobar from root (/TEST); exactly as I expected, no problem
http://phd.russ.ru/pcgi/TEST/2/index_html
   WOW! It show foobar again from root, not from /TEST/2!
standard_html_header acquires using static path provided by index_html!

   Is it normal and intended behaviour? If it is, how can I "solve" my
problem? (I want to acquire different properties in standard_html_header,
but call standard_html_header from different DTML Documents).

Oleg.

 Oleg Broytmann http://www.zope.org/Members/phd/ [EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.


___
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: DTML Methods vs Documents

2001-01-05 Thread Stephane Bortzmeyer

On Friday 5 January 2001, at 12 h 26, the keyboard of Oleg Broytmann 
[EMAIL PROTECTED] wrote:

Can anyone here explain clearly what is the difference between DTML
 Methods and DTML Documents regarding acquisition?

Not me but this HOWTO:

http://www.zope.org/Members/michel/HowTos/DTMLMethodsandDocsHowTo

saved my life.



___
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: DTML Methods vs Documents

2001-01-05 Thread Oleg Broytmann

On Fri, 5 Jan 2001, Stephane Bortzmeyer wrote:
 http://www.zope.org/Members/michel/HowTos/DTMLMethodsandDocsHowTo
 saved my life.

   Thanks. I'be read it yesterday. It does not help much because it does
not answer my question:

   If I call http://machine:port/top/middle/AFolder/ADocument (in terms of
this HOWTO), and ADocument calls dtml-var AMethod, what is acquisition
path for AMethod?

   I showed an example, where AMethod do acquisition using static path, and
I think it is a bug. Or, may be, just my misunderstanding...

Oleg.

 Oleg Broytmann http://www.zope.org/Members/phd/ [EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.


___
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: DTML Methods vs Documents

2001-01-05 Thread Oleg Broytmann

On Fri, 5 Jan 2001, Stephane Bortzmeyer wrote:
  http://phd.russ.ru/pcgi/TEST/2/index_html
 WOW! It show foobar again from root, not from /TEST/2!
  standard_html_header acquires using static path provided by index_html!

 You started acquisition from index_html. Since it has no foobar, it looked
 into its own container, /TEST, then in root.

   Exactly as I wrote - in this situation standard_html_header acquires
using static path provided by index_html :(

 You can but the "problem" in your case, comes from the acquisition of an
 index_html document in a different folder. I suggest to add index_html
 documents in every folder *or* make index_html a method (this is what I
 use).

   There are many Documents on my site, not only index_html. Should I make
them all Methods? Why after this I need Documents at all?

Oleg.

 Oleg Broytmann http://www.zope.org/Members/phd/ [EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.


___
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: DTML Methods vs Documents

2001-01-05 Thread Stephane Bortzmeyer

On Friday 5 January 2001, at 12 h 26, the keyboard of Oleg Broytmann 
[EMAIL PROTECTED] wrote:

When I call standard_html_header directly through the web, it acquires
 foobar using dynamic acquisition path:

Actually, if I understand it myself :-) it acquires foobar because a method 
has no poperties, so it looks first in the innermost container, the folder 
TEST or TEST/2.

 But then I call standard_html_header from DTML Document index_html:

In that case, you start the acquisition with the document index_html (reread 
the HOWTO http://www.zope.org/Members/michel/HowTos/DTMLMethodsandDocsHowTo: 
the acquisition can start from a document or a folder, not from a method).

 http://phd.russ.ru/pcgi/TEST/index_html
show foobar from root (/TEST); exactly as I expected, no problem
 http://phd.russ.ru/pcgi/TEST/2/index_html
WOW! It show foobar again from root, not from /TEST/2!
 standard_html_header acquires using static path provided by index_html!

You started acquisition from index_html. Since it has no foobar, it looked 
into its own container, /TEST, then in root.

Is it normal and intended behaviour? If it is, how can I "solve" my
 problem? (I want to acquire different properties in standard_html_header,
 but call standard_html_header from different DTML Documents).

You can but the "problem" in your case, comes from the acquisition of an index_html 
document in a different folder. I suggest to add index_html documents in every folder 
*or* make index_html a method (this is what I use).



___
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: DTML Methods vs Documents

2001-01-05 Thread Stephane Bortzmeyer

On Friday 5 January 2001, at 17 h 58, the keyboard of Oleg Broytmann 
[EMAIL PROTECTED] wrote:

There are many Documents on my site, not only index_html. Should I make
 them all Methods? Why after this I need Documents at all?

Because not all documents are acquired (from an above folder). For index_html, for 
instance, it is common to have a different index_html (and in that case a document) in 
each folder. 




___
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: DTML Methods vs Documents

2001-01-05 Thread Dario Lopez-Kästen

Hello!

I think hade a similar problem. It seems that you can only use methods for
acquisition, not documents.

I had an index_html DOC where I specified the structure of my site. In
index_html I used dtml-var some_doc that and in some_doc I once dtml-var
other_doc.

The idea was that in my subfolers I only needed to have the objects some_doc
and other_doc, and that I would use the structure from the index_html higher
up. This way I could provide "modules" to managers of subfolders, so they
need not to concern themselvs with the proper way of setting up their
index_html.

It didn't work unitl I changed index_html and all other objects from
dtml-docs to dtml-methods. Otherwise I would always end up with the parent
(in my case the root level) documents. I wanted to have DTML-documents in
the firts place, because I noticed that in dtml-methods the dtml-var
title_or_id call has no effect; it does not use the methods title_or_id, it
uses the toplevel (or the calling documents) title_or_id.

Is this a similar situation to yours?

/dario

- Original Message -
From: "Oleg Broytmann" [EMAIL PROTECTED]


There are many Documents on my site, not only index_html. Should I make
 them all Methods? Why after this I need Documents at all?

 Oleg.



___
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: DTML Methods vs Documents

2001-01-05 Thread Rik Hoekstra

 On Fri, 5 Jan 2001, Stephane Bortzmeyer wrote:
  http://www.zope.org/Members/michel/HowTos/DTMLMethodsandDocsHowTo
  saved my life.

Thanks. I'be read it yesterday. It does not help much because it does
 not answer my question:

If I call http://machine:port/top/middle/AFolder/ADocument (in terms of
 this HOWTO), and ADocument calls dtml-var AMethod, what is acquisition
 path for AMethod?

Oleg,

what might come handy in your case is the howto "Shane's Aquisition
Understander" at

 http://www.zope.org/Members/chrisw/showaq

it'll help you visualize the acquisition path from your document.

You may also want to look at my howto Changing Contexts in Zope
http://www.zope.org/Members/Hoekstra/ChangingZopeContexts

Or Jim's acquisition algebra from a Python point of view of these matters:

http://www.zope.org/Members/jim/Info/IPC8/AcquisitionAlgebra/index.html


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 )




Re: [Zope] Acquisition: DTML Methods vs Documents

2001-01-05 Thread Dieter Maurer

Oleg Broytmann writes:
 Can anyone here explain clearly what is the difference between DTML
  Methods and DTML Documents regarding acquisition?
I think, I gave a good answer to a similar question
in zope-dev recently -- searchable list archive.



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 )




[Zope] acquisition/acl_users/permissions: is something broken? 2e post on this pb.

2000-11-27 Thread Gilles Lavaux

Hello,


That's the second time I have this problem, I report it again because the
answer I got the last time was not 'sure' (see bottom of mail) and I would
like to have an 'definitive' explanation from some Zope guru. I hope my
explanation will be clear:

I have 3 folders for a project called 'sms':
/sms/shtmlwhich is accessible by anonymous
/sms/shtml/stationswhich is not accessible by anonymous, only by
'operator' ans stations users
/sms/adminwhich is accessible only by 'operator' user

/sms/acl_userscontains the 'operator' user with role 'sms_admin'
/sms/shtml/stations/acl_userscontains several station users
(station1, staiton2.etc...) with role 'station'

1)'operator' user has permission to access /shtml/stations. operator
authentication is forced by accessing a '/sms/admin/login' method.
2)a method 'check' is inside the '/sms/shtml' folder, this method (also)
display the http authenticated user.

My problem: I am logged in as 'operator'. Sometime, accessing
'/sms/shtml/stations/check' show me:
  -Logged in as: Anonymous User   and has role(s):Anonymous
instead of:
  -Logged in as: operator   and has role(s): sms_admin

why   (this with IE and Netscape)


I just have a guess: the 'operator' user is defined in '/sms/acl_users' and
my stationx users are defined in '/sms/shtml/stations/acl_users'.
So: is it possible that when I do my 'check' as operator, the acquisition go
to the acl_users which contains the stationx users and miss the other
acl_users folder (which is two levels above) ?
Another investigation: I am logged as operator in a new browser and have the
problem, I click on a link for a stationx user but cancel the http
authentication, then the problem disappear.

I am able to use a workarround, but I would like to understand what cause my
problem.
Is there a way to display which object has triggered the authentication, and
which acl_users folder is used??

Help please...
Thanks.

Gilles Lavaux



Last time reply by Dieter Maurer :
The security system does not use the full acquisition context but
only the containment. This is a security feature to prevent
a user with partial management rights in a subfolder to
affect permissions for objects outside its area.

I think (am not sure!) that in your case, the "protected" context
is not used as your objects are in fact outside "protected".
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 )




Re: [Zope] acquisition/acl_users/permissions: is something broken? 2e post on this pb.

2000-11-27 Thread Dieter Maurer

Gilles Lavaux writes:
  My problem: I am logged in as 'operator'. Sometime, accessing
  '/sms/shtml/stations/check' show me:
-Logged in as: Anonymous User   and has role(s):Anonymous
  instead of:
-Logged in as: operator   and has role(s): sms_admin
  
  why   (this with IE and Netscape)
Only sometimes?

Did you already recognize a pattern?

  I just have a guess: the 'operator' user is defined in '/sms/acl_users' and
  my stationx users are defined in '/sms/shtml/stations/acl_users'.
  So: is it possible that when I do my 'check' as operator, the acquisition go
  to the acl_users which contains the stationx users and miss the other
  acl_users folder (which is two levels above) ?
A user folder is only allowed to return "Annonymous", if
it is the top level user folder.

Thus, your "/sms/shtml/statios/acl_users" must return "None"
and ZPublisher should ask "/sms/acl_users" which should return
"Operator".

  Another investigation: I am logged as operator in a new browser and have the
  problem, I click on a link for a stationx user but cancel the http
  authentication, then the problem disappear.
Hmmh, the only difference should be that you no longer have
an HTTP authentication. I do not understand this behaviour.

  Is there a way to display which object has triggered the authentication, and
  which acl_users folder is used??
You can instrument the code in "ZPublisher.BaseRequest.traverse"
to output this information.


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 )




[Zope] Acquisition beahviour ... static/shared vs local instance

2000-11-08 Thread Matt

This is more a philosophical question about what is the better way to
organize a Zope utility.  The feeling of acquisition is a nice one, and
is a joy to program with, but there seems to be one scenario that
troubles me a little.  Am I correct in assuming that objects and their
properties(if they are allowed them) are static, or shared in their
nature.  I.e. : 2 people accessing the same object at the same time are
sharing that object, and therefore can potentially collide if they both
are able to execute a method that changes this object, say a property
such as language.  To overcome this I reorganized things such that
shared objects could only have constant like properties that only a
manager can change and then created a session object, which is just a
rather boring ZClass that can hold onto session variables so that I
don't have to keep passing them around as form variables, since this is
the interface that the public user has.  Maybe this is not the right way
to do it, maybe there are better ways of letting someone move around
with session variables.  I thought perhaps cookies would be a better
thing, except that people can turn these off.

The next problem then is that it is easy enough getting people to login
through a particular node so that I can set a sheet up for them before
redirecting them to another part of the Zope environment, but there is
no way to ensure they have to log out so that I can throw the sheet
away.  Hmm, yes cookies sound better.  The more important point is that
I have used methods in their fullest sense of acquisition ... I use
redirects to activate a method in the correct part of the Zope
environment so that it acquires what it needs and creates instances of
various ZClasses as required.  These methods are obviously reasonably
close to root of the hierarchy, just so they can be thrown to many
places.  I want to be able to restrict where these can be thrown to stop
people playing around with their own urls and creating bad objects in
the wrong places.

Anyone have any thoughts on these problems?

regards
Matt Bion


___
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] 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?

Thanx,
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 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 )




Re: [Zope] acquisition vs. inheritance

2000-08-04 Thread Chris Withers

Jonothan Farr wrote:
 
  Is it possible to have just one top level object that refers to
  other objects that get overridden as you go into other folders?
 
 Acquisition works the other way around. You can create objects in subfolders
 whose contents are overriden higher up. You can't have an object at the top
 whose contents get overridden as you go down.

Urm, I think wires are getting crossed here, so here's an example which
may help (and which we use on most of our sites):

index_html is a DTML method:

dtml-var standard_html_header
dtml-var index.html
dtml-var standard_html_footer

Now, in each folder we have DTML documents called index.html which
actually contain the pages.

So, we have one index_html and many index.html's.

When someone does http://www.mysite.com/folder/
This actually renders http://www.mysite.com/folder/index_html
Then, index_html is acquired from the root.
However, because index.html exists is /folder, it is that which is
displayed.

I hope this makes it a little clearer :S

cheers,

Chris

PS:
 Your solution was correct. Create another index_html in the subfolder, 

As long as index_html is a method, you only need one of them, in the
root.

 which
 uses the 'contents' object in the subfolder, 

This will still happen if there's only one index_html

___
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 vs. inheritance

2000-08-04 Thread Jonothan Farr

Dang! Just when I think I understand this acquisition thing. ;)

Sorry for the misinformation.

--jfarr

"Perl is worse than Python because people wanted it worse."
Larry Wall, 14 Oct 1998

- Original Message -
From: Chris Withers [EMAIL PROTECTED]
To: Jonothan Farr [EMAIL PROTECTED]
Cc: Bob Horvath [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, August 04, 2000 1:54 AM
Subject: Re: [Zope] acquisition vs. inheritance


 Jonothan Farr wrote:
 
   Is it possible to have just one top level object that refers to
   other objects that get overridden as you go into other folders?
 
  Acquisition works the other way around. You can create objects in subfolders
  whose contents are overriden higher up. You can't have an object at the top
  whose contents get overridden as you go down.

 Urm, I think wires are getting crossed here, so here's an example which
 may help (and which we use on most of our sites):

 index_html is a DTML method:

 dtml-var standard_html_header
 dtml-var index.html
 dtml-var standard_html_footer

 Now, in each folder we have DTML documents called index.html which
 actually contain the pages.

 So, we have one index_html and many index.html's.

 When someone does http://www.mysite.com/folder/
 This actually renders http://www.mysite.com/folder/index_html
 Then, index_html is acquired from the root.
 However, because index.html exists is /folder, it is that which is
 displayed.

 I hope this makes it a little clearer :S

 cheers,

 Chris

 PS:
  Your solution was correct. Create another index_html in the subfolder,

 As long as index_html is a method, you only need one of them, in the
 root.

  which
  uses the 'contents' object in the subfolder,

 This will still happen if there's only one index_html



___
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] acquisition vs. inheritance

2000-08-03 Thread Bob Horvath


I am slowly getting the hang of Zope, but am confused about
something.

Either I don't understand how acquisition works, or there is
something special about how index_html is treated.

I had a folder with a index_html that had something like:

dtml-var standard_html_header
dtml-var content
dtml-var standard_html_footer

Then in the top level folder, I had a "content" object that
I filled in with text.

In a subfolder, I created a content object, but it didn't seem to
override the upper layer one unless I copied down a copy of
index_html.

I would have thought it would have gone up a layer for index_html,

but then would have discovered content at the lower layer.

It seems this would be very powerful, but I am guessing there is a

good reason.  I wondered why standard_html_header and
standard_html_footer seemed to be used everywhere, but I am
starting to see, I think why.

Is it possible to have just one top level object that refers to
other objects that get overridden as you go into other folders?




___
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 vs. inheritance

2000-08-03 Thread Chris Withers

Bob Horvath wrote:
 I would have thought it would have gone up a layer for index_html,
 
 but then would have discovered content at the lower layer.

Sounds like your index_html is a DTML Document when it should be a DTML
method...

cheers,

Chris

___
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 vs. inheritance

2000-08-03 Thread Jonothan Farr

 Is it possible to have just one top level object that refers to
 other objects that get overridden as you go into other folders?

Acquisition works the other way around. You can create objects in subfolders
whose contents are overriden higher up. You can't have an object at the top
whose contents get overridden as you go down.

Your solution was correct. Create another index_html in the subfolder, which
uses the 'contents' object in the subfolder, but the standard_html_header and
standard_html_footer from the parent folder.

--jfarr

"Perl is worse than Python because people wanted it worse."
Larry Wall, 14 Oct 1998



___
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 problems?

2000-07-13 Thread Stephen Harrison

Curtis Maloney wrote:
 
[snip]
 
 Well, here's the details:
 
 /
  standard_html_header
  register
 /internal/
 standard_html_header
 
 register works fine if invoked as  /register
 however, it spits the dummy if invoked as /internal/register
 Complaining loudly about TypeError: too many arguments; expected 2, got 3
 in standard_html_header.

Is register a method, or a document?  If it is a method the when you
call /internal/register you are calling the object internal with the
method register, so when it looks for standard_html_header it will first
look in internal, before doing the acquisition thing.  So it finds
internal/standard_html_header.  If it is a document, then you are
calling the object /register, in the context of internal, but the
containment of / so you get /standard_html_header.

In algebra terms, if register is a method, you have

(internal o /)

but if register is a document (or folder, or other object) you have

((register o /) o (internal o /))

This is how acquisition (simple acquisition) behaves.

Of course, I am strongly of the opinion that this method of acquisition
is of very limited use and zope should really use natural acquisition
(see http://www.zope.org/Wikis/zope-dev/AcquisitionUsage for a
definition).

The problem with acquisition as it currently is is that you can't use
the example you have above to do something useful.  You can't have a
default site which you can then flavour, or skin, by adding an
overriding object high up in the context tree.

Example:

/register is the standard way of presenting the register page.

But, for internal use, you want it to look different, so you create
/internal, which replaces some of the methods (like
standard_html_header).

You should then be able to call /internal/register and see register in
the _context_ of internal, which is what is important.  The containment
of an object is only useful from an administrative point of view.  The
thing which is important is the _context_ in which the object is called.

As it is, in order to achieve the result described above you have to
carefully construct your site in order to work around the problems with
acquisition, which really isn't the way we should be doing things.

Sorry to go on about this, but as time passes I am becomming more and
more convinced that the method of acquisition needs to change from
containment before context to context before containment.

I have yet to think of any advantages provided by the current method,
but I would be more than happy to hear of any.

For reference, here a more general post on the problem I sent to the
list a while ago:

http://zope.nipltd.com/public/lists/zope-archive.nsf/ByKey/61727C8A78322A51

and here is a summary of the problem in the dev wiki:

http://www.zope.org/Wikis/zope-dev/AcquisitionFeedback

Cheers,
Stephen

-- 
Stephen Harrison[EMAIL PROTECTED]
New Information Paradigms   www.nipltd.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 problems?

2000-07-13 Thread Curtis Maloney

On Thu, 13 Jul 2000, Stephen Harrison wrote:
 Curtis Maloney wrote:

 [snip]

  Well, here's the details:
 
  /
   standard_html_header
   register
  /internal/
  standard_html_header
 
  register works fine if invoked as  /register
  however, it spits the dummy if invoked as /internal/register
  Complaining loudly about TypeError: too many arguments; expected 2, got 3
  in standard_html_header.

 Is register a method, or a document?  If it is a method the when you

It is a document.

 call /internal/register you are calling the object internal with the
 method register, so when it looks for standard_html_header it will first
 look in internal, before doing the acquisition thing.  So it finds
 internal/standard_html_header.  If it is a document, then you are
 calling the object /register, in the context of internal, but the
 containment of / so you get /standard_html_header.

Yes, well.. This is what I worked out from the Acquisition Algebra tute, and 
from MP, but this is not what the actions of the site suggest.  When I 
modified /internal/standard_html_header, the actions of register as 
/internal/register changed.  This is what has me so confused.

That, and the fact the page give an error at all, when it works frine as 
/register.

 In algebra terms, if register is a method, you have

 (internal o /)

 but if register is a document (or folder, or other object) you have

 ((register o /) o (internal o /))

 This is how acquisition (simple acquisition) behaves.

 Of course, I am strongly of the opinion that this method of acquisition
 is of very limited use and zope should really use natural acquisition
 (see http://www.zope.org/Wikis/zope-dev/AcquisitionUsage for a
 definition).

[snip]

 As it is, in order to achieve the result described above you have to
 carefully construct your site in order to work around the problems with
 acquisition, which really isn't the way we should be doing things.

Well, it just so happens this is what I'm doing next.  (o8
I was handed this site to "fix", which has taken a lot of work.  However, 
rewriting it properly would have taken longer, and the project was already 
overdue.


 Sorry to go on about this, but as time passes I am becomming more and
 more convinced that the method of acquisition needs to change from
 containment before context to context before containment.

Rant away, please.  I believe it can be a great way to provoke ideas in other 
people.  Besides, if we never complained, how would they know there was a 
problem? (o8

 I have yet to think of any advantages provided by the current method,
 but I would be more than happy to hear of any.

 Cheers,
 Stephen

Thanks for trying,
Curtis.

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