[kforge-dev] Re: [kforge-user] kforge-config-rebuild problem

John Bywater john.bywater at appropriatesoftwarefoundation.org
Mon Jan 16 17:51:30 UTC 2006

Hi Mark,

I think I've now fixed kforge for SQLObject 0.7.

Firstly, ...

Mark Constable wrote:


>The current
>INSTALL doc mentions kforge-test-run but I don't seem to have that in bin.

Can you see a kforge-test in bin? The kforge-test-run was renamed 

I'll update the INSTALL doc now....

Anyway, the method we were discussing needs to look like:

        def addPersistenceAttribute(self, className, attribute):
            mapperClass = self.getRecordClass(className)
            mapperAttribute = mapperClass.meta.addAttribute(attribute)
            sqlAttribute = mapperAttribute.createNamedMapperClassAttribute()
            if hasattr(mapperClass.sqlmeta, 'addColumn'):
                addColumn = mapperClass.sqlmeta.addColumn
                delColumn = mapperClass.sqlmeta.delColumn
                addColumn = mapperClass.addColumn
                delColumn = mapperClass.delColumn
            # todo: check if table already has column
                addColumn(sqlAttribute, changeSchema=True)
            except:  # table has column, but class needs field
                    delColumn(sqlAttribute, changeSchema=False)
                    addColumn(sqlAttribute, changeSchema=False)
#                    pass  # todo: log warning?

Additionally, to eliminate the "_table" depractation warning:

1. Search for the getSQLObjectAttributes method in that file

    def getSQLObjectAttributes(self):

2. Comment out (or delete) these two commented-out lines:

    def getSQLObjectAttributes(self):
        mapperAttributes = {}
        #if self.dbName:
        #    mapperAttributes['_table'] = self.dbName
        for a in self.attributes:
            mapperAttributes[a.dbName] = a.createMapperClassAttribute()
        return mapperAttributes

3. Search for the MetaMapper.createMapperClass method (just above the 
getSQLObjectAttributes method):

    def createMapperClass(self, baseClass):

4. Change the bottom of that method so it looks like:

    def createMapperClass(self, baseClass):
        mapperAttributes = self.getSQLObjectAttributes()
        mapperAttributes['meta'] = self
        mapperAttributes['map'] = {}
        mapperAttributes['map']['isUnique'] = self.isUnique
        mapperAttributes['_connection'] = DatabaseFacade().getConnection()
        mapperClass = self.createClass(self.domName, baseClass, 
        if self.dbName:
            mapper.sqlmeta.table = self.dbName
        return mapper

Now try "bin/kforge-db rebuild", and then "bin/kforge-test". To run the 
tests, you may need to change "system_mode" in "etc/kforge.conf" from 
"production" to "development".

Any questions, or other problems, just send me another message!



More information about the kforge-dev mailing list