[TIP] Please help for StorageMediaNotFound
Kumar McMillan
kumar.mcmillan at gmail.com
Wed Nov 18 10:48:52 PST 2009
On Wed, Nov 18, 2009 at 12:34 PM, Madhusudan C.S <madhusudancs at gmail.com> wrote:
> The data models for our app doesn't reside in a single Python module, but
> spread across several Python modules in the package called models.
>
> Can you please tell me what should I do in this case? How should my
>
> datafixture = GoogleDatastoreFixture(env=models, style=NamedDataStyle()) #
> Note models is a package containing models in each file, for example user
> model is in the module user.py.
> self.data = datafixture.data(datasets.UserData)
ok, I see. The env keyword can be a dictionary. So you can type out
every model class, like:
env={'User': models.User, 'Other': other_models.Other, ...}
but if that's not feasible then you'll have to make a proxy that acts
like a dictionary. Something like this should work:
class MultiModuleEnv(object):
def __init__(self, modules):
self.modules = modules
def __getitem__(self, name):
for m in self.modules:
if hasattr(m, name):
return getattr(m, name)
raise KeyError("%s not found in %r" % (name, self.modules))
datafixture = GoogleDatastoreFixture(env=MultiModuleEnv([models,
other_models, more_models]), ...)
>
> be rewritten. Please help me.
>
>>
>> >
>> > Traceback (most recent call last):
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/tests/app/soc/modules/ghop/views/models/test_task.py",
>> > line 130, in setUp
>> > self.data.setup()
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/base.py",
>> > line 71, in setup
>> > self.loader.load(self.data)
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
>> > line 193, in load
>> > self.wrap_in_transaction(loader, unloading=False)
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
>> > line 310, in wrap_in_transaction
>> > routine()
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
>> > line 192, in loader
>> > self.load_dataset(ds)
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
>> > line 217, in load_dataset
>> > self.attach_storage_medium(ds)
>> > File
>> >
>> > "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
>> > line 375, in attach_storage_medium
>> > self.Medium, ds.meta.storable_name, ds, repr_env))
>> > StorageMediaNotFound: could not find <class
>> > 'fixture.loadable.google_datastore_loadable.EntityMedium'> 'User' for
>> > dataset <UserData at 0xa84decc with keys ['user_0001']> in self.env
>> > (<type
>> > 'module'>)
>> >
>> > Can some one please tell me why I get this error and what I should to do
>> > to
>> > fix this?
>> >
>> >
>> > --
>> > Thanks and regards,
>> > Madhusudan.C.S
>> >
>> > Blogs at: www.madhusudancs.info
>> > My Online Identity: madhusudancs
>> >
>> > _______________________________________________
>> > testing-in-python mailing list
>> > testing-in-python at lists.idyll.org
>> > http://lists.idyll.org/listinfo/testing-in-python
>> >
>> >
>
>
>
> --
> Thanks and regards,
> Madhusudan.C.S
>
> Blogs at: www.madhusudancs.info
> My Online Identity: madhusudancs
>
More information about the testing-in-python
mailing list