Package platecom :: Package utils :: Module fieldproperty :: Class ATToolDependentFieldProperty
[hide private]
[frames] | no frames]

Class ATToolDependentFieldProperty

source code

     object --+    
              |    
ATFieldProperty --+
                  |
                 ATToolDependentFieldProperty

A version of the field property type which is able to acquire tools. This uses a not-very-nice acquisition hack, and is not generalisable to all acquisition-dependent operations, but should work for tools in the portal root.

>>> from Products.Archetypes.atapi import *
>>> from icsemantic.core.fieldproperty import ATToolDependentFieldProperty
>>> from zope.app.component.hooks import setSite
>>> setSite(portal)
>>> class MyContent(BaseContent):
...     portal_type = meta_type = 'MyContent'
...     schema = Schema((
...         ReferenceField('some_field', multiValued=True,
...                        relationship='foo', storage=AnnotationStorage()),
...         ))
...
...     some_field = ATToolDependentFieldProperty('some_field')
>>> registerType(MyContent, 'Archetypes')
>>> self.portal._setOb('foo', MyContent('foo'))
>>> foo = getattr(self.portal, 'foo')

These lines would fail with AttributeError: reference_catalog if it used the standard accessor.

>>> foo.some_field
[]
>>> foo.some_field = [self.folder.UID()]
>>> foo.some_field
[<ATFolder at /plone/Members/test_user_1_>]
Instance Methods [hide private]
 
__init__(self, name, get_transform=None, set_transform=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__get__(self, inst, klass) source code
 
__set__(self, inst, value) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, get_transform=None, set_transform=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__get__(self, inst, klass)

source code 
Overrides: ATFieldProperty.__get__

__set__(self, inst, value)

source code 
Overrides: ATFieldProperty.__set__