After two price increases, and a horrendous, unexpected bill, and two weeks of hard work to escape from the walled gardens of App Engine, the Adventures are ended in the Cloud.
Monday, July 23, 2012
Tuesday, June 2, 2009
Installing PIL
Sooner or later you may need the PIL library for image manipulation. If you're using OS X, you will see it's not 100% obvious how to install - here is the solution.
For me, PYTHONPATH haven't worked, but this comment helped me out.
Also don't forget to restart AppEngine Launcher after PIL installed.
Monday, June 1, 2009
How to make a simple 404 page in App Engine
In app.yaml you have to define a 'catch all' mask at the very end of the file:
# --- 404 page ---- url: /.*script: 404.py
Of course you can use a static file as well.
Thursday, May 28, 2009
Back-references are your friends
A very handy feature of database references is their automatic back-references pairs.
The name of the back-reference property defaults to {model name}+'_set' in lower case, that's how 'phone_set' was made in the example. More about back-references can be read here.
class User(db.Model):
name = db.StringProperty()
class Phone(db.Model):
number = db.PhoneNumberProperty()
user = db.ReferenceProperty(User)
# fetch one user
username = 'John'
user = User().all().filter('name = ', username).get()
# get the first associated phone number for a user
phonenum = user.phone_set[0].number
# list all phone numbers of the user
for phonenum in user.phone_set:
# phonenum here contains the user's actual phonenum in the list
The name of the back-reference property defaults to {model name}
Sunday, May 3, 2009
Interactive Shell - a must have
Do you want to debug and see a memcache value on the live server? Or any other property? Deploy this interactive shell into your application's directory. Don't forget to set the rights to admin only in app.yaml.
Saturday, May 2, 2009
Full Text Search
I thought it's impossible but then I've found an article about Full Text Searching in GAE - the nasty thing is, it's entirely undocumented. I'll give it a try soon. How-to can be found here.
Custom Django Filters in Google Application Engine
Here is a very good description how can you use custom Django filters in Google Application Engine.
I've modified a filter found on Django Snippets to convert ISO8859-2 / ISO8859-1 strings into URL friendly strings:
match_non_alnum = re.compile("[^a-zA-Z0-9]+")def dig_url_encode(string):"""Converts common ISO88592/1 chars to ASCII and removes any special chars"""r = {u'á': u'a',u'é': u'e',u'í': u'i',u'ó': u'o',u'ö': u'o',u'õ': u'o',u'ő': u'o',u'ú': u'u',u'ü': u'u',u'ű': u'u',u'û': u'u',u'Á': u'A',u'É': u'E',u'Í': u'I',u'Ó': u'O',u'Ö': u'O',u'Ő': u'O',u'Ú': u'U',u'Ü': u'U',u'Ű': u'U'}for key, value in r.items():string = string.replace(key, value)return match_non_alnum.sub(' ', string).strip().replace(' ', '_')
Subscribe to:
Posts (Atom)