invokeFactory is failing in plone 4 test code

was geting error like this when running my test:

File “/home/tareq/DATA/projects/DANBIO_FOLDER/danbio/buildout-cache/eggs/Products.CMFCore-2.2.5-py2.6.egg/Products/CMFCore/TypesTool.py”, line 835, in constructContent
ob = info.constructInstance(container, id, *args, **kw)
File “/home/tareq/DATA/projects/DANBIO_FOLDER/danbio/buildout-cache/eggs/Products.CMFCore-2.2.5-py2.6.egg/Products/CMFCore/TypesTool.py”, line 311, in constructInstance
raise AccessControl_Unauthorized(‘Cannot create %s’ % self.getId())
Unauthorized: Cannot create connectorfolder

It was working in gui but not in test code, then i found from this link http://plone.293351.n2.nabble.com/invokeFactory-failing-on-Plone-4-PTC-but-working-on-Plone-3-td5755482.html

the solution is like you need to install the product differently in setup_product function in your test.

like this:

@onsetup
def setup_product():

fiveconfigure.debug_mode = True
import zitelab.connector #import your product here
zcml.load_config(‘configure.zcml’, zitelab.connector) #load config of your product
fiveconfigure.debug_mode = False
ztc.installPackage(‘zitelab.connector’) #install it now

then it seems working after installing like this.

hope this helps, thanks

 

 

Advertisements
About

Work is fun!

Tagged with: , , , , , , , ,
Posted in ploneCMS, python, Zope

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Disclaimer
All content provided on this "tareqalam.com" blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner of [tareqalam.wordpress.com] will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
July 2013
M T W T F S S
« Jun   Oct »
1234567
891011121314
15161718192021
22232425262728
293031  

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 23 other followers

%d bloggers like this: