473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Where does shelve look for unshelved class definitions?

Hi all,

I have a python module foo.py which contains:

class A(object): ...
class B(object): ...

As well as a class that uses shelve (which in turn is
using dumbdbm):

class foo(object): ...
// uses a shelve internally

The methods of foo shelve and restore A and B instances
*but* shelve seems to be looking in the wrong places for
the definitions of A and B when they're "unshelved",
giving the error:

AttributeError: 'module' object has no attribute 'A'

How can I persuade shelve to look in other namespaces for
A and B?

Any advice much appreciated,
Stu
Jul 18 '05 #1
1 1425
BG
This looks like a problem I had recently. Please take a look at this
news thread:

http://groups.google.com/groups?hl=n....nl%26rnum%3D1

I hope this link works ;-)

Berry.
Stuart Hungerford wrote:
Hi all,

I have a python module foo.py which contains:

class A(object): ...
class B(object): ...

As well as a class that uses shelve (which in turn is
using dumbdbm):

class foo(object): ...
// uses a shelve internally

The methods of foo shelve and restore A and B instances
*but* shelve seems to be looking in the wrong places for
the definitions of A and B when they're "unshelved",
giving the error:

AttributeError: 'module' object has no attribute 'A'

How can I persuade shelve to look in other namespaces for
A and B?

Any advice much appreciated,
Stu

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
1
by: Matthew Barnes | last post by:
This may be a naive question, but since Python 2.3 added a handy little DictMixin class to its UserDict module it seems to me like UserList.ListMixin and maybe even UserString.StringMixin should...
1
by: Eric Wichterich | last post by:
Hello Pythonistas, I use Python shelves to store results from MySQL-Queries (using Python for web scripting). One script searches the MySQL-database and stores the result, the next script reads...
0
by: Ray O | last post by:
I have read a number of threads relating to problems with shelve, but I couldn't find one directly related my experience, so I would appreciate some advice. The closest one ended with a...
4
by: Terry Hancock | last post by:
I only just recently had a look at the shelve module, and it looks pretty handy, my only question being, what if I really want two shelves? Must I use two files? Also, it seems strange that...
1
by: Paul Rubin | last post by:
class x: pass z = x() z.a = 'a' d = {'a': z} for i in range(5): print id(d) prints the same id 5 times as you'd expect.
3
by: Michele Petrazzo | last post by:
Hi, I'm trying a script on a debian 3.1 that has problems on shelve library. The same script work well on a fedora 2 and I don't know why it create this problem on debian: #extract from my code...
1
by: max.aginaga | last post by:
Hi everyone I've come across the following problem: on two different linux machines, both running python 2.5 (r25:51908), I have the same file 'd.dat'. The md5 checksums are the same. Now, on...
0
by: Gabriel Genellina | last post by:
En Mon, 28 Apr 2008 02:08:31 -0300, tarun <tarundevnani@gmail.comescribió: By default, each time you do d you get a *different* object. A shelve isn't very smart: it stores a string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.