Neato-Keen
I just wrote an almost completely generic object-oriented wrapper for Metakit records in 35 lines of Python code. Which includes 4 lines of comments, 5 blank lines and 5 lines of debugging code.
It handles searching by the primary key, creation if it's not found, and completely transparent transferral of data from the argh. Uzgbf. Never mind. Back to the drawing board. Update: I just wrote an even more almost completely generic object-oriented blah blah, same length (well, I took out the 5 debugging lines), only this time it doesn't screw everything up when two threads try to manipulate the same record. I call it MEOW: The Metakit Easy Object Wrapper. Hooray for getattr, setattr and hasattr! I've never tinkered with Python objects like this before, but after only a couple of hours it all makes sense. In fact, it's obvious that this is how to do it. (Actually, there's probably an even simpler way that I have yet to find, but pfft. This is neat and understandable, very general, fast enough, and works.) A little more tweaking and I'll have a base class that I can derive all my objects from. Yay! (For those of you saying What?: Persistent objects made easy. For those of you still saying What?: Shiny programmer thing!) More Update: Poo! The mere presence of __getattr__ in a class definition causes the class to run like molasses in January. When I enable __getattr__, time taken to instantiate the class increases by a factor of 250 - even though it is never called! I may have to ask the Python wizards about this. Err, in theory it should never be called. In practice, it is getting called 2988 times for a single instantiation. Odd, that. Oh. Using hasattr() within the definition of __getattr__ is a Bad Thing. Access __dict__ directly. Right.
Posted by: Pixy Misa at 03:19 AM
Comments
1
M.E.O.W. wow! Isn't that something Calvin's friend Hobbes used to say?
Posted by: Lee at January 06, 2004 07:02 AM (BpPRO)
2
"Shiny Programmer Thing" made perfect sense.
Posted by: Victor at January 06, 2004 08:06 AM (L3qPK)
3
So this would have nothing to do with the "Blogging Software that Shall Not be Named"?
Posted by: Rob at January 06, 2004 10:52 AM (ZfpQw)
4
Err - This is the Blogging Software That Formerly Had No Name But Is Now Named Minx. Or at least, a clean-up of the persistent-object core thereof.
Posted by: Pixy Misa at January 06, 2004 12:27 PM (kOqZ6)
5
This is just IKEA furntiure instructions.
Posted by: Simon at January 06, 2004 02:44 PM (UKqGy)
Processing 0.0, elapsed 0.0081 seconds.
18 queries taking 0.0064 seconds, 13 records returned.
Page size 5 kb.
Powered by Minx 0.8 beta.