This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(db.Model): | |
__tablename__ = 'foo' | |
id = db.Column(db.Integer, primary_key=True) | |
bars = db.relationship('Bar', backref='foo') | |
name = db.Column(db.String(256)) | |
class Bar(db.Model): | |
__tablename__ = 'bar' | |
id = db.Column(db.Integer, primary_key=True) | |
bazs = db.relationship('Baz', backref='bar') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_access_token(self, code): | |
app.logger.debug("get_access_token") | |
payload = {'client_id': self.GITHUB_CLIENT_ID, | |
'client_secret': self.GITHUB_CLIENT_SECRET, | |
'code': code} | |
response = requests.post('https://github.com/login/oauth/access_token', | |
data=json.dumps(payload), | |
headers=self.headers()) | |
if 'access_token' not in response.json(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCrazyModel(models.Model): | |
def some_stupid_function(self): | |
new_model = MyModel() | |
new_model.my_crazy_model = self | |
new_model.save() | |
def this_fails(self): | |
find_model = MyModel.objects.filter(my_crazy_model_id=self.id)[0] | |
# prints the ID | |
print find_model.my_crazy_model_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(env)vagrant@precise64:/vagrant$ ll | |
total 70 | |
drwxrwxrwx 1 vagrant vagrant 4096 May 15 18:50 ./ | |
drwxr-xr-x 24 root root 4096 May 14 21:08 ../ | |
-rwxrwxrwx 1 vagrant vagrant 31744 Apr 29 16:52 blank.db* | |
drwxrwxrwx 1 vagrant vagrant 4096 Apr 29 17:00 bootstrap/ | |
drwxrwxrwx 1 vagrant vagrant 4096 May 14 16:44 .git/ | |
-rwxrwxrwx 1 vagrant vagrant 31 Apr 29 16:52 .gitignore* | |
-rwxrwxrwx 1 vagrant vagrant 259 Apr 29 16:52 manage.py* | |
drwxrwxrwx 1 vagrant vagrant 4096 May 15 19:18 mensch/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(env)vagrant@precise64:/vagrant$ python manage.py shell | |
Python 2.7.3 (default, Aug 1 2012, 05:14:39) | |
[GCC 4.6.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
(InteractiveConsole) | |
>>> from django.conf import settings | |
>>> settings.CURRENT_DIR | |
'/vagrant/mensch' | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = ( | |
'django.contrib.auth', | |
'django.contrib.admin', | |
'django.contrib.sites', | |
'django.contrib.comments', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.contenttypes', | |
'django.contrib.staticfiles', | |
'south', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MEDIA_ROOT = os.path.join(CURRENT_DIR, 'media_root') | |
MEDIA_URL = '/media/' | |
STATIC_ROOT = os.path.join(CURRENT_DIR, 'static_root') | |
STATIC_URL = '/static/' | |
STATICFILES_DIRS = ( | |
os.path.join(CURRENT_DIR, 'static'), | |
) | |
STATICFILES_FINDERS = ( | |
'django.contrib.staticfiles.finders.FileSystemFinder', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(env)vagrant@precise64:/vagrant$ python manage.py collectstatic -c | |
You have requested to collect static files at the destination | |
location as specified in your settings. | |
This will DELETE EXISTING FILES! | |
Are you sure you want to do this? | |
Type 'yes' to continue, or 'no' to cancel: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2013-04-24T14:30:13+00:00] INFO: *** Chef 11.4.0 *** | |
[2013-04-24T14:30:14+00:00] WARN: unable to detect ipaddress | |
[2013-04-24T14:30:14+00:00] WARN: unable to detect macaddress | |
[2013-04-24T14:30:14+00:00] WARN: unable to detect ip6address | |
[2013-04-24T14:30:15+00:00] INFO: Run List is [role[babl_application_server]] | |
[2013-04-24T14:30:15+00:00] INFO: Run List expands to [users::sysadmins, sudo, apt, build-essential, chef-client, database::postgresql, postgresql::server, postgresql::client, openssl, application, git, python, runit, gunicorn, tmux, vim, zsh, nginx, postgresql, postgresql::ruby, babl::babl] | |
[2013-04-24T14:30:15+00:00] INFO: HTTP Request Returned 404 Not Found: No routes match the request: /reports/nodes/babl-www/runs | |
[2013-04-24T14:30:15+00:00] INFO: Starting Chef Run for babl-www | |
[2013-04-24T14:30:15+00:00] INFO: Running start handlers | |
[2013-04-24T14:30:15+00:00] INFO: Start handlers complete. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authorization_header = request.META['HTTP_AUTHORIZATION'] | |
app_id_header = request.META['HTTP_X_ZIPMARK_APPLICATION_IDENTIFIER'] | |
date_header = request.META['HTTP_DATE'] | |
callback_path = reverse('zipmark_callback') | |
body_md5_hex = md5.new(request.raw_post_data).hexdigest() | |
string_to_sign = "POST\n%s\napplication/json\n%s\n%s\n%s" % (body_md5_hex, date_header, callback_path, app_id_header) | |
hmac_digest = hmac.new(settings.ZIPMARK_APPLICATION_SECRET, string_to_sign).digest() | |
sha_digest = sha.new(hmac_digest).digest() | |
signed_string = "ZM %s:%s" % (base64.b64encode(vendor_identifier), base64.b64encode(sha_digest)) |