Weblog | 2010
All articles published during 2010.
Backup files safely on Ubuntu linux
Using cron and rsync to easily backup your home directory without having to think about it.
Scale a hex color in Python
A quick little snippet on scaling HTML hex colors.
Getting fresh with SQLAlchemy
Accessing an attribute of a record instance using the __dict__
The UTF-8 BOM-B
UTF-8 just bombed my website! Remove UTF-8 BOM (byte-order-mark) with python.
The quest to fix the dead clicking hard drive with FREEZE
How I was able to fix my clicking hard drive by freezing it!
Multiple Decorators for python functions
A little trick to effectively stacking multiple decorators with python functions.
Canoeing down the brazos in Texas
Information on my trip down the brazos, and the things I learned for the next time!
Web2py Utilities
I have decided to share some of the libraries that I have found useful when creating web2py apps.
Using fixtures in web2py
So you are ready to deploy your newly finished web2py app, but you don't like the idea of having to manually insert all of this fixture data again! Create a new model, and name it ``x_fixtures.py``. This way it will execute after all of your models.
Compile web2py apps externally
Web2py has a nice built-in feature supported execution of byte-code compiled applications. When you compile your application, web2py actually will byte-code compile all models, controllers and views. Web2py is the only framework to date that will compile
Let the web server stream your files, not response.download!
If your web server supports the X-Sendfile header, you are able to stream your uploaded files from the web server, instead of through web2py. Here is a snippet from [Cherokee Website][1] explaining the X-Sendfile header. > X-Sendfile is a special, non
Increase Productivity By Using Parameterized Queries with web2py
One of the nice things about MS Access is that you can define a query, and it will be accessible to your code anywhere else in the database. You can even base another query off of a query. Making queries inheritable properties. Another nice feature avail
Check reserved SQL Keywords on web2py DAL
As of web2py version 1.75.1 there is also another argument that can be passed to the DAL constructor to check table names and column names against reserved SQL keywords in target back-end databases. This argument is check_reserved; it defaults to None
Download of a file-like python object in web2py
Here are a couple of ways to expose any python file-like object as download-able in a web2py controller. You might want to do this if you have a generated pdf report, or allowing an export of the sites content. From your controller, you can stream
Query between dates
So you need to write a query to get rows that exist between dates. This is a situation where the simplicity of the web2py DAL really shows, and how close it is to SQL really shines.
Table Inheritance with web2py DAL
It is possible to define common db columns, e.g. posted_by, posted_on, etc... once and define on theappropriate table to inherit these common columns. The DAL makes this quite easy. You define a Table with the common fields that you would like to i
web2py dynamic queries
In many cases you might need a query based on multiple sets of information. Think of a search box, where you would like to provide the option to search in multiple areas (title, content, authors) or exclude these areas. Or a customer management system, i