KeywordDescriptor¶
-
class
Cauldron.ext.declarative.descriptor.
KeywordDescriptor
(name, initial=None, type=<function <lambda>>, doc=None, readonly=False, writeonly=False)[source] [edit on github]¶ Bases:
object
A descriptor which maintains a relationship with a keyword.
The descriptor should be used as a class level variable. It can be accessed as a regular instance variable, where it will return the result of
Keyword.update()
operations. Setting the instance variable will result in aKeyword.modify()
operation.Parameters: name : str
Keyword name. Case-insensitive, will be translated to upper case.
initial : str
Keyword initial value, should be a string. If not set, no initial value is used and the descriptor will return
None
before the keyword is bound.type : function
A function which converts an inbound value to the appropraite python type. The python type returned by this function should be suitable for use as a string to modify the keyword.
doc : str
The docstring for this keyword descriptor.
readonly : bool
Set this keyword descriptor to be read-only.
writeonly : bool
Set this keyword descriptor to be write-only.
Attributes Summary
name
Keyword name service
The DFW Service associated with this descriptor. Methods Summary
bind
(obj[, service])Bind a service to this descriptor, and the descriptor to an instance. keyword
(obj)The keyword instance for this descriptor. set_bound_name
(obj, value)Set a bound name. Attributes Documentation
-
name
¶ Keyword name
-
service
¶ The DFW Service associated with this descriptor.
Methods Documentation
-
bind
(obj, service=None)[source] [edit on github]¶ Bind a service to this descriptor, and the descriptor to an instance.
Binding an instance of
DescriptorBase
to this descriptor activates the listening of events attached to the underlying keyword object.Binding an instance of
DescriptorBase
to this descriptor will cause the descriptor to resolve the initial value of the keyword. This initial value will be taken from the instance itself, if the descriptor was modified before it was bound to this instance, or the initial value as set by this descriptor will be used. When the initial value conflicts with a value already written to the underlying keyword,IntegrityError
will be raised.If this descriptor has already been bound to any one instance, the descriptor level initial value will not be used, and instead only an instance-level initial value may be used.
Parameters: obj : object
The python instance which owns this descriptor. This is used to bind instance method callbacks to changes in this descriptor’s value.
service :
DFW.Service.Service
The DFW Service to be used for this descriptor. May also be set via the
service
attribute.
-
keyword
(obj)[source] [edit on github]¶ The keyword instance for this descriptor.
-
set_bound_name
(obj, value)[source] [edit on github]¶ Set a bound name.
-