Quantcast

invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

classic Classic list List threaded Threaded
13 messages Options
ajung ajung
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have the following code for testing EasyNewsletter:

http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/test_enl.py


The invokeFactory('EasyNewsletter') call works on Plone 3
but fails on Plone 4 with Unauthorized (although I am Manager):

    self.portal.invokeFactory('EasyNewsletter', id='newsletter')
  File
"/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/PortalFolder.py",
line 295, in invokeFactory
    return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
  File
"/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
line 836, in constructContent
    ob = info.constructInstance(container, id, *args, **kw)
  File
"/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
line 312, in constructInstance
    raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
Unauthorized: Cannot create EasyNewsletter


Digging deeper using pdb:

>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(472)_queryFactoryMethod()
- -> def _queryFactoryMethod(self, container, default=None):
(Pdb) n
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(474)_queryFactoryMethod()
- -> if not self.product or not self.factory or container is None:
(Pdb)
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(478)_queryFactoryMethod()
- -> dispatcher = getattr(container, 'manage_addProduct', None)
(Pdb)
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(480)_queryFactoryMethod()
- -> if dispatcher is None:
(Pdb)
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(483)_queryFactoryMethod()
- -> try:
(Pdb)
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(484)_queryFactoryMethod()
- -> p = dispatcher[self.product]
(Pdb)
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(489)_queryFactoryMethod()
- -> m = getattr(p, self.factory, None)
(Pdb) print dispatcher
<App.FactoryDispatcher.ProductDispatcher object at 0x196f190>
(Pdb) print self.factory
addEasyNewsletter
(Pdb) n
>
/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(491)_queryFactoryMethod()
- -> if m:
(Pdb) print m
None

Why does this fail on Plone 4?

Side note: adding an EasyNewsletter instance through the Plone UI
works both with Plone 3 and Plone 4.

Andreas


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJM5o3nAAoJEADcfz7u4AZjcmULv2Z7UgrPVo7ClGepqnzm10H5
P266ughqWZcRZNig+LLFPBN6GSwW6hMY5xaUrZZ5C5yhDtKjhdsSJUB2a8VasDS5
LfrXtnbZYchFiQqJtOIwcMPYl7tTH1+0d0p6xlnj65ammD5YdJE7mrQ4ox8wj3WS
K/6rk6HK8HtxhM//ymW4i0xhslQMHAJ4nRzeRq88dDDE0rlUK2ZdRnS4jogS/Abg
lQ5cYFWE+BuKLSKyMSPa0pW9NkoP1gPsBzvnNj1edkEG4V8m9ajrJewtK72vohQU
4CcN11h5VdtZrK3dYE36/p/HO7XVR9+suWaNv16g23v8ME/2j3udO6UmA0ZDOsCK
UTKXEHIe1hYjpIhyguCbhLc6m8g6YL3RgaEP2/K/Hufdmw3O94+PKOV96yDcoN1V
CmE98pqvpTyhmFbjN3tERG2ZqT0hKRWL5WTajlQoKhBBf0v0k74xQOdDIMhnoK63
e5zHk2yK9+K1wIAtW078g7imPYGdhRM=
=/j62
-----END PGP SIGNATURE-----

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers

lists.vcf (331 bytes) Download Attachment
Eric BREHAULT Eric BREHAULT
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

Hello,

I have the same issue. The strange thing is it fails in tests only,
but it works with the Plone UI.
I guess there is an extra something we need to declare in the test
onsetup to make sure our custom archetypes are installed properly, but
I haven't find out what for now.

Eric

On Fri, Nov 19, 2010 at 3:47 PM, Andreas Jung <[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I have the following code for testing EasyNewsletter:
>
> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/test_enl.py
>
>
> The invokeFactory('EasyNewsletter') call works on Plone 3
> but fails on Plone 4 with Unauthorized (although I am Manager):
>
>    self.portal.invokeFactory('EasyNewsletter', id='newsletter')
>  File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/PortalFolder.py",
> line 295, in invokeFactory
>    return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
>  File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
> line 836, in constructContent
>    ob = info.constructInstance(container, id, *args, **kw)
>  File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
> line 312, in constructInstance
>    raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
> Unauthorized: Cannot create EasyNewsletter
>
>
> Digging deeper using pdb:
>
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(472)_queryFactoryMethod()
> - -> def _queryFactoryMethod(self, container, default=None):
> (Pdb) n
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(474)_queryFactoryMethod()
> - -> if not self.product or not self.factory or container is None:
> (Pdb)
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(478)_queryFactoryMethod()
> - -> dispatcher = getattr(container, 'manage_addProduct', None)
> (Pdb)
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(480)_queryFactoryMethod()
> - -> if dispatcher is None:
> (Pdb)
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(483)_queryFactoryMethod()
> - -> try:
> (Pdb)
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(484)_queryFactoryMethod()
> - -> p = dispatcher[self.product]
> (Pdb)
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(489)_queryFactoryMethod()
> - -> m = getattr(p, self.factory, None)
> (Pdb) print dispatcher
> <App.FactoryDispatcher.ProductDispatcher object at 0x196f190>
> (Pdb) print self.factory
> addEasyNewsletter
> (Pdb) n
>>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(491)_queryFactoryMethod()
> - -> if m:
> (Pdb) print m
> None
>
> Why does this fail on Plone 4?
>
> Side note: adding an EasyNewsletter instance through the Plone UI
> works both with Plone 3 and Plone 4.
>
> Andreas
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQGUBAEBAgAGBQJM5o3nAAoJEADcfz7u4AZjcmULv2Z7UgrPVo7ClGepqnzm10H5
> P266ughqWZcRZNig+LLFPBN6GSwW6hMY5xaUrZZ5C5yhDtKjhdsSJUB2a8VasDS5
> LfrXtnbZYchFiQqJtOIwcMPYl7tTH1+0d0p6xlnj65ammD5YdJE7mrQ4ox8wj3WS
> K/6rk6HK8HtxhM//ymW4i0xhslQMHAJ4nRzeRq88dDDE0rlUK2ZdRnS4jogS/Abg
> lQ5cYFWE+BuKLSKyMSPa0pW9NkoP1gPsBzvnNj1edkEG4V8m9ajrJewtK72vohQU
> 4CcN11h5VdtZrK3dYE36/p/HO7XVR9+suWaNv16g23v8ME/2j3udO6UmA0ZDOsCK
> UTKXEHIe1hYjpIhyguCbhLc6m8g6YL3RgaEP2/K/Hufdmw3O94+PKOV96yDcoN1V
> CmE98pqvpTyhmFbjN3tERG2ZqT0hKRWL5WTajlQoKhBBf0v0k74xQOdDIMhnoK63
> e5zHk2yK9+K1wIAtW078g7imPYGdhRM=
> =/j62
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers
>
>
_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
ajung ajung
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric Bréhault wrote:
> Hello,
>
> I have the same issue. The strange thing is it fails in tests only,
> but it works with the Plone UI.
> I guess there is an extra something we need to declare in the test
> onsetup to make sure our custom archetypes are installed properly, but
> I haven't find out what for now.

I have another product using basically the same test setup working for
Plone 3 and Plone 4 - being slightly confused.

- -aj


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJM5qtZAAoJEADcfz7u4AZjsuALwKx3Ro65h0aswlPa2DfUJM0M
/X9dfT+SkzIhuoJgmIhIcvwV72CTvyxM4ZXEjrw3YXiTyqxrGR22mUHnEYiwWwGH
lqWd/Cq/jH5nkjpDPmhmK9/43bXPA3cqhzpW949SA79Mfp5eB6GP3rstnu7RAsXB
JKo877eF6W9xccSi8oDlGfxtJ7sLQY+9VYo7H9lWC15Osyl4QLV2os3mgXDhZNBr
5Bukp1FHnf8l8cTT18AhEZyuVEs9xduf2fUJ3URWBowOHuzUjsn865J0jDzYjxtS
mZQtmiPNaxyDwGigrpO04BV8T7qA30wg7zHWqhOfZPeK+3KOPCsYk5eIjAEftVlo
FNb00ITV8GLSMAAMd1/agXh3yJcvu6HUo4vMLwfHSVE39yYjW8GZUkMsALXqlDwd
1BWs0q/OdHWgvmkFQY4LJ44oBt0MyTl0SkRHgLF1NwRxYi4Lz8vniHq876HUCmlK
KHMDtCTyp1DF7WY3X+Kyus8Vns70cCw=
=98cF
-----END PGP SIGNATURE-----

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers

lists.vcf (331 bytes) Download Attachment
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

In reply to this post by ajung
On 11/19/10 6:47 AM, Andreas Jung wrote:

> I have the following code for testing EasyNewsletter:
>
> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/test_enl.py
>
>
> The invokeFactory('EasyNewsletter') call works on Plone 3
> but fails on Plone 4 with Unauthorized (although I am Manager):
>
>     self.portal.invokeFactory('EasyNewsletter', id='newsletter')
>   File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/PortalFolder.py",
> line 295, in invokeFactory
>     return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
>   File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
> line 836, in constructContent
>     ob = info.constructInstance(container, id, *args, **kw)
>   File
> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
> line 312, in constructInstance
>     raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
> Unauthorized: Cannot create EasyNewsletter
>
>
> Digging deeper using pdb:
>
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(472)_queryFactoryMethod()
> -> def _queryFactoryMethod(self, container, default=None):
> (Pdb) n
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(474)_queryFactoryMethod()
> -> if not self.product or not self.factory or container is None:
> (Pdb)
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(478)_queryFactoryMethod()
> -> dispatcher = getattr(container, 'manage_addProduct', None)
> (Pdb)
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(480)_queryFactoryMethod()
> -> if dispatcher is None:
> (Pdb)
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(483)_queryFactoryMethod()
> -> try:
> (Pdb)
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(484)_queryFactoryMethod()
> -> p = dispatcher[self.product]
> (Pdb)
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(489)_queryFactoryMethod()
> -> m = getattr(p, self.factory, None)
> (Pdb) print dispatcher
> <App.FactoryDispatcher.ProductDispatcher object at 0x196f190>
> (Pdb) print self.factory
> addEasyNewsletter
> (Pdb) n
>
> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(491)_queryFactoryMethod()
> -> if m:
> (Pdb) print m
> None
>
> Why does this fail on Plone 4?
Not sure why, but I would guess EasyNewsletter's initialize method isn't
getting called in your test setup for some reason.
David
----------
David Glick
 Web Developer
 [hidden email]
 206.286.1235x32

Groundwire: You Are Connected
 http://groundwire.org               

Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
 http://groundwire.org/email-capture

Check out our 2010 Website Benchmarks Report. How do you stack up?
 http://groundwire.org/resources/articles/2010-website-benchmarks-report

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Ross Patterson-2 Ross Patterson-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

David Glick <[hidden email]> writes:

> On 11/19/10 6:47 AM, Andreas Jung wrote:
>> I have the following code for testing EasyNewsletter:
>>
>> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/test_enl.py>
>>
>> The invokeFactory('EasyNewsletter') call works on Plone 3
>
>> but fails on Plone 4 with Unauthorized (although I am Manager):
>>
>>     self.portal.invokeFactory('EasyNewsletter', id='newsletter')
>>   File
>> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/PortalFolder.py",
>> line 295, in invokeFactory
>>     return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
>>   File
>> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
>> line 836, in constructContent
>>     ob = info.constructInstance(container, id, *args, **kw)
>>   File
>> "/home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py",
>> line 312, in constructInstance
>>     raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
>> Unauthorized: Cannot create EasyNewsletter
>>
>>
>> Digging deeper using pdb:
>>
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(472)_queryFactoryMethod()
>> -> def _queryFactoryMethod(self, container, default=None):
>> (Pdb) n
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(474)_queryFactoryMethod()
>> -> if not self.product or not self.factory or container is None:
>> (Pdb)
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(478)_queryFactoryMethod()
>> -> dispatcher = getattr(container, 'manage_addProduct', None)
>> (Pdb)
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(480)_queryFactoryMethod()
>> -> if dispatcher is None:
>> (Pdb)
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(483)_queryFactoryMethod()
>> -> try:
>> (Pdb)
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(484)_queryFactoryMethod()
>> -> p = dispatcher[self.product]
>> (Pdb)
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(489)_queryFactoryMethod()
>> -> m = getattr(p, self.factory, None)
>> (Pdb) print dispatcher
>> <App.FactoryDispatcher.ProductDispatcher object at 0x196f190>
>> (Pdb) print self.factory
>> addEasyNewsletter
>> (Pdb) n
>>
>> /home/ajung/.buildout/eggs/Products.CMFCore-2.2.2-py2.6.egg/Products/CMFCore/TypesTool.py(491)_queryFactoryMethod()
>> -> if m:
>> (Pdb) print m
>> None
>>
>> Why does this fail on Plone 4?
> Not sure why, but I would guess EasyNewsletter's initialize method isn't
> getting called in your test setup for some reason.

Just to mention the obvious in case that's it, bit the instance's
site.zcml isn't loaded for tests under Plone 4.  Is your ZCML being
loaded?

Ross

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
ajung ajung
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

In reply to this post by David Glick (GW)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Glick wrote:

>>
>> Why does this fail on Plone 4?
> Not sure why, but I would guess EasyNewsletter's initialize method isn't
> getting called in your test setup for some reason.

Neither I see initialize() being called nor site.zcml being loaded
although my setup looks perfectly fine to me (and working with Plone 3):

http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/base.py

I see something in the PTC release notes about site.zcml being loaded
lazily but not sure how this applies here.

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJM52PvAAoJEADcfz7u4AZj4nsLv3K5TIy0IAV5yrG8cdS/2Jyk
F+t5zVcRD0KqXVn1VWpZXvc2F9Tv90mgtrNwgBN5olYB5xR9SfLYB9FLE4oieXLR
Y9CnT915c9eL0Oi07XUjSpect2r5Awr9m9+KQn8YESZZ0yhB8QfsBc4jF2bRyAMU
7Jhxgupm9ELGzLtac18I8nxeqio8QLpD30ErAXUcTwFiFC/9jMao7enLEsv5fBM+
xqbK5xEIJmmQBRm9wdXodbtQJkye10kfsWHebtXey1SLl76+1Pl1hNA4Z656pyDi
fJHAIbk7dkN3eIIUI9YBaBr8s03SlZEgTnqjrm/ebMaeiICJFOkOzkjKBx93VnZB
Rzymue+00o/QKirKs74quZLaNAiLXqv16w4wG2POZhj3oh/sDWUzayz+W+ayb2As
F8hU3ZY0WbhuMWJculcNooJBnssKOFOvcCUIy4pNRG3aLavtc3hBcO/1f+pxCcl+
Z+D6S/0qY/dWenFxfgn9JkC+0+OABDg=
=x3F3
-----END PGP SIGNATURE-----

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers

lists.vcf (331 bytes) Download Attachment
Ross Patterson-2 Ross Patterson-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

Andreas Jung <[hidden email]> writes:

> David Glick wrote:
>
>>>
>>> Why does this fail on Plone 4?
>> Not sure why, but I would guess EasyNewsletter's initialize method isn't
>> getting called in your test setup for some reason.
>
> Neither I see initialize() being called nor site.zcml being loaded
> although my setup looks perfectly fine to me (and working with Plone 3):
>
> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/tests/base.py
>
> I see something in the PTC release notes about site.zcml being loaded
> lazily but not sure how this applies here.

Your ZCML doesn't incldue five:registerPackage nor does your test setup
call installProduct.

Ross

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
ajung ajung
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ross Patterson wrote:

> Your ZCML doesn't incldue five:registerPackage

Does not help after adding registerPackage:

http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/configure.zcml

>nor does your test setup
> call installProduct.

installProduct() is of course called in the setup of the layer
(see base.py).

and all EasyNewsletter type are registered correctly with portal_types:

- -> self.portal.invokeFactory('EasyNewsletter', id='newsletter')

(Pdb) self.portal.portal_types.objectIds()
['ATBooleanCriterion', 'ATCurrentAuthorCriterion', 'ATDateCriteria',
'ATDateRangeCriterion', 'ATListCriterion', 'ATPathCriterion',
'ATRelativePathCriterion', 'ATPortalTypeCriterion',
'ATReferenceCriterion', 'ATSelectionCriterion', 'ATSimpleIntCriterion',
'ATSimpleStringCriterion', 'ATSortCriterion', 'Discussion Item',
'Document', 'Event', 'File', 'Folder', 'Image', 'Link', 'News Item',
'Plone Site', 'TempFolder', 'Topic', 'EasyNewsletter', 'ENLIssue',
'ENLSubscriber', 'ENLTemplate']

(Pdb) 'EasyNewsletter' in self.portal.portal_types.objectIds()
True

Andreas


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJM528RAAoJEADcfz7u4AZjSWgLwMLUl1GSt72NZq8lWxC+6wiE
aZM9jmRqgK11vQvOjlXhOJllnMIGY2Y4WSNQ/kEmr6FvWVz5K8AIN791AU8C3aFc
SFRmAhZvhOoNmKS+iyAbPDd7HRDWIjoZ2Gk4BSXGVqBBV5CPmgSgXNagBdTwXW1N
ToeeKGJXtqoRkAxRnbizBaDJcayMN35YJPztXwA137LGuU1mvuE4xTSa9qNpZ6Ua
zDknAGEN8SIuSF87XWPxASLWzbfuymLm00NN3GrqGPDDKZgc1hJz/H7X+DMlcvgJ
YGWw7rsHBgcF1pKtgrxEvUr8ceihTXE4J+A2FB0wvhOIAZEb+z41GpxfUr62HTkj
JWV5mzc9xoRz7WR/3jA9s/SP73FygLg/DRb5fkvy8Ix7sUMsCEoaP394X1j07pbA
ktgTWOULcXeJ6QFE+bPVlJfNizYjJK+iltQElQhGFsE6mMc/1HV3QT9G6/mB72Lj
hIvyaSh6rovssS1b/1/9JLSccZc9FkI=
=n+fe
-----END PGP SIGNATURE-----

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers

lists.vcf (331 bytes) Download Attachment
Ross Patterson-2 Ross Patterson-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

Andreas Jung <[hidden email]> writes:

> Ross Patterson wrote:
>
>> Your ZCML doesn't incldue five:registerPackage
>
> Does not help after adding registerPackage:
>
> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/configure.zcml
>
>>nor does your test setup
>> call installProduct.
>
> installProduct() is of course called in the setup of the layer
> (see base.py).

My bad, missed the installProduct.

> and all EasyNewsletter type are registered correctly with portal_types:
>
> -> self.portal.invokeFactory('EasyNewsletter', id='newsletter')
>
> (Pdb) self.portal.portal_types.objectIds()
> ['ATBooleanCriterion', 'ATCurrentAuthorCriterion', 'ATDateCriteria',
> 'ATDateRangeCriterion', 'ATListCriterion', 'ATPathCriterion',
> 'ATRelativePathCriterion', 'ATPortalTypeCriterion',
> 'ATReferenceCriterion', 'ATSelectionCriterion', 'ATSimpleIntCriterion',
> 'ATSimpleStringCriterion', 'ATSortCriterion', 'Discussion Item',
> 'Document', 'Event', 'File', 'Folder', 'Image', 'Link', 'News Item',
> 'Plone Site', 'TempFolder', 'Topic', 'EasyNewsletter', 'ENLIssue',
> 'ENLSubscriber', 'ENLTemplate']
>
> (Pdb) 'EasyNewsletter' in self.portal.portal_types.objectIds()
> True

Your problem is very explicitly in the initialize stuff, not in
portal_types.

Ross

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

On 11/19/10 10:57 PM, Ross Patterson wrote:

> Andreas Jung <[hidden email]> writes:
>
>> Ross Patterson wrote:
>>
>>> Your ZCML doesn't incldue five:registerPackage
>> Does not help after adding registerPackage:
>>
>> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/configure.zcml
>>
>>> nor does your test setup
>>> call installProduct.
>> installProduct() is of course called in the setup of the layer
>> (see base.py).
> My bad, missed the installProduct.
installProduct is a deferred call just like setupPloneSite and your
setup_registration.  So when you call it from within setup_registration,
it adds the deferred function too late.  I think it'll work if you put
the installProduct line outside of setup_registration.

As for the five:registerPackage, you shouldn't need that since this
package is in the Products namespace.
----------
David Glick
 Web Developer
 [hidden email]
 206.286.1235x32

Groundwire: You Are Connected
 http://groundwire.org               

Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
 http://groundwire.org/email-capture

Check out our 2010 Website Benchmarks Report. How do you stack up?
 http://groundwire.org/resources/articles/2010-website-benchmarks-report

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

On 11/20/10 9:21 PM, [hidden email] wrote:

> David Glick wrote:
> > On 11/19/10 10:57 PM, Ross Patterson wrote:
> >> Andreas Jung <[hidden email]> writes:
> >>
> >>> Ross Patterson wrote:
> >>>
> >>>> Your ZCML doesn't incldue five:registerPackage
> >>> Does not help after adding registerPackage:
> >>>
> >>>
> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/configure.zcml
> >>>
> >>>> nor does your test setup
> >>>> call installProduct.
> >>> installProduct() is of course called in the setup of the layer
> >>> (see base.py).
> >> My bad, missed the installProduct.
> > installProduct is a deferred call just like setupPloneSite and your
> > setup_registration.  So when you call it from within setup_registration,
> > it adds the deferred function too late.  I think it'll work if you put
> > the installProduct line outside of setup_registration.
>
> Right - this works.
>
> Then this documentation is wrong - as it states to call installPackage()
> or installProduct() inside setup_registration().
>
> http://plone.org/documentation/manual/developer-manual/testing/writing-a-plonetestcase-unit-integration-test
It demonstrates calling installProduct outside of the @onsetup function,
and installPackage inside. That is correct.
David
----------
David Glick
 Web Developer
 [hidden email]
 206.286.1235x32

Groundwire: You Are Connected
 http://groundwire.org               

Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
 http://groundwire.org/email-capture

Check out our 2010 Website Benchmarks Report. How do you stack up?
 http://groundwire.org/resources/articles/2010-website-benchmarks-report

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Eric BREHAULT Eric BREHAULT
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

In reply to this post by David Glick (GW)
Thank you very much for this solution !!
I spent hours trying to understand why my product was not setting up
properly in my tests.
Now I have moved installProduct call outside onsetup, it works fine.

As it used to work when called from onsetup in Plone 3, it would
probably a good thing to mention in the Plone 3 to Plone 4 upgrade
guide.

Eric

On Sat, Nov 20, 2010 at 9:35 PM, David Glick <[hidden email]> wrote:

> On 11/19/10 10:57 PM, Ross Patterson wrote:
>> Andreas Jung <[hidden email]> writes:
>>
>>> Ross Patterson wrote:
>>>
>>>> Your ZCML doesn't incldue five:registerPackage
>>> Does not help after adding registerPackage:
>>>
>>> http://svn.plone.org/svn/collective/Products.EasyNewsletter/trunk/Products/EasyNewsletter/configure.zcml
>>>
>>>> nor does your test setup
>>>> call installProduct.
>>> installProduct() is of course called in the setup of the layer
>>> (see base.py).
>> My bad, missed the installProduct.
> installProduct is a deferred call just like setupPloneSite and your
> setup_registration.  So when you call it from within setup_registration,
> it adds the deferred function too late.  I think it'll work if you put
> the installProduct line outside of setup_registration.
>
> As for the five:registerPackage, you shouldn't need that since this
> package is in the Products namespace.
> ----------
> David Glick
>  Web Developer
>  [hidden email]
>  206.286.1235x32
>
> Groundwire: You Are Connected
>  http://groundwire.org
>
> Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
>  http://groundwire.org/email-capture
>
> Check out our 2010 Website Benchmarks Report. How do you stack up?
>  http://groundwire.org/resources/articles/2010-website-benchmarks-report
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers
>
_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invokeFactory() failing on Plone 4 (PTC) but working on Plone 3

On 11/22/10 2:44 AM, Eric Bréhault wrote:
> Thank you very much for this solution !!
> I spent hours trying to understand why my product was not setting up
> properly in my tests.
> Now I have moved installProduct call outside onsetup, it works fine.
>
> As it used to work when called from onsetup in Plone 3, it would
> probably a good thing to mention in the Plone 3 to Plone 4 upgrade
> guide.
Ah, interesting. I wonder if it could be made to not defer the call if
it is called from another deferred call. Please consider filing a Zope 2
bug at http://launchpad.net/zope2
David
----------
David Glick
 Web Developer
 [hidden email]
 206.286.1235x32

Groundwire: You Are Connected
 http://groundwire.org               

Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
 http://groundwire.org/email-capture

Check out our 2010 Website Benchmarks Report. How do you stack up?
 http://groundwire.org/resources/articles/2010-website-benchmarks-report

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Loading...