J
Jorgen Bodde
Hi All,
I am wrestling with some architecture inside my app. Let's say I have
a tunings collection, which contains e.g. 23 types of guitar tunings.
In my song object I want to restore a relation between one of the
tuning objects inside the tunings module.
I already figured out I need somethign like a global collection inside
the tunings module,. but how global is it? When I am inside my app
object, and import the tunings module, can I access the same global
class as when I am inside my songs module and load the tunings module?
So for some pseudo code:
--- songs.py
import tunings
class Song(object):
def __init__(self, tuning_id):
# create relation with tuning object
self._tuning = tunings.GetTuningById(tuning_id)
-- app.py
import tunings
# get list of tunings
for t in tunings._tuningCollection:
print 'Tuning:', t._name
----
So basically I want to access the same global list in both modules,
but not re-create the list in every module since it should be restored
by the database layer once.
Is this as simple as defining a global variable in the module tunings
which is available on both imports, or should I do it different, and
then my next question ofcourse is, how ?
Thanks for any advice, I do not want to make a global manager object
that I need to pass around all the time, that would be silly..
Regards,
- Jorgen
I am wrestling with some architecture inside my app. Let's say I have
a tunings collection, which contains e.g. 23 types of guitar tunings.
In my song object I want to restore a relation between one of the
tuning objects inside the tunings module.
I already figured out I need somethign like a global collection inside
the tunings module,. but how global is it? When I am inside my app
object, and import the tunings module, can I access the same global
class as when I am inside my songs module and load the tunings module?
So for some pseudo code:
--- songs.py
import tunings
class Song(object):
def __init__(self, tuning_id):
# create relation with tuning object
self._tuning = tunings.GetTuningById(tuning_id)
-- app.py
import tunings
# get list of tunings
for t in tunings._tuningCollection:
print 'Tuning:', t._name
----
So basically I want to access the same global list in both modules,
but not re-create the list in every module since it should be restored
by the database layer once.
Is this as simple as defining a global variable in the module tunings
which is available on both imports, or should I do it different, and
then my next question ofcourse is, how ?
Thanks for any advice, I do not want to make a global manager object
that I need to pass around all the time, that would be silly..
Regards,
- Jorgen