Re: [Zope] proxy role for an external method

2005-10-11 Thread Reinoud van Leeuwen
On Tue, Oct 11, 2005 at 07:29:27AM +0100, Chris Withers wrote:
> Reinoud van Leeuwen wrote:
> >On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:
> >
> >>Are you using CMF/Plone?
> >
> >
> >yes. the main part of the function is:
> >
> >   for brain in self.portal_catalog(portal_type='User',
> >SearchableText=SearchableText):
> >user = brain.getObject()
> >if user is None:
> >continue
> >results.append(getUserInfo(user))
> >
> >This works in a pyhton script but not in an external one
> 
> At this point I'd recommend my SainBrains product:
> http://www.simplistix.co.uk/software/zope/sanebrains
> 
> Then, change your user = line to:
> 
> user = brain._unrestrictedGetObject()

That is exactly what I need! Thanks!

I'll clean up the code and paste it here this afternoon so a working 
solution ends up in the archives. (I hate it to find discussions on google 
without the final solution to the problem ";-)
 

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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] proxy role for an external method

2005-10-11 Thread Chris Withers

Reinoud van Leeuwen wrote:

On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:


Are you using CMF/Plone?



yes. the main part of the function is:

   for brain in self.portal_catalog(portal_type='User',
SearchableText=SearchableText):
user = brain.getObject()
if user is None:
continue
results.append(getUserInfo(user))

This works in a pyhton script but not in an external one


At this point I'd recommend my SainBrains product:
http://www.simplistix.co.uk/software/zope/sanebrains

Then, change your user = line to:

user = brain._unrestrictedGetObject()

cheers,

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] proxy role for an external method

2005-10-10 Thread Jens Vagelpohl


On 10 Oct 2005, at 23:14, Peter Bengtsson wrote:

I understood that Plone does some extra magic, so I have to setup a
securoty context... I'll post it here if I have a working solution



Shouldn't really be the problem. Isn't portal_catalog just another
ZCatalog that has nothing to do with Plone except it's located inside
a Plone instance.


It *is* a problem. The reason is most likiely all the extra stuff the  
catalog tool adds to the query before it reaches the actual catalog.  
The workaround is something like this:


from Products.ZCatalog.ZCatalog import ZCatalog
results = ZCatalog.searchResults(portal_catalog, **kws)

That way you circumvent any query munging done in the catalog tool  
searchResults method, specifically the effective/expires and  
allowedRolesAndUsers filtering.


jens

___
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] proxy role for an external method

2005-10-10 Thread Peter Bengtsson
2005/10/10, Reinoud van Leeuwen <[EMAIL PROTECTED]>:
> On Mon, Oct 10, 2005 at 10:57:25PM +0100, Peter Bengtsson wrote:
> > 2005/10/10, Reinoud van Leeuwen <[EMAIL PROTECTED]>:
> > > On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:
> > > > Are you using CMF/Plone?
> > >
> > > yes. the main part of the function is:
> > >
> > >for brain in self.portal_catalog(portal_type='User',
> > > SearchableText=SearchableText):
> > > user = brain.getObject()
> > > if user is None:
> > > continue
> > > results.append(getUserInfo(user))
> > >
> > > This works in a pyhton script but not in an external one
> > >
> >
> > I find this hard to believe. But, for the External Method you might
> > need to allow Anonymous to View it if it's at all protected.
>
> Done that
> > What's the output when you do it via xmlrpc? Is it [] or error?
> []

Can you then debug wether it that's because portal_catalog(**kws)
doesn't return anything or because brain.getObject() constantly
returns None?

>
> I understood that Plone does some extra magic, so I have to setup a
> securoty context... I'll post it here if I have a working solution
>
Shouldn't really be the problem. Isn't portal_catalog just another
ZCatalog that has nothing to do with Plone except it's located inside
a Plone instance.

> --
> __
> "Nothing is as subjective as reality"
> Reinoud van Leeuwen[EMAIL PROTECTED]
> http://www.xs4all.nl/~reinoud
> __
> ___
> 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 )


Re: [Zope] proxy role for an external method

2005-10-10 Thread Reinoud van Leeuwen
On Mon, Oct 10, 2005 at 10:57:25PM +0100, Peter Bengtsson wrote:
> 2005/10/10, Reinoud van Leeuwen <[EMAIL PROTECTED]>:
> > On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:
> > > Are you using CMF/Plone?
> >
> > yes. the main part of the function is:
> >
> >for brain in self.portal_catalog(portal_type='User',
> > SearchableText=SearchableText):
> > user = brain.getObject()
> > if user is None:
> > continue
> > results.append(getUserInfo(user))
> >
> > This works in a pyhton script but not in an external one
> >
> 
> I find this hard to believe. But, for the External Method you might
> need to allow Anonymous to View it if it's at all protected.

Done that 
> What's the output when you do it via xmlrpc? Is it [] or error?
[]

I understood that Plone does some extra magic, so I have to setup a 
securoty context... I'll post it here if I have a working solution

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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] proxy role for an external method

2005-10-10 Thread Peter Bengtsson
2005/10/10, Reinoud van Leeuwen <[EMAIL PROTECTED]>:
> On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:
> > Are you using CMF/Plone?
>
> yes. the main part of the function is:
>
>for brain in self.portal_catalog(portal_type='User',
> SearchableText=SearchableText):
> user = brain.getObject()
> if user is None:
> continue
> results.append(getUserInfo(user))
>
> This works in a pyhton script but not in an external one
>

I find this hard to believe. But, for the External Method you might
need to allow Anonymous to View it if it's at all protected.
What's the output when you do it via xmlrpc? Is it [] or error?


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


Re: [Zope] proxy role for an external method

2005-10-10 Thread Andreas Jung



--On 10. Oktober 2005 20:00:23 +0200 Reinoud van Leeuwen 
<[EMAIL PROTECTED]> wrote:



But really searching for something through xmlrpc does not work. If I
copy  & paste the code in an (ZODB) Python script which I give the
Authenticated  proxy role it works perfect.



Nonsense. Your problem has nothing to do with proxy roles since Plone 
modifies your query. You can also try to send and XMLRPC using basic 
authentication.


-aj

pgplG8joVeEUo.pgp
Description: 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] proxy role for an external method

2005-10-10 Thread Reinoud van Leeuwen
On Tue, Oct 11, 2005 at 03:42:44AM +1000, Alan Milligan wrote:

> > yes. I I run the script from the ZMI logged in as admin it finds members, 
> > but if I try it from an XMLRPC client it does not
> > 
> You're sure you haven't got an access control problem and that your
> xml-rpc client is not running up as Anonymous?

Yes the client is not loggin in. (and since it will be a commandline 
script it is not supposed to do).

If I hardcode some bogus data to be returned it works fine. But as soon 
as something in the catalog is searched it does not work. So the xmlrpc 
works.
If I run the script from the browser (with default parameters) logged in 
as Manager it works. So the functionality works.

But really searching for something through xmlrpc does not work. If I copy 
& paste the code in an (ZODB) Python script which I give the Authenticated 
proxy role it works perfect.

So I suspect the conclusion is that the external method lacks that proxy 
role

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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] proxy role for an external method

2005-10-10 Thread Reinoud van Leeuwen
On Mon, Oct 10, 2005 at 07:27:11PM +0200, Andreas Jung wrote:
> Are you using CMF/Plone?

yes. the main part of the function is:

   for brain in self.portal_catalog(portal_type='User',
SearchableText=SearchableText):
user = brain.getObject()
if user is None:
continue
results.append(getUserInfo(user))

This works in a pyhton script but not in an external one

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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] proxy role for an external method

2005-10-10 Thread Andreas Jung

Are you using CMF/Plone?

-aj

--On 10. Oktober 2005 19:18:00 +0200 Reinoud van Leeuwen 
<[EMAIL PROTECTED]> wrote:



On Mon, Oct 10, 2005 at 05:06:22PM +0100, Jens Vagelpohl wrote:


On 10 Oct 2005, at 16:49, Reinoud van Leeuwen wrote:
> I would like to convert this script to an Exteral Method in
> $INSTANCE_HOME/Extensions. This basically works, but I cannot see
> any way
> to specify the proxy role. And when it is not specified the script
> obviously does not work.

Have you *tried* that? External methods don't need proxy roles. They
are "trusted code".


yes. I I run the script from the ZMI logged in as admin it finds members,
but if I try it from an XMLRPC client it does not

--
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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 )






pgpzAkMrzjRxx.pgp
Description: 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] proxy role for an external method

2005-10-10 Thread Reinoud van Leeuwen
On Mon, Oct 10, 2005 at 05:06:22PM +0100, Jens Vagelpohl wrote:
> 
> On 10 Oct 2005, at 16:49, Reinoud van Leeuwen wrote:
> >I would like to convert this script to an Exteral Method in
> >$INSTANCE_HOME/Extensions. This basically works, but I cannot see  
> >any way
> >to specify the proxy role. And when it is not specified the script
> >obviously does not work.
> 
> Have you *tried* that? External methods don't need proxy roles. They  
> are "trusted code".

yes. I I run the script from the ZMI logged in as admin it finds members, 
but if I try it from an XMLRPC client it does not

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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] proxy role for an external method

2005-10-10 Thread Andreas Jung



--On 10. Oktober 2005 17:49:20 +0200 Reinoud van Leeuwen 
<[EMAIL PROTECTED]> wrote:





I would like to convert this script to an Exteral Method in
$INSTANCE_HOME/Extensions. This basically works, but I cannot see any way
to specify the proxy role. And when it is not specified the script
obviously does not work.



ExternaMethod run without restriction so there is usually to need for proxy 
roles (there are no proxy roles) for ExternalMethods.


-aj




pgpwB668eu9Pm.pgp
Description: 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] proxy role for an external method

2005-10-10 Thread Jens Vagelpohl


On 10 Oct 2005, at 16:49, Reinoud van Leeuwen wrote:

I would like to convert this script to an Exteral Method in
$INSTANCE_HOME/Extensions. This basically works, but I cannot see  
any way

to specify the proxy role. And when it is not specified the script
obviously does not work.


Have you *tried* that? External methods don't need proxy roles. They  
are "trusted code".


jens

___
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] proxy role for an external method

2005-10-10 Thread Reinoud van Leeuwen
Hi,

I have a working pyhton script in the ZODB that searches for members and 
is called by a xmlrpc client. Security is only needed based on source IP 
address, so Anonymous can execute it, but the script has an Authenticated 
proxy role.

I would like to convert this script to an Exteral Method in 
$INSTANCE_HOME/Extensions. This basically works, but I cannot see any way 
to specify the proxy role. And when it is not specified the script 
obviously does not work.

After some googling, I tried to make a .metadata file with:
[default]
proxy=Authenticicated

But that does not seem to work...

- Is the .metadata supported for external methods?
- Is there another way to set proxy roles in external methods?

TIA,

-- 
__
"Nothing is as subjective as reality"
Reinoud van Leeuwen[EMAIL PROTECTED]
http://www.xs4all.nl/~reinoud
__
___
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 )