Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how saving/retreiving python code from DB ?

5 views
Skip to first unread message

vincent delft

unread,
Jul 18, 2001, 9:43:16 AM7/18/01
to
I'm looking for a module that allow us to store/import python code into
DB (bsddb for example) instead of a file.

like "import" retreives coding in flat files, is there a way to retreive
coding for a DB ?
something like :
db.open('db')
db.dbimport('module1')
print module1.test()

where 'time' whas previously save into the DB as a Python code :
class module1:
def test(self):
print "work"

Thanks

Joonas Paalasmaa

unread,
Jul 18, 2001, 10:00:12 AM7/18/01
to

Alex Martelli

unread,
Jul 18, 2001, 10:07:12 AM7/18/01
to
"vincent delft" <vde...@itmasters.com> wrote in message
news:3B559274...@yahoo.com...

> I'm looking for a module that allow us to store/import python code into
> DB (bsddb for example) instead of a file.
>
> like "import" retreives coding in flat files, is there a way to retreive
> coding for a DB ?

You can write your own version of __import__ and set it as the
thus-named attribute of the __builtin__ module -- statements
import and from will thereafter use your version rather than
the built-in kind. Is this what you want...?


Alex

Skip Montanaro

unread,
Jul 18, 2001, 12:18:58 PM7/18/01
to Alex Martelli, pytho...@python.org
vincent> I'm looking for a module that allow us to store/import python
vincent> code into DB (bsddb for example) instead of a file.

Alex> You can write your own version of __import__ ...

I believe there was a custom __import__ floating around at one time that
allowed imports from zipfiles (part of some sort of freeze tool that Fredrik
Lundh wrote, perhaps?). If that code can be located, it would probably
serve as a useful template for importing code from other structured files.
Sorry, my memory is foggy on the details.

--
Skip Montanaro (sk...@pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/

Erno Kuusela

unread,
Jul 18, 2001, 2:35:10 PM7/18/01
to
In article <mailman.995473171...@python.org>, Skip
Montanaro <sk...@pobox.com> writes:

| I believe there was a custom __import__ floating around at one time that
| allowed imports from zipfiles (part of some sort of freeze tool that Fredrik
| Lundh wrote, perhaps?).

<URL: http://starship.python.net/crew/gmcm/archives.html> ?

-- erno

0 new messages