Re: Allowed types programmatically on dexterity content

Philip Bauer <[email protected]>
Newsgroups gmane.comp.web.zope.plone.user
Message-ID <[email protected]>
I forgot the imports:

from Products.CMFPlone.interfaces.constrains import ISelectableConstrainTypes
from plone.app.dexterity.behaviors import constrains

Philip

> Am 26.03.2015 um 19:47 schrieb Philip Bauer <[email protected]>:
> 
> See http://plone-training.readthedocs.org/en/latest/user_generated_content.html
> 
> def constrain(context, allowed_types):
>    behavior = ISelectableConstrainTypes(context)
>    behavior.setConstrainTypesMode(constrains.ENABLED)
>    behavior.setLocallyAllowedTypes(allowed_types)
>    behavior.setImmediatelyAddableTypes(allowed_types)
> 
> Philip
> 
> --
> Starzel.de
> Philip Bauer
> Adlzreiterstr. 35
> 80337 München
> Tel: 089 - 189 29 533
> Fax: 089 - 189 29 535
> [email protected]
> www.starzel.de
> 
>> Am 26.03.2015 um 18:56 schrieb Bruno Barbosa <[email protected]>:
>> 
>> Thanks Johannes!
>> 
>> it will be very useful.
>> 
>> 
>> 
>> --
>> Bruno Barbosa
>> [email protected]
>> 
>> 
>> On Wed, Mar 25, 2015 at 6:18 PM, Johannes Raggam <[email protected]> wrote:
>> This is a start: use this behavior for your content type:
>> 
>> Products.CMFPlone.interfaces.constrains.ISelectableConstrainTypes
>> 
>> Now you should be able to set the constraint types. Look at the behavior
>> implementation to get an idea on how to do that.
>> 
>> Cheers, Johannes
>> 
>> 
>> 
>> On Wed, 2015-03-25 at 18:09 -0300, Bruno Barbosa wrote:
>>> ​​
>>> ​​Hello,
>>> 
>>> In my project I need to setup programmatically the allowed types at
>>> add-menu on custom content type.
>>> 
>>> On google, I found the follow link:
>>> http://stackoverflow.com/questions/5194464/how-to-programmatically-control-an-objects-add-menu-list-of-allowed-content-type
>>> 
>>> But unfortuna​tel​y don't works for me because I'm using dexterity
>>> instead of AT.
>>> 
>>> 
>>> Someone has a tip about how to do it with dexterity?
>>> 
>>> 
>>> att,
>>> 
>>> --
>>> Bruno Barbosa
>>> [email protected]
>>> ​
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
>>> by Intel and developed in partnership with Slashdot Media, is your hub for all
>>> things parallel software development, from weekly thought leadership blogs to
>>> news, videos, case studies, tutorials and more. Take a look and join the
>>> conversation now. http://goparallel.sourceforge.net/
>>> _______________________________________________ Plone-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/plone-users
>> 
>> 
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub for all
>> things parallel software development, from weekly thought leadership blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/_______________________________________________
>> Plone-Users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/plone-users
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
Plone-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plone-users
signature.asc (application/pgp-signature, 496 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQEcBAEBCgAGBQJVFFTFAAoJEOeXgSbn9GtJvp0IAJEaw7tjf8yorV0cWrGiZ9On
gq2B7z9OcLW+jrGYlHiy9/uti/vkBQMf4Om3EunSnXhdKFwfYWnKa5Exi5B2FzUd
z/4KCGc/WlIF0Emsd9awWtwp4Y+RStwZ8MDmtRM7hoIfMjy0J+y3Gum7zg0bFXLM
m1FKflYOZmIckYWhTD18ouc9NuVmeysJQXNnPt0zFF6vl7VyqOhSGjsVqTDXiJLy
wrN7zx8PYK41WVD72Gj7J/6XqGVcHzJt8gI5VLX4ZIC7QPXWr7YvSnvLlXSOaNpD
XvqBFE7NK7HiCgffRs68Cabn2tkWyyFh/1KIiS8lPR4EG6AfODOquYvSEhmY7yQ=
=Gctc
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.