Hi all Does anyone know how I can "be someone" besides Anonymous when debugging Zope? This works: """ In [80]: Zope.debug('/fab/materials/invokeFactory?type_name=Material&id=test2', u='user:secret', ) ____________________________________________________________ Status: 302 Moved Temporarily X-Powered-By: Zope (www.zope.org), Python (www.python.org) Content-Length: 5 Content-Type: text/plain Location: http://localhost/Zope/fab/materials/test2/base_edit test2 """ But I want to do stuff like: """ In [83]: at = app.fab.materials.invokeFactory('Material', 'test3') [...] Unauthorized: Your user account is defined outside the context of the object being accessed. Access to 'addMaterial' of (__FactoryDispatcher__ instance at 41c540d0) denied. Your user account, jean, exists at /acl_users. Access requires Fabrinox__Add_Materials_Permission, granted to the following roles: ['Manager']. """ Hey! I'm not Anonymous! :) It still doesn't work though. Without that Zope.debug call I would've got """ Unauthorized: Your user account does not have the required permission. Access to 'addMaterial' of (__FactoryDispatcher__ instance at 419f0a00) denied. Your user account, Anonymous User, exists at (unknown). Access requires Fabrinox__Add_Materials_Permission, granted to the following roles: ['Manager']. Your roles in this context are ['Anonymous']. """ Hmmm, now does anyone know how I can get hold of that user object so that I can try and make it __of__(portal)? -- Jean Jordaan http://www.upfrontsystems.co.za
Jean Jordaan wrote:
Hi all
Does anyone know how I can "be someone" besides Anonymous when debugging Zope? This works:
""" In [80]: Zope.debug('/fab/materials/invokeFactory?type_name=Material&id=test2', u='user:secret', )
____________________________________________________________
Status: 302 Moved Temporarily X-Powered-By: Zope (www.zope.org), Python (www.python.org) Content-Length: 5 Content-Type: text/plain Location: http://localhost/Zope/fab/materials/test2/base_edit
test2 """
But I want to do stuff like:
""" In [83]: at = app.fab.materials.invokeFactory('Material', 'test3') [...] Unauthorized: Your user account is defined outside the context of the object being accessed. Access to 'addMaterial' of (__FactoryDispatcher__ instance at 41c540d0) denied. Your user account, jean, exists at /acl_users. Access requires Fabrinox__Add_Materials_Permission, granted to the following roles: ['Manager']. """
Hey! I'm not Anonymous! :) It still doesn't work though. Without that Zope.debug call I would've got
""" Unauthorized: Your user account does not have the required permission. Access to 'addMaterial' of (__FactoryDispatcher__ instance at 419f0a00) denied. Your user account, Anonymous User, exists at (unknown). Access requires Fabrinox__Add_Materials_Permission, granted to the following roles: ['Manager']. Your roles in this context are ['Anonymous']. """
Hmmm, now does anyone know how I can get hold of that user object so that I can try and make it __of__(portal)?
Look at Products.CMFCore.tests.base.testcase.SecurityTest.setUp. Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
On Oct 4, 2004, at 17:24, Jean Jordaan wrote:
Hi all
Does anyone know how I can "be someone" besides Anonymous when debugging Zope? This works:
You could do something like... (untested and from memory!)
from AccessControl.SecurityManagement import newSecurityManager desired_user = app.acl_users.getUser('desired_user') newSecurityManager(desired_user) <now do whatever you want as desired_user>
jens
On Mon, Oct 04, 2004 at 06:24:59PM +0200, Jean Jordaan wrote:
Hmmm, now does anyone know how I can get hold of that user object so that I can try and make it __of__(portal)?
Something like this:
from AccessControl.SecurityManagement import newSecurityManager user = portal.acl_users.getUser('joebob').__of__(portal.acl_users) newSecurityManager(None, user) getSecurityManager().getUser() # just to verify it. joebob
-- Paul Winkler http://www.slinkp.com
Jean Jordaan wrote:
Does anyone know how I can "be someone" besides Anonymous when debugging Zope?
Here are two examples of authenticating in the debug interface: http://cms.athabascau.ca/webunit/cms_tips/howto_debug/view http://plone.org/documentation/archetypes/wiki/BulkLoadContent You're looking for the 'newSecurityManager' stuff. Once you've done it, it would be nice to write it up on zope.org (a HOWTO) and/or zopelabs. Filing a bug to get this into the Zope source in doc/DEBUGGING.txt would be good too. As you've noticed, this info is hard to find at the moment. --jcc
Thank you, Jens, Paul, and JCC :)
Once you've done it, it would be nice to write it up on zope.org (a HOWTO) and/or zopelabs.
How about this: http://www.zopewiki.org/DebuggingZopeWithPythonDebugger ? Looks like this has some good stuff http://plone.org/documentation/archetypes/wiki/BulkLoadContent but there's things I don't understand yet. In [47]: from Testing.makerequest import makerequest In [48]: app Out[49]: <Application instance at 4115be30> In [50]: app.REQUEST Out[51]: '<Special Object Used to Force Acquisition>' In [52]: app = makerequest(app) In [53]: app.REQUEST Out[54]: <HTTPRequest, URL=http://foo> # Oooh, *looks* cool .. In [56]: app.fab.ma # I hit <TAB> and it hangs ..
Filing a bug to get this into the Zope source in doc/DEBUGGING.txt would be good too.
I'll try & remember .. -- Jean Jordaan http://www.upfrontsystems.co.za
How about this: http://www.zopewiki.org/DebuggingZopeWithPythonDebugger ?
Looks like someone's editing it .. I see there are some RST glitches. You wanna fix it, or shall I? -- Jean Jordaan http://www.upfrontsystems.co.za
On Mon, Oct 04, 2004 at 02:26:11PM -0500, J Cameron Cooper wrote:
Jean Jordaan wrote:
Does anyone know how I can "be someone" besides Anonymous when debugging Zope?
Here are two examples of authenticating in the debug interface:
http://cms.athabascau.ca/webunit/cms_tips/howto_debug/view http://plone.org/documentation/archetypes/wiki/BulkLoadContent
You're looking for the 'newSecurityManager' stuff.
Once you've done it, it would be nice to write it up on zope.org (a HOWTO) and/or zopelabs.
I have a zopelabs recipe that shows this. zopelabs appears to be down for the past couple days, so I can't dig up the URL. -- Paul Winkler http://www.slinkp.com
Hi, I'm trying to create a generic python script in Zope that will translate any SQL query into a dictionary. I've got it working when I put in the name of a specifc SQL query name, but I can't figure out the syntax/function to take a string that contains the ZSQL method name and use it in the code like I have below (which produces attribute errors): columns=2 # the number of columns needed query = "sql_getMySQL()" myObject = getattr(context,query) qresults=context.myObject.dictionaries() # this is done to get a real list return [qresults[index:index+columns] for index in range(0,len(qresults),columns)] Any suggestions? Duane
Appologies - forgot to change the subject line so this is offtopic for the thread - ignore and I'll repost. Duane On Tue, 5 Oct 2004 13:35:44 +0100, Duane Raymond <duane.raymond@gmail.com> wrote:
Hi,
I'm trying to create a generic python script in Zope that will translate any SQL query into a dictionary. I've got it working when I put in the name of a specifc SQL query name, but I can't figure out the syntax/function to take a string that contains the ZSQL method name and use it in the code like I have below (which produces attribute errors):
columns=2 # the number of columns needed query = "sql_getMySQL()" myObject = getattr(context,query)
qresults=context.myObject.dictionaries() # this is done to get a real list
return [qresults[index:index+columns] for index in range(0,len(qresults),columns)]
Any suggestions?
Duane
participants (6)
-
Duane Raymond -
J Cameron Cooper -
Jean Jordaan -
Jens Vagelpohl -
Paul Winkler -
Tres Seaver