On Tuesday 26 February 2002 03:56 am, Erwin J.van Eijk wrote:
> I'm using MiddleKit in a non-web environment as a O-R mapper. It's
> idea is quite good, but I have two small problems:
> 1. The links between two tables get screwed up. Say I have a FooType
> table. ft = FooType()
> Then I create an instance of Bar which has a field type: FooType.
> This should work, right?
> b = Bar()
> For some reason, b.type becomes a value which has no relation
> whatsoever to a FooType record.
Obj refs in MK are 64 bit values where the first 32 are a class id and
the last 32 are an object id. These are pretty much necessary for
general object references (you need the class id to know what table to
fetch the object from).
I plan on allowing some kind of "simple reference" type or option that
would allow for only storing the object id, in those cases where you
know there is only one class.
For example, in my own application, we have User, but no subclasses of
User and likely never will. So all refs to User could be simple obj
ids. However, we have about 8-10 subclasses of MessageGenerator, so
MessageGenerator refs require the full 64 bit value.
I don't have a schedule as to when I'll get to this enhancement and it
won't help for those cases where the target object could be from more
than one class.
> 2. If I create a lot of instances, and I try to connect them, I run
> into problems with MySQL:
> % ./main.py /var/log/messages
> /var/log/messages had 2656 lines
> Traceback (most recent call last):
> File "./main.py", line 69, in ?
> File "./main.py", line 65, in main
> File "./MiddleKit/Run/ObjectStore.py", line 266, in saveChanges
> File "./MiddleKit/Run/SQLObjectStore.py", line 166, in
> commitInserts File "./MiddleKit/Run/SQLObjectStore.py", line 179, in
> _insertObject File "./MiddleKit/Run/SQLObjectStore.py", line 311, in
> executeSQL File "./MiddleKit/Run/SQLObjectStore.py", line 341, in
> connectionAndCursor File "./MiddleKit/Run/MySQLObjectStore.py", line
> 33, in newConnection File
> "/usr/lib/python2.1/site-packages/MySQLdb/__init__.py", line 63, in
> return apply(Connection, args, kwargs)
> File "/usr/lib/python2.1/site-packages/MySQLdb/connections.py",
> line 67, in __init__
> self._db = apply(connect, args, kwargs2)
> _mysql_exceptions.OperationalError: (1040, 'Too many connections')
> What is going on, am I doing something wrong?
That's interesting. Haven't seen it before, but I know today's MK makes
more connections than older versions due in part to mysql's change of
thread_safety from something like 2 to 1. However, I think this can be
addressed in MK.
If your app is not too big and you can share it, I could possibly look
at it this week. You could send it to me directly as a tar.gz. Please
remove .pyc files if you do.
Thanks for including your products and version #s in your report.