Recently I have been working on a Python application that required the use of connection pool to help speed up the processing time of the whole application. As making a new connection to the Database takes a lot of time. A connection pool is one of the best things to do to help speed this up.
I started to look all over the net and really never found out any good ideas for one that would support threading. So I set out to create my own. So here is what I came up with. MySQLPool Source
The MySQLPool class is the primary class for managing all the connections. It is never touched outside of the MySQL class. The MySQLPool class uses The Borg Pattern to store all the connections between all the instances and threads. As well as uses the Threading.Condition() to lock each connection as well as the connection dictionary.
The MySQL class is the primary class used by all the queries though out each thread and class. Each time you need to run a query. You create a new instance of MySQL passing it all your connection information in the form of a dictionary. Then call the query function with your SQL and replacement arguments (Just as if you where using the native cursor.execute() function).
When use correctly all your threads will be able to share the same connections and help speed things up.
from MySQLPool import *
query = MySQL(conn, True)
query.Query(“select * from company where company_id = %s”, (self.company_id))
if (int(query.rowcount) > 0):
for row in query.record:
Source Distro Package: MySQLPool-1.0.zip
Linux Tar package to come soon.
Recently I had the joy of having Microsoft do a write up on my Virtual Earth property search mash-up I did. They contacted The Group Inc about how its helped them out. They looked into how its helped out there customers find there new homes and what they have been liking about the ability to find real estate this way.
You can check out the write up at: http://dev.live.com/blogs/mashups/archive/2007/07/20/125.aspx
Well after trying to install PyXML 0.8.4 on my work computer and having no success do to the fact I don’t have Visual Studio. I have built a Windows Install for all that wish to use PyXML with there Python 2.5 installation.
As many of you will find out the PyXML project is no longer being maintained by the development crew. So finding a binary distribution of PyXML for Python 2.5 is hard. So to help in the struggle I have built the binary distribution for all to download. Please keep in mind this is really the first time I have created a binary installation for Python. So if something doesn’t work I’m sorry. Please comment back to this post and I will see what I can do.
Download: PyXML 0.8.4 for Win32 and Python 2.5
Please enjoy and keep up the Python work.
Edit: Updated link to new download location. Sorry for those that this was broken on.
jsColorPallet Version 2.0 Beta has been released for your enjoyment.
I have gone to a bit of effort to improve on the original version by decrease load times and process times as well as provide better dynamic Web 2.0 style support. You can now add color pallets on the fly as well as add the color pallet to other forms on the fly. I am working on getting some documentation out so that you all may better understand how to use it. Currently the Source Code is pretty well documented (Still needs some more for all the new functions and make updates to old). I hope this new version going forward will allow me to provide better functionality and controls for you all.
Version 2.0 Changes:
- Made Major Changes to the Class Structure
- Class initilization now takes a hash/object as the paramater
- Denoted all private functions with “_” at the begining
- Removed Old comments and unneeded functions
- Added function to allow for better API style calls
- Anytime addition of forms
- Anytime addition of color pallet definitions
- Added global callback meathod
- Changed the structure for defining bound fields to allow for more flexability of use
- Added Callbacks function support. Passes the returned HEX value to the function.
- Added support to change the Color Pallet title on a field by field level
Version 1.2 Changes:
- Seperated color pallets from jsColorPallet’s core class. In prep of extend color types. i.e. Hex, RGB
- Made slight changes to the colorpallet array structures. In prep of extend color types. i.e. Hex, RGB
- Changed the close button to an icon.
- Changed the next button to an icon.
- Added an example to the SVN.
- Made slight css/style changes.
- Changed code to no longer require a set veriable name
- Added optional paramater to append jsColorPallet to
- Fixed bug where jsColorPallet would override any onfocus events on form elements
Well as a lot of you may have been noticing around the CoLoCo site I have started making a lot of upgrades to the website and its layout. I am hoping that you all are enjoying all the new features that have been implemented and the new looks. I just wanted to give everyone a break down of what has been done and what I have planed for the future.
- Round Corners
- Side Bar Titles Updated
- Set correct titles
- Removed Special Font
- Titles are now text no longer images
- Flickr Avatar integration
- Reduced Load time thanks to Session storage.
- Sessions should be refreshed every 12 hours
- CoLoCo Members Roster
- Blinding Effect Added to Home Page Posts
- Blinding Effect will store to session. So when you come back to the article it will be in the last state you had it
- Avatars added to the Roster page
- Flickr Mash-Up to provide a Photo Gallery
- Updated SVN with the current website build. So that other LoCos maybe able to download it and improve upon it.
- Setup Flickr Mash-Ups to be configurable from the admin instead of editing scripts.
Also to all you other LoCos out there that want to have a website but do have the man power to setup or the scripting knowledge to do so. I will be uploading this all to SVN on code.google.com as well as setting up some documentation on how to deploy it. If you would like to use the current structure I can provide you with a copy and some information on how to set it up. Just email me on nerdynick [at] gmail (dot) com.
So for all you who are still visiting from StreetVibez. I am pleased to tell you all that me and DJ Lockdown are working on a new project that we hope to get out and released for everyone to check out. I currently can not tell you any details about the project other then it will be pretty cool. The only down side that you may drive a lot of you away from it is that it has nothing to do with music. I’m sorry.
But I hope you will all keep checking back for updates and further information about the project.
So in the little free time I have. I have been working on building a search bot. Currently I have it up and running in basic form in that it will go through all the links it can find on a website and read in all their code for parsing later by a index engine. There is a lot more I want to add and will be adding to the engines and components that will help any one out with using it.
If you would like to check it out and follow the development. You can visit the Google Code Project at http://code.google.com/p/web-ninja/
So we have launched the new Colorado Local Ubuntu Linux Team Website. So far everyone seems to be liking the new design and layout a lot. There are still some bugs that I need to work our with IE 6 support but hopefully those will be quick and easy.
Once all the bugs are worked out I will be bundling it up and putting it in the SVN of the google code project that I have started. This way if anyone else would like to use this team they can easily do so.
I look forward to hearing from everyone on what they think of the website and hope everyone enjoys it.
So after releasing my Virtual Earth Property Search on The Group Inc. I am now working on releasing it on several other real estate websites. Kentwood Homes Tour – WKRE – Reinhart Realtors.
I have to say this is just awesome to have created something so great that everyone of our clients checks it out and instantly wants it on there website. I kind of makes you feel good inside.
I am also working on the phase 2 of this great project. I am working on trying to move it to a central server to make updates ten time easier. I am also working on my own admin to help with plotting all the office on the map as well as tracking stats. This will hopefully make my life ten times more easier.
Well I finally had some time today along with my video game playing to finally revisit jsColorPallet with some design changes to the website. It keep the same very simple gray layout but gave it a more better div layout with some more areas to visit in regards to the project. So hopefully this will help out with people managing to use the software.
I also have plans at the next time I get some time to do a bit more code clean up and some creating some more color pallets for everyone to use. I have an idea to separate the color pallets from the main code base so that it becomes a lot easier for people to create custom color pallets for special purposes. I also want to achieve this so that I can allow options to change the color value returned(Hex, RGB, etc). I also have a plan to give you the option to in bed the color pallet on the page. So hopefully I can get some more time to get to making these changes. They will probable steam to creating v1.1.1 and then v2_rc0 with the separation into subclasses for each color pallet.
So go check out the current state of things as well as keep checking back for updates on the project.
Well I can finally say I have beat Gears of War. Yes!
I was finally able to sit down and find some time today to play some videos games. So as you know I decided to pick Gears of War sense its probable one of the newer games that I own. I picked up were I had left off with the infamous battle with Ramm (The End Boss). I had been trying to beat him on my own for a while but as we all know the AI in most games just sucks ass. This time though was diffrent I didn’t have AI to worry about because I had Taylor over to help me kick this guys ass.
Once we got back into the groove of playing Gears of War we managed to beat his ass with no problem at all. The ending was great to we managed to get one of us at one end of the train and the other at the other end of the train. We had Raam so confused at who to go after that for a while he just stood there. He finally went after Taylor which opened up a hole for me to just let loose on him with shotgun shells and grenades. It finally came down to him getting so close to Taylor that he had to jump out of his spot and start running back to me. As soon as he did that Raam turned around at started chasing after him. We almost thought he was done for then I managed to score some nice shots in as Taylor was running back that dropped Raam to the ground. It was one of the senses from a movie. You know the ones where the guy comes running out as the building blows but this time it was the guy running as bullets go flying over his head and a giant ugly mother falls to the ground dead.
It feels so great to finally have another game under the belt and to have had enough time to sit down a play a game. So now its time to sit and play another one. This time its the old classic Teenage Mutant Ninja Turtles 1989 Arcade game.
Well I have finally got to release one of the best projects I have worked on in a while. It is a Microsoft Virtual Earth Mass-Up.
The whole thing uses Virtual Earth to search for properties in your desired area of the US. Currently the site that I have deployed it on only displays Northern Colorado Properties. Even though this may be so I have built it so well that you can use it with an IDX provider’s data. So if you would like to go check it out. You will need the address. The Group Inc. Map Based Search. So go check it out tell me what you think and well keep reading for updates that I make to this new mass-up. I’m sure there will be more.
So I found a problem with Prototype in IE 7 with he Element.hasAttribute() method. It appears prototype doesn’t add the method very well in IE 7 to the element. Specifically the problem where I was having problems was when I would pass “this” on a anchor tag onClick event.
The solution I found that seems to work well is to take the element that is passed into the function and wrap $() around the element.
<a onClick=”myFunction(this); return false;”>Link</a>
element = $(element);
Hope this helps a lot of people out.
So I have started a new website that amazingly is up and complete. Go Check it out at TheRedCavern.com
You will love it. Oh ya by the way “NOT FOR WORK”.
Well I also have another project going on along with all my other lovely projects. This one happens to be a great fun project. Whos aim is to provide joy amongst you and your co-workers.
So whats the project, you ask. Well the current title is Ultimate Goatse. If the title doesn’t give it away as to what the project is all about then you need to go to the Goatse website.
Currently we are working on some great features of the project in our spear time. As it sites we have an interface that I am building that will allow you to connect to the other modules of the project. Currently the only server that we have is the wsServices module. We will soon have posted on the project site the source code that you can add onto as well as some binaries to download.
I must also tell you that not only will the project have Goatse but will contain all the favorites plus some new ones. Like LemonParty, The Will Power, and all the other greats.
Look forward to future posts on the project as well as my other projects.