Hi,
following an old article from zopyx blog, i have
try to make something just to play a bit with zope. here is the code
#coding utf-8
import os
from AccessControl import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import setSecurityManager
import Zope2
def createDocumentContent(plone):
plone.invokeFactory("Document", 'test-doc', "Test of document without
request object")
mydoc = getattr(self, 'test-doc')
DESC = "my description"
BODY = "akelfapfkaefp"
mydoc.setDescription(DESC)
mydoc.setText(BODY)
os.environ['ZOPE_CONFIG'] = '/home/jmfrancois/workspace/stagemcol/
plone3/parts/instance/etc/zope.conf'
app = Zope2.app()
plone = app.plone
user = plone.acl_users.getUser('administrator').__of__(plone.acl_users)
newSecurityManager(app, plone.acl_users.getUser('administrator'))
createDocumentContent(plone)
And here the traceback on a plone3.1 instance:
Traceback (most recent call last):
File "/home/jmfrancois/workspace/stagemcol/plone3/bin/zopepy", line
64, in ?
execfile(sys.argv[0])
File "test.py", line 26, in ?
createDocumentContent(plone)
File "test.py", line 9, in createDocumentContent
plone.invokeFactory("Document", 'test-doc', "Test of document
without request object")
File "/home/jmfrancois/workspace/stagemcol/plone3/parts/plone/
CMFCore/PortalFolder.py", line 315, in invokeFactory
return pt.constructContent(type_name, self, id, RESPONSE, *args,
**kw)
File "/home/jmfrancois/workspace/stagemcol/plone3/parts/plone/
CMFCore/TypesTool.py", line 721, in constructContent
RESPONSE.redirect( immediate_url )
AttributeError: 'str' object has no attribute 'redirect'
I m posting this because i have testing the same code on Plone 2.5,
and i have got an Attribute error not on RESPONSE but REQUEST. For
sure i m not throw the web with a request. When i m doing unit tests i
m not creating fake request for those kind of tests (create content
type instance).
- Am i doing wrong with this code ?
- Is plone can be used without request object (i m sure it is) ?
The goal of this test for me is to replace classique migration done
throw portal_migration; I m working on a big plone web site atm (more
than 100 000 entries inside the portal_catalog and more than 6000
people registred) When i m trying to do partial reindex on the
portal_catalog to add a metadata or sth like that i m getting timeout
from the server. So i m trying this way to do without web browser.
Thx for the help.
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers