direct access to zodb question
I am trying to access the zodb directly from a python program (instead of via an external method), in order to process large volumes of updates (adding about 900k records to a zcatalog): So far I have: #!/apps/zope/bin/python import os, sys sys.path.append("/apps/zope/lib/python") import Zope app=Zope.app() Which works fine. I can see existing objects within a folder by: for item in app.sw.WebSitesFolder.WebSitesMasterData.objectItems(): print str(item) However, when I try to create new objects (zclass instances) using: REQUEST = app.REQUEST REQUEST.set('id', '100') newobj = app.sw.WebSitesFolder.WebSitesChildData.manage_addProduct['SWV2'].WebSites.c reateInObjectManager(REQUEST['id'], REQUEST) I get the following error: Traceback (most recent call last): File "./jhtst.py", line 14, in ? app.REQUEST.set('id', '100') AttributeError: set I have also discovered that REQUEST.get also generates an error. Apparently my REQUEST is not the 'normal' zope REQUEST. When I "print str(REQUEST)" I get: <Special Object Used to Force Acquisition> Does anyone have any ideas as to how to make this work!!!??? Thanks Jonathan
Errr... maybe try "from Testing import makerequest; app = makerequest.makerequest(app)" after app = Zope.app().. On Mon, 2004-07-05 at 16:39, Jonathan Hobbs wrote:
I am trying to access the zodb directly from a python program (instead of via an external method), in order to process large volumes of updates (adding about 900k records to a zcatalog):
So far I have:
#!/apps/zope/bin/python import os, sys sys.path.append("/apps/zope/lib/python") import Zope app=Zope.app()
Which works fine. I can see existing objects within a folder by:
for item in app.sw.WebSitesFolder.WebSitesMasterData.objectItems(): print str(item)
However, when I try to create new objects (zclass instances) using:
REQUEST = app.REQUEST REQUEST.set('id', '100') newobj = app.sw.WebSitesFolder.WebSitesChildData.manage_addProduct['SWV2'].WebSites.c reateInObjectManager(REQUEST['id'], REQUEST)
I get the following error:
Traceback (most recent call last): File "./jhtst.py", line 14, in ? app.REQUEST.set('id', '100') AttributeError: set
I have also discovered that REQUEST.get also generates an error. Apparently my REQUEST is not the 'normal' zope REQUEST. When I "print str(REQUEST)" I get:
<Special Object Used to Force Acquisition>
Does anyone have any ideas as to how to make this work!!!???
Thanks
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 )
From: "Chris McDonough" <chrism@plope.com>
Errr... maybe try "from Testing import makerequest; app = makerequest.makerequest(app)" after app = Zope.app()..
Sweet! That did the trick! Where the x did that wee piece of arcane knowledge come from??!! Thanks very much! Jonathan
On Mon, 2004-07-05 at 16:39, Jonathan Hobbs wrote:
I am trying to access the zodb directly from a python program (instead of via an external method), in order to process large volumes of updates (adding about 900k records to a zcatalog):
So far I have:
#!/apps/zope/bin/python import os, sys sys.path.append("/apps/zope/lib/python") import Zope app=Zope.app()
Which works fine. I can see existing objects within a folder by:
for item in app.sw.WebSitesFolder.WebSitesMasterData.objectItems(): print str(item)
However, when I try to create new objects (zclass instances) using:
REQUEST = app.REQUEST REQUEST.set('id', '100') newobj =
app.sw.WebSitesFolder.WebSitesChildData.manage_addProduct['SWV2'].WebSites.c
reateInObjectManager(REQUEST['id'], REQUEST)
I get the following error:
Traceback (most recent call last): File "./jhtst.py", line 14, in ? app.REQUEST.set('id', '100') AttributeError: set
I have also discovered that REQUEST.get also generates an error. Apparently my REQUEST is not the 'normal' zope REQUEST. When I "print str(REQUEST)" I get:
<Special Object Used to Force Acquisition>
Does anyone have any ideas as to how to make this work!!!???
Thanks
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 )
On Mon, 2004-07-05 at 17:07, Jonathan Hobbs wrote:
From: "Chris McDonough" <chrism@plope.com>
Errr... maybe try "from Testing import makerequest; app = makerequest.makerequest(app)" after app = Zope.app()..
Sweet! That did the trick!
Good news.
Where the x did that wee piece of arcane knowledge come from??!!
Er.. I wrote the module a long time ago. It's just completely undocumented, sorry! - C
No apologies necessary at all :) I'm just extremely glad you wrote the module and remembered it!!! I am running a test of update speed via an external method vs this new 'direct-to-zodb' process. If anyone is interested I will post the results. Jonathan ----- Original Message ----- From: "Chris McDonough" <chrism@plope.com> To: "Jonathan Hobbs" <toolkit@magma.ca> Cc: <zope@zope.org> Sent: July 5, 2004 5:11 PM Subject: Re: [Zope] direct access to zodb question
On Mon, 2004-07-05 at 17:07, Jonathan Hobbs wrote:
From: "Chris McDonough" <chrism@plope.com>
Errr... maybe try "from Testing import makerequest; app = makerequest.makerequest(app)" after app = Zope.app()..
Sweet! That did the trick!
Good news.
Where the x did that wee piece of arcane knowledge come from??!!
Er.. I wrote the module a long time ago. It's just completely undocumented, sorry!
- C
participants (2)
-
Chris McDonough -
Jonathan Hobbs