I’ve created two objects outside the database. One is SERVICES and one is MODULES.
I’d like to be able to get all MODULES related to a certain service. For instance, for the below example, I’d like to issue a command that basically says “Get list of Module Objects related to Service with key FACEBOOK” and have it return the two last Module objects.
class Module(object):
def __init__(self, key, service, name):
self.key = key
self.service = service
self.name = name
ALL_MODULES = [
Module(
'TWT',
SERVICES['TWITTER'],
'Twitter Tweets',
),
Module(
'FBC',
SERVICES['FACEBOOK'],
'Facebook Comments',
),
Module(
'FBP',
SERVICES['FACEBOOK'],
'Facebook Posts',
),
]
#dict of the above list
MODULES = dict([(s.key, s) for s in ALL_MODULES])
I assume that
SERVICESreturns aService-class having anname-attribute. If this is true, then you can get all modules related to a service (FACEBOOK for example) like this: