Пример #1
0
class StringsProperty(basic.BasicProperty):
	"""Strings list property"""
	baseType = list_types.listof_strings
	default = defaults.DefaultCallable( _defaultList )
Пример #2
0
class ClassesProperty(basic.BasicProperty):
	"""Classes list property"""
	baseType = list_types.listof_classes
	default = defaults.DefaultCallable( _defaultList )
Пример #3
0
class FloatsProperty(basic.BasicProperty):
	"""Floats list property"""
	baseType = list_types.listof_floats
	default = defaults.DefaultCallable( _defaultList )
Пример #4
0
class IntegersProperty(basic.BasicProperty):
	"""Ints list property"""
	baseType = list_types.listof_ints
	default = defaults.DefaultCallable( _defaultList )
Пример #5
0
class BooleansProperty(basic.BasicProperty):
	"""Booleans list property"""
	baseType = list_types.listof_bools
	default = defaults.DefaultCallable( _defaultList )
Пример #6
0
class ListProperty(basic.BasicProperty):
	"""Generic list property"""
	baseType = basic_types.List_DT
	default = defaults.DefaultCallable( _defaultList )
Пример #7
0
	def __init__(
		self, name, documentation = "",
		**namedarguments
	):
		"""Create a new basic property object

		name -- name of the property, used for storage and reporting
		documentation -- appears in automated documentation systems

		baseType -- an object representing the base-type of the
			property's values.  May include the following values:

				coerce( value ) -- coerce value to acceptable type
				check( value ) -- check that given value is acceptable,
					return false if it is not.
				factories( ) -- return a list of factory functions/classes
					for creating new instances of the class
				dataType -- string specifying a data-type key for the
					values.  This specifier is entirely local to the
					properties system, with no neccessary relation to
					class or type names.  With that said, generally the
					values are the dotted-name of the class/type allowed
					for the property.
					
					Note: This can be a dotted name with the trailing
					items specifying more specific data types, so, for
					instance, str.long will use the "long string" editor if
					it's registered, or the "string" editor if not.
					
			if coerce is not present, the class should have an initialiser
			that allows passing a single value as the value to coerce.

			if check is not present, check will be done as
			isinstance( value, baseType).

			if factories is not present, factories will be assumed to be
			the baseType itself.
		
		defaultValue -- static value to be used as default, if not
			specified, not provided
		defaultFunction -- function with signature function( property,
			client ) which returns a dynamic default value
		setDefaultOnGet -- if true (default), then retrieving a
			default value causes the value to be explicitly set as the
			current value

		boundaries -- series of callable Boundary objects which are
			(if present) called for each set/getDefault in order to
			confirm that the given value abides by the boundaries
			defined.  Should generally only raise ValueError, TypeError,
			KeyError or AttributeError (or sub-classes of those) as
			appropriate to the boundary violation.

			Called as:
				boundary( value, property, client )
			note that the basictypes.boundary module defines a number
			of Boundary objects which are designed to be used in this
			field of the property.

		friendlyName -- user-friendly name for use in UIs and the like,
			defaults to the current value of name
		trueProperty -- if true, this property really does describe a
			property, that is, a descriptor for an attribute which is
			accessed using object.x notation.
			
			if false, this property is used to interact with the
			property system, but is not actually a property of an
			object (for instance when the object is an old-style class
			which cannot support properties, you can define virtual
			properties for use with the class)  The property system
			can examine the value of trueProperty to determine whether
			to use setattr(object,name,value) or call
			property.__set__(object, value) to use the property.


		Notes:
			You can specify _any_ name=value set to store a value, so,
			for instance, you could specify __get__ to override the
			__get__ method, or similarly _getValue or getDefault.

			Sub-classes may (and do) define extra name=value pairs to
			support extended functionality.  You will need to look at
			the sub-class's documentation for details on other
			significant attribute names.
		"""
		assert isinstance( name, (str,unicode)), """Property name is not a string or unicode value, was a %s"""%(type(name))
		self.name = name
		assert isinstance( documentation, (str,unicode)), """Property documentation is not a string or unicode value, was a %s"""%(type(documentation))
		self.__doc__ = documentation

		if namedarguments.has_key('defaultValue'):
			namedarguments[ 'default' ] = defaults.DefaultValue(
				namedarguments[ 'defaultValue' ]
			)
			del namedarguments[ 'defaultValue' ]
		elif namedarguments.has_key('defaultFunction'):
			namedarguments[ 'default' ] = defaults.DefaultCallable(
				namedarguments[ 'defaultFunction' ]
			)
			del namedarguments[ 'defaultFunction' ]
		elif namedarguments.has_key('default'):
			current = namedarguments.get('default')
			if not isinstance( current, defaults.Default ):
				namedarguments['default' ] = defaults.DefaultValue(current)
		propertied.Propertied.__init__( self, **namedarguments )