`if not apps.has_key(app_id):` will be better.