czerwiec 1st, 2009 — Apache
If mod rewrite is not working in your apache server under Ubuntu:
Invalid command 'RewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration
You have to run the following command in a terminal:
sudo a2enmod rewrite
maj 21st, 2009 — Python
Python has jumped from 6th to 5th place in TIOBE Programming Community Index (May 2009). Congratulations!
maj 20th, 2009 — Python
Little experiment:
python -m timeit -r 100 -s "d={'a':'1', 'b':'2', 'c':'3'}" "d.has_key('a')"
1000000 loops, best of 100: 0.361 usec per loop
python -m timeit -r 100 -s "d={'a':'1', 'b':'2', 'c':'3'}" "'a' in d"
10000000 loops, best of 100: 0.159 usec per loop
Checking if dictionary has key using “in” is faster than using has_key() method.
Tested in Python 2.6
maj 5th, 2009 — Pylons, Python
How to write and read array from cookies ?
The easiest way to write an array in cookie is serialize it using pickle module and quote returned string with urllib module. For example:
import pickle, urllib
cookie = []
response.set_cookie('some_cookie', urllib.quote(pickle.dumps(cookie)))
And getting an array from cookie:
cookie = pickle.loads(str(urllib.unquote(request.cookies['some_cookie'])))

kwiecień 24th, 2009 — Pylons, Python
Remember the trick!
The easiest way to modify response headers in Pylons is add:
response.headerlist = [('Content-type', 'image/png')]
just before render() function.
kwiecień 9th, 2009 — Pylons, Python
This is a simple solution to create own decorator function for any action in Pylons.
First, you have to import some functions:
from decorator import decorator
from pylons.decorator.util import get_pylons // to get request environment
Now create decorator function, for example myowndecorator:
def myowndecorator():
def wrapper(func, *args, **kwargs):
request = get_pylons(args).request # use it for any operation with request
# do something
return func(*args, **kwargs)
return decorator(wrapper)
Save it in your project lib directory as mylib.py.
In last step you have to import function from you library, and use decorator in your controller:
from myproject.lib.mylib import myowndecorator
class PanelController(BaseController):
@myowndecorator()
def index(self):
return render('/panel/index.mako')
luty 27th, 2009 — All & nothing
I had to create basic authentication in my project(based on Pylons), and this is simple solution to do it.
First, you have to open your config/middleware.py. It’s necessary to import AuthBasicHandler: from paste.auth.basic import AuthBasicHandler.
Next step is find ‘app = PylonsApp()‘. Change this line to: ap = PylonsApp() and add after: app = AuthBasicHandler(ap, “My realm”, authfunc). Of course you need to create auth function, for example:
def authfunc(environ, username, password):
if username == 'myusername' and password == 'mypassword':
return True
else:
return False
Restart your application environment.
That’s it
luty 24th, 2009 — Python
New version(0.9.7) of Pylons framework has been released. It’s a big step to standardize code and documentation
Major changes:
- Switched to using WebOb for the request/response object
- Various performance improvements to object initialization
- Beaker and Routes updates
- Middleware improvements, and optimizations
styczeń 22nd, 2009 — Conferences, sql

On the 19 of February this year my University is going to organise conference about SQL Server 2008.
The topics:
- T-SQL Tips&Tricks
- SQL Server 2008 - what will give to developers and administrators
- Integration Services - something else aside than sending data
Conference’s place:
Wy ższa Szkoła Bankowa w Poznaniu Wydział Zamiejscowy w Chorzowie
Street: Sportowa 29
City: Chorzów
Start: 8:00
More information on the conference website: http://ms-groups.pl/plssug/Strony/SeminariumSQLServer2008.aspx
styczeń 22nd, 2009 — Python
I have noticed today pylonshq.com has new website
It’s prettier than last one. and I hope it’s announce, that new stable version(0.9.7) of Pylons is comming soon