Example #1
0
    def __init__(self):
        # Do not allow initialization of the abstract base class
        assert self.__class__ is not Table, (
            'Only subclasses of Table can be instantiated!')

        # Record the definition order
        self.__definition_serial__ = util.get_next_definition_serial()
        
        # Clone columns, constraints and indexes
        self._column_list = [column.clone(self) for column in self._column_list]
        self._constraint_list = [constraint.clone(self) for constraint in self._constraint_list]
        self._index_list = [index.clone(self) for index in self._index_list]
        self._trigger_list = [trigger.clone(self) for trigger in self._trigger_list]
        
        # Override the model definitions with the bound instances
        for column in self._column_list:
            setattr(self, column.name, column)
        for constraint in self._constraint_list:
            setattr(self, constraint.name, constraint)
        for index in self._index_list:
            setattr(self, index.name, index)
        for trigger in self._trigger_list:
            setattr(self, trigger.name, trigger)
            
        # Reassign the primary key
        if self._primary_key:
            self._primary_key = getattr(self, self._primary_key.name)
Example #2
0
 def __init__(self):
     
     assert self.__class__ is not BaseConstraint, (
         'Only subclasses of BaseConstraint can be instantiated!')
     
     # Record the definition order
     self.__definition_serial__ = util.get_next_definition_serial()
Example #3
0
 def __init__(self, procedure_name, *procedure_parameters):
     
     assert self.__class__ is not BaseTrigger, (
         'Only subclasses of BaseTrigger can be instantiated!')
     
     # Record the definition order
     self.__definition_serial__ = util.get_next_definition_serial()
     
     self.procedure_name = procedure_name
     self.procedure_parameters = procedure_parameters
Example #4
0
    def __init__(self, *columns):
        
        assert self.__class__ is not BaseIndex, (
            'Only subclasses of BaseIndex can be instantiated!')
        
        # Record the definition order
        self.__definition_serial__ = util.get_next_definition_serial()

        # Verify
        assert columns, 'This index must be applied to at least one column!'
        self.columns = columns
Example #5
0
    def __init__(self, doc=None):
        
        assert self.__class__ is not BaseColumn, (
            'Only subclasses of BaseColumn can be instantiated!')
        
        # Record the definition order
        self.__definition_serial__ = util.get_next_definition_serial()

        # Store column documentation if any
        if doc is not None:
            self.doc = doc
Example #6
0
 def __init__(self, language, argument_list, result, body):
     
     assert self.__class__ is not BaseProcedure, (
         'Only subclasses of BaseProcedure can be instantiated!')
     
     # Record the definition order
     self.__definition_serial__ = util.get_next_definition_serial()
     
     self.language = language
     self.argument_list = argument_list
     self.result = result
     self.body = body