(n.b. newbie to python, newbie to turbogears -- so I may be using the
wrong approach, but I think this is still a bug)

When deploying a "setter" function within a SQLObject class (as per
SQLObject documentation), CatWalk overwrites the value of the setter
function based on the value previously present (and still in the form
entry).  This may be too complicated to correct in a simple
datafill/object browser tool -- but I figured I could raise the point.

The setter function in the Project class works flawlessly, however the
_set_context() function in the Action class works from the python
shell, but as SQLObject debuggin shows the CatWalk applet rewrites all
values to the class whether changed within the interface or not.  This
causes the value the setter function set to be changed again to the
value in the web form.  I haven't looked at the CatWalk code to discern
if this is deterministic behavior or not (how does CatWalk select the
order of object modifications?)

# my classes below -- yes it's Yet Another Lame Attempt At A GTD Tool.
# The idea being to reset the context of an Action to the Project if it
is re-assigned.
# I think that is an acceptable feature of the data model.
class Action(SQLObject):
    name = StringCol(length=255)
    notes = StringCol(default=None)
    completed = BoolCol(default=False)
    context = ForeignKey('Context')
    project = ForeignKey('Project')

    def _set_project(self, value):
        self.context = Project.get(value).context
        self._SO_set_project(value)


class Project(SQLObject):
    name = StringCol(length=255)
    notes = StringCol()
    completed = BoolCol(default=False)
    context = ForeignKey('Context')
    actions = MultipleJoin('Action')

    def _set_context(self, value):
        for a in self.actions:
            a.context = value
        self._SO_set_context(value)

class Context(SQLObject):
    name = StringCol(length=20, unique=True)
    actions = MultipleJoin('Action')
    projects = MultipleJoin('Project')

Regards,
Kevin M. Dulzo

Reply via email to