[Grok-dev] BasicSourceFactory again
Jan Ulrich Hasecke
janulrich.hasecke at web.de
Fri Oct 19 15:15:42 EDT 2007
Hi,
after finishing some jobs I now can do some grokking work again.
As you know, we are developing a zoo game with grok. We add cages in
the zoo with a addform in a choice field we reference a source
defined by BasicSourceFactory.
class GehegeListe(BasicSourceFactory):
"""This is the list of available cages for animals"""
def getValues(self):
return [_(u'Elefantengehege'),_(u'Giraffengehege'), _(u'Paviankäfig')]
The form triggers a method which creates the cage. According to the
number of animals, which shall live in the cage and depending on the
kind of cage the building costs are increasing or decreasing. A
Paviankäfig is cheeper than a Elefantengehege. All this is defined in
the method, which creates the cage.
def bauegehege(self, name, groesse, tierart, kosten):
"""creates a cage object.
FIXME: use something better than if if if"""
if name == _(u'Elefantengehege'):
tierart = _(u'Elefant')
kosten = groesse*150000
if name == _(u'Paviankäfig'):
tierart = _('Pavian')
kosten = groesse*80000
if name == _(u'Giraffengehege'):
tierart = _('Giraffe')
kosten = groesse*100000
self[name] = gehege.Gehege(name, groesse, tierart,kosten)
self.konto -= self[name].kosten
but this is not what I want.
I would like to define costs and maybe some other criteria before and
then use them in the BasicSourceFactory and in the method "bauegehege".
How can i achieve this?
Create cage-objects with all attributes at startup and query them
while creating a BasicSourceFactory? Or define a central dictionary
with all values?
Any ideas?
juh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Signierter Teil der Nachricht
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20071019/29e2ed61/PGP.bin
More information about the Grok-dev
mailing list