Re: [Zope] context.user at ImplPython.py
Please keep the mailing list in the loop, others may have insights too. On 23. mar. 2007, at 15.37, Garito wrote:
If you read the link I put, you could read I can create (with CrearFuncionalidad) but not delete it (with BorrarFuncionalidad) that seems to have the same security necessities
Return a callable from your traverser (so return the __call__, don't call it yourself). The publisher will call it for you after the user has been authenticated.
As Dieter said __bobo_traverse__ can't return strings or ints for that I create (as he tall me, thanks again) a wrapper that returns the rendered code
Fine, that's what I ment. But your wrapper should implement a __call__ method. The publisher will call that method at a time where security *has* been set up. Do make sure that you wrap your wrapper in the correct security context though: class Wrapper(Acquisition.Implicit): def __call__(self): # Things that need a security context need to be done here. return getSecurityManager().getAuthenticatedUser().getId() class SomeItem(SimpleItem): def __bobo_traverse__(self, REQUEST, name): if name == 'Wrapper': return Wrapper().__of__(self) else: return getattr(self, name) This way the security policies can still look up the security context. -- Martijn Pieters
I don't know if I understand what you say This is the code of one of my wrappers (str one): class WrapperStr(str): """ """ __roles__ = None def __bobo_traverse__(self, REQUEST, nombre): obj = getattr(self, nombre, None) if obj is None: return self else: return obj How could be the __call__? like: def __call__(self): return <what to return here?> Thanks! 2007/3/23, Martijn Pieters <mj@zopatista.com>:
Please keep the mailing list in the loop, others may have insights too.
On 23. mar. 2007, at 15.37, Garito wrote:
If you read the link I put, you could read I can create (with CrearFuncionalidad) but not delete it (with BorrarFuncionalidad) that seems to have the same security necessities
Return a callable from your traverser (so return the __call__, don't call it yourself). The publisher will call it for you after the user has been authenticated.
As Dieter said __bobo_traverse__ can't return strings or ints for that I create (as he tall me, thanks again) a wrapper that returns the rendered code
Fine, that's what I ment. But your wrapper should implement a __call__ method. The publisher will call that method at a time where security *has* been set up.
Do make sure that you wrap your wrapper in the correct security context though:
class Wrapper(Acquisition.Implicit): def __call__(self): # Things that need a security context need to be done here. return getSecurityManager().getAuthenticatedUser().getId()
class SomeItem(SimpleItem): def __bobo_traverse__(self, REQUEST, name): if name == 'Wrapper': return Wrapper().__of__(self) else: return getattr(self, name)
This way the security policies can still look up the security context.
-- Martijn Pieters
-- Mis Cosas http://blogs.sistes.net/Garito
On 3/23/07, Garito <garito@sistes.net> wrote:
I don't know if I understand what you say This is the code of one of my wrappers (str one):
class WrapperStr(str): """ """ __roles__ = None
def __bobo_traverse__(self, REQUEST, nombre): obj = getattr(self, nombre, None) if obj is None: return self else: return obj
What kind of object is obj? It should probably be acquisition wrapped (return obj.__of__(self).
How could be the __call__? like:
def __call__(self): return <what to return here?>
The object returned from __bobo_traverse__ will be called by the publisher, so *it* needs to implement __call__, but index_html and __str__ may also do. -- Martijn Pieters
Wow! Now I' more confused than before I create WrapperStr class because the __bobo_traverse__ of my product has problems to return a str But when I try to use it it has an error (I don't remember what, sorry) that dissapears when I create the wrapper's __bobo_traverse__. I copy the behavior from my product's __bobo_traverse__ (I don't know so much what I'm doing I confess) Then my wrapper is an intuitive wrapper Can you lighten about how need to construct a good wrapper? Thanks! 2007/3/23, Martijn Pieters <mj@zopatista.com>:
On 3/23/07, Garito <garito@sistes.net> wrote:
I don't know if I understand what you say This is the code of one of my wrappers (str one):
class WrapperStr(str): """ """ __roles__ = None
def __bobo_traverse__(self, REQUEST, nombre): obj = getattr(self, nombre, None) if obj is None: return self else: return obj
What kind of object is obj? It should probably be acquisition wrapped (return obj.__of__(self).
How could be the __call__? like:
def __call__(self): return <what to return here?>
The object returned from __bobo_traverse__ will be called by the publisher, so *it* needs to implement __call__, but index_html and __str__ may also do.
-- Martijn Pieters
-- Mis Cosas http://blogs.sistes.net/Garito
On 3/23/07, Garito <garito@sistes.net> wrote:
But when I try to use it it has an error (I don't remember what, sorry) that dissapears when I create the wrapper's __bobo_traverse__. I copy the behavior from my product's __bobo_traverse__ (I don't know so much what I'm doing I confess)
Then my wrapper is an intuitive wrapper
We are getting beyond mailing list support capabilities then, at least for me. Hacking about with __bobo_traverse__ and such requires a certain level of insight into the Zope publishing mechanisms that you seem to lack, and take some time to explain. I am not familiar with the contents of Zope books here, so I can't directly recommend anything here either. -- Martijn Pieters
Thanks Martijn! I think if I'm not familiar with zope book I can't program what I'm programming But, no problem I try and try to find a solution to my problem Thanks for your clues!!!! 2007/3/23, Martijn Pieters <mj@zopatista.com>:
On 3/23/07, Garito <garito@sistes.net> wrote:
But when I try to use it it has an error (I don't remember what, sorry) that dissapears when I create the wrapper's __bobo_traverse__. I copy the behavior from my product's __bobo_traverse__ (I don't know so much what I'm doing I confess)
Then my wrapper is an intuitive wrapper
We are getting beyond mailing list support capabilities then, at least for me. Hacking about with __bobo_traverse__ and such requires a certain level of insight into the Zope publishing mechanisms that you seem to lack, and take some time to explain.
I am not familiar with the contents of Zope books here, so I can't directly recommend anything here either.
-- Martijn Pieters
-- Mis Cosas http://blogs.sistes.net/Garito
Do you refer something like this?: class WrapperUnicode(unicode): """ """ __roles__ = None def __init__(self, cadena): self.cadena = cadena def __bobo_traverse__(self, REQUEST, nombre): obj = getattr(self, nombre, None) if obj is None: return self else: return obj.__of__(self) def __call__(self): return self.cadena def __str__(self): return str(self.cadena.decode('latin-1')) 2007/3/23, Garito <garito@sistes.net>:
Thanks Martijn! I think if I'm not familiar with zope book I can't program what I'm programming
But, no problem
I try and try to find a solution to my problem
Thanks for your clues!!!!
2007/3/23, Martijn Pieters <mj@zopatista.com>:
On 3/23/07, Garito <garito@sistes.net> wrote:
But when I try to use it it has an error (I don't remember what, sorry) that dissapears when I create the wrapper's __bobo_traverse__. I copy the behavior from my product's __bobo_traverse__ (I don't know so much what I'm doing I confess)
Then my wrapper is an intuitive wrapper
We are getting beyond mailing list support capabilities then, at least for me. Hacking about with __bobo_traverse__ and such requires a certain level of insight into the Zope publishing mechanisms that you seem to lack, and take some time to explain.
I am not familiar with the contents of Zope books here, so I can't directly recommend anything here either.
-- Martijn Pieters
-- Mis Cosas http://blogs.sistes.net/Garito
-- Mis Cosas http://blogs.sistes.net/Garito
participants (2)
-
Garito -
Martijn Pieters