コード例 #1
0
ファイル: model.py プロジェクト: ddd00a/plato
    def __setup_columns(self):
        '''
            Find all the columns attached to this model and assign storage.            
        '''
        column_id_util = ColumnIdentifierUtil(self)

        for prop_name in dir(self):

            try:
                prop = getattr(self, prop_name)
            except AttributeError:
                # property has not been initialized yet, ignore and continue
                continue

            if Column.is_column(prop):
                column = Column.get_column(prop)
                col_name = prop_name
                col_storage_id = column_id_util.get_column_identifier(column)
                storage = self.service_locator.get_storage(col_storage_id)
                self.columns[col_name] = BoundColumnCall(column, storage, self)

            elif SubModel.is_submodel(prop):
                submodel_name = prop_name
                submodel = prop
                self.submodels[submodel_name] = SubModelBinding(submodel, self)
コード例 #2
0
 def testSingleModelGetColumnId(self):
     
     m = ModelSetupUtility.setup_test_model(TestModel, 'test_model_1')
     util = ColumnIdentifierUtil(m)
     col_id = util.get_column_identifier(m.some_test_col)
     
     self.assertEqual(col_id, 'test_model_1#some_test_col')
コード例 #3
0
ファイル: model.py プロジェクト: ande7590/plato
    def __setup_columns(self):
        '''
            Find all the columns attached to this model and assign storage.            
        '''        
        column_id_util = ColumnIdentifierUtil(self)

        for prop_name in dir(self):
            
            try:            
                prop = getattr(self, prop_name)
            except AttributeError:
                # property has not been initialized yet, ignore and continue
                continue
            
            if Column.is_column(prop):
                column = Column.get_column(prop)
                col_name = prop_name                                
                col_storage_id = column_id_util.get_column_identifier(column)
                storage = self.service_locator.get_storage(col_storage_id)                
                self.columns[col_name] = BoundColumnCall(column, storage, self)
        
            elif SubModel.is_submodel(prop):
                submodel_name = prop_name
                submodel = prop
                self.submodels[submodel_name] = SubModelBinding(submodel, self)            
コード例 #4
0
 def testNestedModelGetColumnId(self):
     
     parent_model = ModelSetupUtility.setup_test_model(TestModel, \
                                                       'parent_model')
     
     child_model = ModelSetupUtility.setup_test_model(TestModel, \
         'child_model', parent_model=parent_model)
     
     util = ColumnIdentifierUtil(child_model)
     col_id = util.get_column_identifier(child_model.some_test_col)
     
     self.assertEqual(col_id, 'parent_model.child_model#some_test_col')