[Product-Developers] How to add custom permissions to a Standalone View
Tim Knapp
duffyd at kokorice.org
Wed May 13 20:31:28 UTC 2009
On Wed, 2009-05-13 at 13:21 -0700, cvielma wrote:
> Hi there people!
>
> Due to a senseless discuss with a very frustrated guy, and in order to show
> my problem better, i decided to separate my early post in two problems.
>
> I have an standalone view, and i want to make a product that adds permission
> to access that view to some users (maybe a role).
>
> I have followed this
> http://plone.org/documentation/how-to/adding-a-custom-permission-to-a-plone-2-5-product.
>
> My product schema has the following:
>
> - profiles/
> - default/
> - rolemap.xml
> <?xml version="1.0"?>
> <rolemap>
> <roles>
> <role name="MyRole" />
> </roles>
> <permissions>
> <permission name="MyProduct: MyPermission"
> acquire="True">
> <role name="MyRole" />
> </permission>
> </permissions>
> </rolemap>
> - import-steps.xml:
> <?xml version="1.0"?>
> <import-steps>
> <import-step id="goldmine-permisos"
> version="20090512-01"
>
> handler="acmkms.goldmine.setuphandlers.createPermission"
> title="Crear permiso nuevo para
> conexion con Goldmine">
> </import-step>
> </import-steps>
> - configure.zcml:
> <configure
> xmlns="http://namespaces.zope.org/zope"
> xmlns:five="http://namespaces.zope.org/five"
>
> xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
> i18n_domain="acmkms.goldmine">
> <!-- Include the sub-packages that use their own
> configure.zcml files. -->
> <include package=".browser" />
> <include package=".zsql" />
> <!-- Register the installation GenericSetup
> extension profile -->
> <genericsetup:registerProfile
> name="default"
> title="Goldmine"
> directory="profiles/default"
> description="Provee interfaces y los
> requerimientos para realizar consultas a Goldmine desde ACMKMS."
>
> provides="Products.GenericSetup.interfaces.EXTENSION"
> />
> </configure>
> - __init__.py (empty)
> - setuphandlers.py
> from Products.CMFCore.permissions import
> setDefaultRoles
> def createPermission(portal):
> setDefaultRoles('MyProduct: MyPermission', ())
>
> I do buildout and then when i try to install, plone says to me that the
> package broken, and the error is: ValueError: The permission <em>Goldmine:
> Consultar</em> is invalid.
>
> Does anyone know where maybe the problem, or what i'm doing wrong?
>
> Thanks in advance to not frustrated helping guys!
Have a look at collective.autopermission it solves these kinds of issues
and means you don't need to worry about using setDefaultRoles ==
'simpler' (the KISS principle :)
You'll need to include it in your eggs 'install_requires=' line and also
do an <include package="collective.autopermission" /> at the top of your
configure.zcml.
HTH,
Tim
[1] http://pypi.python.org/pypi/collective.autopermission
-Tim
>
> Greetings,
More information about the Product-Developers
mailing list