ANNOUNCE: xsdb -- the eXtremely Simple Database goes alpha

D

David Mertz, Ph.D.

|[email protected] (David Mertz, Ph.D.) wrote:
|> >>> def echo():
|> ... message = [None]
|> ... while message[0] != "EXIT":
|> ... yield message
|> ...
|> >>> for mess in echo():
|> ... if mess[0] is not None: print mess[0]
|> ... mess[0] = raw_input("Word: ")

(e-mail address removed) (Michele Simionato) wrote previously:
|A more verbose but arguably more elegant way would be to wrap the
|generator in a class. Let me repost some code I wrote some time ago.
|class MyIterator(Iterator):
| def __gen__(self):
| self.x=1
| yield self.x # will be changed outside the class
| yield self.x
|
|iterator=MyIterator()
|print iterator.next()
|iterator.x=5
|print iterator.next()

I don't disagree, of course, with Michele's class-based approach. For
something fleshed out, his style lets you do a lot more with the
underlying class.

But there *is* something awfully elegant about the function-like
definition syntax of simple generators. Doing what I do in the simple
example--yielding a mutable object, and manipulating that object outside
the generator--feels very Pythonic to me. I use a list for this, but a
different mutable object would work similarly (a dictionary, instance,
shelve, etc.)

But obviously, keep both styles in mind; either might be a good
solution to a problem. It just depends on your needs and coding style.

Yours, David...

--
mertz@ | The specter of free information is haunting the `Net! All the
gnosis | powers of IP- and crypto-tyranny have entered into an unholy
..cx | alliance...ideas have nothing to lose but their chains. Unite
| against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------
 
P

Paul McGuire

Skip Montanaro said:
Twisted.

Istvan> The question that needs to be answered is whether it would be
Istvan> worth to wrestle with those rather than locking out the vast
Istvan> majority of the potential users.

I imagine Aaron provides the code (it is hosted on SF, after all). All you
need to do is port it to use Twisted or Medusa, then feed the diffs back to
Aaron. If it results in broader reach for xsdb without making the existing
code a nightmare to maintain, he'll probably fold it in.

Skip
Well, actually, retro-installing Stackless isn't all that difficult. I had
already upgraded to Python 2.3, but wanted to experiment with xsdb. I
installed Python2.2 in its own tree, downloaded Stackless, and copied the
compiled .libs into the Python 2.2 tree. Then went to the xsdb directory,
and wrote a short setup.bat file to tweak my PATH to look at Python2.2 ahead
of Python2.3, and then run the xsdb startup script. Now I can fire up an
xsdb server using Python2.2+Stackless, and then hit at it from my mainline
Python 2.3 client environment.

Since this Stackless requirement would only be needed on server machines,
this really shouldn't impair any serious deployment. xsdb has some very
interesting features that, if they work out, will be well worth this minor
inconvenience.

-- Paul
 
C

Christian Tismer

A.M. Kuchling wrote:
....
Sheesh, Aaron announces a database system that looks really spiffy from the
examples, like ZODB without the pain of ExtensionClass, and the first two
responses are griping about one aspect of it. Sometimes folks don't know
when they're well-off. (Now if only he'd released it before I wrote the
PyCon proposal tracker using PostgreSQL...)

Yes, too bad. By that, Stackless would sit in the PyCon
proposal tracker. (and I want to have it everywhere)

happy Xmas -- chris

--
Christian Tismer :^) <mailto:[email protected]>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
 
P

Paul Rubin

Christian Tismer said:
Yes, too bad. By that, Stackless would sit in the PyCon proposal
tracker. (and I want to have it everywhere)

I think I started the griping; the issue is having to install a special
Python implementation built around a feature with just one maintainer.
On technical grounds Stackless is great and I hope PyPy can implement
something like it.
 
W

Wolfgang Lipp

hi,

thanks for some great ideas and implementations. i'm in the course of
testing out whether xsdb could be useful for my present project,
and i like it! one minor thing i've found is that when i create
a database, populate it, commit, and then re-open it, i get a nasty
xsdb.xsdbExceptions.RollBackError: write attempt after younger read
exception. this turned out to be avoidable by placing time.sleep(1)
between the commit and the re-open. i guess the culprit might be
on line 34 of xsdb\Connection.py: self.startTime = int(time()).
maybe this should be changed to sth like int(time()*TIME_GRANULARITY),
with the constant being a number in the hundreds or thousands?

_wolf
 
A

Aaron Watters

hi,

....when i create
a database, populate it, commit, and then re-open it, i get a nasty
xsdb.xsdbExceptions.RollBackError....

Thank you very much for finding this problem!

Double apologies: Sorry that I made this bug and sorry that I didn't
respond to your message earlier. I decided take a different approach
than the one you suggested that fixes the problem systematically (and
required a lot of changes and testing).

Basically I hadn't considered
the possibility that a program might open two direct connections
to a database within the same minute (because my machine is so slow :( ).
If you do make very fast connections I added the ability to clear out
all the timestamp information using a special keyword argument to the
connection initializer. Here is the test case (fastconnect.py):

===
"test connecting and then reconnecting to a database quickly"

def test(filename="data/fastconnect.dat"):
import time
now = time.time()
from xsdb.KISSBaseHierarchy import xsdb
print "testing fast reconnection"
connection = xsdb(filename, startup=1)
t = connection.transaction()
t.add("object1", "this is the object")
t.commit()
t = connection.transaction()
t.add("object2", "this is the other object")
t.commit()
connection = None
# must clear the connection for fast reconnect!
connection = xsdb(filename, startup=0, clear=1)
print "fast reconnect completed in ", time.time()-now

if __name__=="__main__":
test()
===

If you omit the "clear=1" above you get the exception you reported.

I just uploaded a new file release which includes this and a number
of other bugfixes, enhancements, doc changes, etcetera. Get it at:

http://xsdb.sourceforge.net

-- Aaron Watters

===
You can't talk to a man
When he don't wanna understand -- Carole King
 
A

Aaron Watters

Basically I hadn't considered
the possibility that a program might open two direct connections
to a database within the same minute...

whoops I meant "second" not "minute". This may not happen very
often because only one direct connection is permissable at any
given moment (but many indirect connections are okay).
-- Aaron Watters

===
TO INFINITY AND BEYOND
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top