Solution to Re: [Zope-CMF] Visibility/creatability of types from TypeInfos

David (Hamish) Harvey david.harvey@bristol.ac.uk
Wed, 12 Jun 2002 21:27:01 +0100


Wicked, cheers Florent :-) Actually, the second method worked, the first 
didn't appear to. I've got too much on my hands to try to work out why, 
despite the learning value this process would surely hold.

The result is available as a product at

http://wemrc10.wemrc.bris.ac.uk/zope.html

now along with the other. Note that I've just tarred up the directories, 
and haven't actually tested that they untar and work. It's nearly 10pm and 
I haven't eaten yet....

Again, if anyone wants to tear it to shreds, please do! It *seems* to work 
for me, as far as I've tested it, so I'm keeping my fingers crossed.

I'm liking Zope more and more!

Thanks loads for the help,
Hamish

--On Wednesday, June 12, 2002 19:01:57 +0000 Florent Guillaume 
<fg@nuxeo.com> wrote:

> David (Hamish) Harvey <david.harvey@bristol.ac.uk> wrote:
>> I then want to *change* the permissions on an *existing* method in
>> TypesTool to use this new permission (I originally just edited the
>> source  of TypesTool, and it all worked fine):
>>
>> from Products.CMFCore.TypesTool import TypesTool
>> security = TypesTool.security
>> # constructInstance is public in CMFCore.TypesTool
>> security.declareProtected( CMFCorePermissions.CreateInstances
>>                          , 'constructInstance' )
>
> I'd do:
>     security = ClassSecurityInfo()
>     security.declareProtected(CMFCorePermissions.CreateInstances,
>                               'constructInstance')
>     security.apply(TypesTool)
>
> security.apply takes your changes into account. It's called
> automatically by InitializeClass. Note that the "security" object is not
> intrinsically linked to the class.
>
> Also I think InitializeClass (in fact default__class_init__) removes the
> security attribute of the class when it's done with it so I'm not sure
> doing "security = TypesTool.security" would work.
>
> Another more hackish way to achieve it would be to do:
>     from AccessControl.PermissionRole import PermissionRole
>     TypesTool.constructInstance__roles__ =
> PermissionRole(CMFCorePermissions.CreateInstances) which is, in the end,
> what security.apply does. Not very
> "new style" though.
>
> Florent
>
> --
> Florent Guillaume, Nuxeo (Paris, France)
> +33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com
>
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
>
> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
> requests
>



--
David Harvey (aka Hamish)
Network Coordinator, FloodRiskNet
Research Assistant, Water and Environmental Management Research Centre
University of Bristol, Lunsford House, Cantock's Close, Bristol BS5 6BU
Tel: +44 (117) 9289768 Fax: +44 (117) 9289770
Email: david.harvey@bristol.ac.uk
PGP Key Fingerprint: 6F15 A1C7 342F 2F87 E2CC  176D 1072 8A5B 20E8 E497
WWW: http://www.cen.bris.ac.uk/civil/pgra/dph/dph.htm