Tag archives: databases

Tuesday 28th Febuary 2012

Python Logo

I have been working on this site on and off for a week now and having great fun hacking some python.

As a base for the blog I am using Django. Django is a framwork which is python based and tends to be very modular. The main modules are called applications or apps. There are millions of apps to do different jobs. As a starting point I used Zinnia. Zinnia looks after blogging and includes tagging and CRM type stuff. It was as simple matter of concocting some sqlfu and pulling the data out of mysql and sticking it in postgres. Blog entries are very simple.

Being a bit rusty on Django, I opted to start with stockphoto, a simple gallery app. The ultimate aim is to replicate all of the overall functionality that my current PHP based site has. The original gallery was gallery2 based with over 4000 images in it. There was no way that I was going to upload those again! I ended up doing a lot of hacking on the stockphoto model. They used a number of field names that match postgres keywords like "date" for the creation date field and "desc" for the description field.

The existing gallery2 instance has about 200 galleries with nesting up to 4 levels deep from the root. I was willing to cut this down to just 2 levels. To facilitate this I created the "group" model, which is really just another "gallery" model which lists galleries. That way there are groups in the root, then galleries, then photos. I also customised the admin areas a bit with extra list columns. I wrote two templatetags for stockphoto, first the index page, which shows the list of groups in the sidebar, the second is the random image block. Next on the agenda is to add in tagging.

On a roll now, I decided to tackle the wiki. The existing site had a mediawiki instance with lots of stuff on it which I didn't particulary want to rewrite. Once I worked out how to get the latest revisions of each pages out of the DB, I dumped them all. Next I replicated the schema in postgres and imported the wiki entries. I was then able to create wiki records from the mediawiki data. There was a lot of messing around required, because the wiki module is designed to be used with markdown. I modified the wiki app to incude the wikimarkup python library. I then wrote a new filter which used that instead of the markdown filter.

The mediawiki has a feature currently which allows me to include code and have it syntax hilighted. To replicate this feature I made another filter based on python-pygments. There was all sorts of messing around required because the two filters werent' playing nice together. I found in the end that I needed to run the field through the pygments filter first, then the wikimarkup filter. It's still not perfect. I'm also having trouble with something eating newlines on blog entries code tags.

I also wrote a template tag for the wiki which dumps out a link to the index, as well as a list of featured pages. This involved another model change to include the models.BooleanField() for featuring it.

All of this happend over a week with lots of back and forward and adjustments and tearout-and-reinstall of apps. It's been good fun!

 

Monday 2nd May 2011 - 22:54:43

Chip

Lots of work on my site today. Cleaned up a lot of old PHP crap, primarily deprecated functions.

I found earlier today that I could not log into my sites admin page. This is because it displays an event log when you log in - which should be fine right? The problem was, not having logged in for ages, that there was a substantial (15,880,000+, 3.8GB) of database table that the poor admin page had to join the user table against! Oops. All of these messages were about PHP deprecation. I must have been crawled by google or something, most of the problems were in my galley. There are over 2000 images in there, each image and gallery generating multiple warnings. So, after lots of careful ereg() and eregi() and split() replacements it's all good.

Friday 28th August 2009 - 07:08:16

Chip

Yesterday was good, I now have my sync program crawling the FIFO table and doing inserts and updates. Once the delete facility is wrapped in the ORM I can work on deletes as well. Then it's testing. Hopefully today is as productive!

I scored a lift home and got some of my crap from work home. Scored a PC and a monitor as well as some other miscellany like DL580 hotswap PSUs. I also scored a nice Gigabyte AM2 mainboard with 2 x pci-e 16s.

I need to do a serious cleanup and eBay session so I can buy the compound saw that I want!

Monday 24th August 2009 - 07:56:49

Chip

Off to work as usual. Hope I get a seat. I'm keen to do some more work on my invoice parser/query tool.

It's a tool used to parse ACCPAC for DOS invoices and stick their contents in a database in a sensible schema that I can report on. Once I can reproduce an invoice, the most basic function - I can move to phase 2, integrating parsing of the payments report and collating that with the invoices in several management reports. This involves porting one of my previous scripts from PHP/MySQL to Python/Postgres. Phase 3 is integration of internet orders data into the bargain. (Python, PHP, Javascript)

Once at work, I'm on a customer job. Writing a database synchronisation script thats designed to replicate a MySQL database into Postgres based around a FIFO table in the MySQL DB. FIFO Records are created by triggers in the MySQL database. The script needs some smarts because of the convoluted way that the developers of the software based around this database do updates. Apparently they didn't know about update - or weren't prepared to plumb in the necessary mechanics to allow the software to decided that it's updating. Their solution: DELETE the record and INSERT every time... Joy.

brewbox (fridge control server) seems to be working away happily - although I haven't connected the controller yet. I need to test the compressor lag routine in the control script. I want to make sure it works before I plug the fridge into it, in case I damage the fridges compressor by turning it on straight after it's been turned off.