[Product-Developers] How to add permissions and create Zope SQL

cvielma cvielma+nable at gmail.com
Wed May 13 17:59:04 UTC 2009


No no no. That's not what i meant.

I mean, i have 2 problems:
- One: i want to create a Zope Database Connection. I do in the __init__.py:

def initialize(context):

context.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection('goldmineConect','Conexion
MySQL Goldmine', 'goldmine root pacm,Io09', 'YES')

and doesn't work. Also, i want to create a ZSQL method. I actually have a
.zsql file with the query on it, but when i install the product it doesn't
do anything (it fails when an standalone view try to use it, because
"doesn't exist")

- Two: I want to restrict the users that can reach my standalone view. I do
in the __init__.py of the product:

"""Main product initializer
"""
from Products.CMFCore.permissions import setDefaultRoles

# Define a message factory for when this product is internationalised.
# This will be imported with the special name "_" in most modules. Strings
# like _(u"message") will then be extracted by i18n tools for translation.

def initialize(context):
    setDefaultRoles('MyProduct: MyPermission', ())

And when it try to install, it fails in 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>

saying that ValueError: The permission "MyProduct: MyPermission" is invalid.


Greetings,

Andreas Jung-5 wrote:
> 
> On 13.05.09 19:10, cvielma wrote:
>> Hi people!
>>
>> Well i think my problem it's very stupid, but i have been more than a
>> week
>> in it :S
>>
>> I want to make a very specialized product, that creates a form view where
>> the user put some search criteria and then another view that show the
>> results of a table in a relational database that match the criteria. It's
>> pretty simple.
>>
>> So far, i went through the ZMI and created a database connection (MySQL),
>> and the ZSQL Method corresponding to the query. Also, i created the
>> standalone views in the product.
>>
>> But i'm really stuck in creating a Zope Database Connection and ZSQL
>> Method.
>> I followed this:
>> http://plone.org/documentation/how-to/add-file-system-zsql-method and
>> http://plone.org/documentation/how-to/move-your-zsql-methods-to-the-filesystem. 
>>
>> Of course, also checked:
>> http://docs.zope.org/zope2/zope2book/source/RelationalDatabases.html.
>>
>> Also, i can't create a custom permission to the views (i want that only
>> some
>> role or group of users to view the form and query results). I have donde
>> this:
>> http://plone.org/documentation/how-to/adding-a-custom-permission-to-a-plone-2-5-product
> 
> 
> You want to redefine the permissions needed to execute ZSQL methods or
> something like
> that? That does not make much sense to me. If you need something
> different, wrap the original
> API calls within your own view. setDefaultRoles() can be used to
> introduce new permissions.
> Zope 2 permissions must be mapped to a Z3-ish permission within a
> permissions.zcml file.
> Look at existing code for examples.
> 
> -aj
> 
> begin:vcard
> fn:Andreas Jung
> n:Jung;Andreas
> org:ZOPYX Ltd. & Co. KG
> adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
> email;internet:info at zopyx.com
> title:CEO
> tel;work:+49-7071-793376
> tel;fax:+49-7071-7936840
> tel;home:+49-7071-793257
> x-mozilla-html:FALSE
> url:www.zopyx.com
> version:2.1
> end:vcard
> 
> 
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers
> 
> 

-- 
View this message in context: http://n2.nabble.com/How-to-add-permissions-and-create-Zope-SQL-tp2885223p2885557.html
Sent from the Product Developers mailing list archive at Nabble.com.





More information about the Product-Developers mailing list