[kforge-dev] Factoring out the KForge core
Rufus Pollock
rufus.pollock at okfn.org
Thu May 11 07:17:41 UTC 2006
I meant to send this message over a month ago but somehow it ended up in
my drafts folder. Despite the delay it is still a useful update -- the
core refactoring though mostly done is not entirely finished.
Regards,
Rufus
Factoring out the KForge core
=============================
A substantial part of iteration 2 (continuing iteration 3) was taken up
with factoring out a KForge core that could then be used by both KForge
and the Open Registry.
This required the implementation of an inversion of control pattern
based on Service Locator so as to allow for a given project to
'override/plugin' replace a given domain class provided by the core
(such as Person) with its own implemenation. This is valuable because it
allows us to reuse whole subcomponents of the domain model such as the
access control section across projects while still allowing the
specialization of related domain objects (person, project etc) in a
given project.
This change has also led to a change (and cleaning up) of the standard
way to obtain basic registry and functionality such as the
DomainRegistry and Commands.
Old Style
=========
{{{
import kforge.system
sysdict = kforge.system.SystemDictionary()
import kforge.dom
r = kforge.dom.DomainRegistry()
joe = r.persons['joe']
import kforge.commands
cmd = kforge.commands.PersonRead('joe')
cmd.execute()
joe = cmd.person
}}}
New Style
=========
{{{
import kforge
app = kforge.getApplication() # can use shorter kforge.getA()
sysdict = app.dictionary
# if you need sysdict before setting up whole app - which e.g. creates
db conn
# sysdict = RequiredFeature('SystemDictionary')
r = app.registry
joe = r.persons['joe']
cmdClass = app.commands['PersonRead']
cmd = cmdClass('joe')
cmd.execute()
joe = cmd.person
}}}
More information about the kforge-dev
mailing list