Exemple #1
0
"""(preliminary) Model of a Factory Callable object"""
from basicproperty import propertied, basic, common
from basictypes import list_types, callable


class Factory(callable.Callable):
    """An object intended to create instances of a type

	The factory allows you to create instances of a type
	through the GUI.  Most factories will allow for
	entirely-default calling (i.e. Factory() creates a
	new, valid instance).  Others may require interactive
	definition of certain parameters.
	"""


listof_Factories = list_types.listof(
    Factory,
    name="listof_Factories",
    dataType='list.Factories',
)
Exemple #2
0
		if isinstance( value, (tuple, list)) and value and len(value) < 4:
			items = {}
			for item,name in zip(value,['name','default','baseType'][:len(value)]):
				items[name] = item
			return cls( **items )
		elif isinstance( value, str ):
			return cls( name = value )
		elif isinstance( value, dict ):
			return cls( **value )
		raise TypeError( """Don't know how to convert %r to a %s object"""%( value, cls.__name__))
	coerce = classmethod(coerce)

	
listof_Arguments = list_types.listof(
	Argument,
	name = "listof_Arguments",
	dataType = 'list.Arguments',
)

class Callable( propertied.Propertied ):
	"""Modelling of a callable Python object"""
	name = common.StringProperty(
		'name', """The callable object's-name (may be different from underlying object)""",
	)
	implementation = basic.BasicProperty(
		"implementation", """The underlying implementation (callable Python object)""",
	)
	arguments = common.ListProperty(
		'arguments', """Argument-list for the callable object""",
		baseType = listof_Arguments,
	)
Exemple #3
0
		if self.foreignFields:
			return self.foreignFields
		else:
			table = self.lookupName( self.foreignTable )
			keys = table.getUniqueKeys()
			assert keys, """Foreign-key constraint %r references table %r which has no unique keys!"""%(
				self, table.name,
			)
			return keys[0]
			
	
def constraint_factories( cls ):
	return [ ForeignKeyConstraint, PrimaryConstraint, UniqueConstraint, CheckConstraint ]
ConstraintSchemas = list_types.listof(
	ConstraintSchema,
	name = "ConstraintSchemas",
	dataType = "list.ConstraintSchemas",
	factories = classmethod( constraint_factories ),
)

class SequenceSchema( Schema ):
	"""A sequence object used for implementing e.g. serial fields"""
	dbObjectType = "SEQUENCE"
	name = common.StringProperty(
		'name', """Name of the sequence""",
	)
	increment = common.IntegerProperty(
		'increment', """Amount to increment on each "next" call""",
		defaultValue = 1,
		setDefaultOnGet = 0,
	)
	ascending = basic.BasicProperty(
                                          'baseType'][:len(value)]):
                items[name] = item
            return cls(**items)
        elif isinstance(value, str):
            return cls(name=value)
        elif isinstance(value, dict):
            return cls(**value)
        raise TypeError("""Don't know how to convert %r to a %s object""" %
                        (value, cls.__name__))

    coerce = classmethod(coerce)


listof_Arguments = list_types.listof(
    Argument,
    name="listof_Arguments",
    dataType='list.Arguments',
)


class Callable(propertied.Propertied):
    """Modelling of a callable Python object"""
    name = common.StringProperty(
        'name',
        """The callable object's-name (may be different from underlying object)""",
    )
    implementation = basic.BasicProperty(
        "implementation",
        """The underlying implementation (callable Python object)""",
    )
    arguments = common.ListProperty(
Exemple #5
0
"""(preliminary) Model of a Factory Callable object"""
from basictypes import list_types, callable


class Factory(callable.Callable):
    """An object intended to create instances of a type

    The factory allows you to create instances of a type
    through the GUI.  Most factories will allow for
    entirely-default calling (i.e. Factory() creates a
    new, valid instance).  Others may require interactive
    definition of certain parameters.
    """


listof_Factories = list_types.listof(
        Factory,
        name="listof_Factories",
        dataType='list.Factories',
)
Exemple #6
0
	these extra properties to forward all actions to
	the source-table's field for standard editing
	actions.
	"""
	sourceTable = basic.BasicProperty(
		'sourceTable', """The source-table schema for this field (may be null)""",
		baseType = dbschema.TableSchema,
	)
	sourceField = basic.BasicProperty(
		'sourceField', """The source-field schema for this field (may be null)""",
		baseType = dbschema.FieldSchema,
	)

ViewFieldSchemas = list_types.listof(
	ViewFieldSchema,
	name = "ViewFieldSchemas",
	dataType = "list.ViewFieldSchemas",
)

class JoinTable( dbschema.Schema ):
	"""A Join of a table, basically just a name:table item"""
	name = common.StringProperty(
		'name', """Name of the table (required)""",
		defaultFunction = lambda prop, client: client.table.name,
	)
	table = basic.BasicProperty(
		'table', """Table object which participates in the schema""",
		baseType = dbschema.TableSchema,
	)
	def check( cls, value ):
		"""Check that value is a proper instance of this class"""