Slides 19-69 of Markus Winand's "Modern SQL":
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
from dataclasses import dataclass | |
import importlib | |
import re | |
from django.conf import settings | |
from django.core.management.base import BaseCommand | |
from django.urls.base import resolve | |
from django.urls.base import reverse | |
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
[tool.poetry] | |
name = "poetry-test" | |
version = "0.1.0" | |
description = "" | |
authors = ["Some User <[email protected]>"] | |
[tool.poetry.dependencies] | |
python = "^3.6" | |
[tool.poetry.dev-dependencies] |
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
shangxiao ~/projects/test-pytest $ pytest | |
========================================================= test session starts ========================================================= | |
platform darwin -- Python 3.6.2, pytest-5.0.0, py-1.8.0, pluggy-0.12.0 | |
rootdir: /Users/shangxiao/projects/test-pytest | |
collected 1 item | |
test_foo.py F [100%] | |
============================================================== FAILURES =============================================================== | |
________________________________________________________ FooTestCase.test_foo _________________________________________________________ |
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
import time | |
from django.conf import settings | |
from django.db import connection | |
class DebugMiddleware: | |
def __init__(self): | |
import logging | |
self.log = logging.getLogger(__name__) |
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
Relay Notes | |
=========== | |
- Define a schema, that is used for _both_ server side endpoint setup & frontend graphql compilation | |
- node only for now, some graphql ports | |
- Relay has a strict specification of how a graphql schema is set up: https://facebook.github.io/relay/docs/graphql-relay-specification.html | |
- tree children are called "plural links" (see _writePluralLink()) | |
- Why shouldn't i use mysql? / mongo?
- Should I use jinja, I read it's faster?
- Should I use sqlalchemy, I read it's superior?
- How do i make this thing happen in parallel/not wait for xxx to finish?
- Why does django ask for a default? (But my table has no data in it wtf django!?!)
- FunkyBob | I think, perhaps, it's time I wrote a blog post on "why does a migration adding a field need a default?"
- Why do I need to commit my migrations? Why can't I just run makemigrations on the server?
- migrations are source, makemigrations is a helper which takes you part way
- i've seen people accidentally lose their migrations on production… oops now what?
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
from functools import update_wrapper | |
from django.http import Http404 | |
class authenticated_or_404(object): | |
def __init__(self, func): | |
self.func = func | |
update_wrapper(self, func) |
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 some_view(request): | |
if request.user.is_authenticated: | |
do_something_private() |
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 ChoiceField(Field): | |
... | |
def to_representation(self, value): | |
if data == '' and self.allow_blank: | |
return '' | |
try: | |
return self.choice_strings_to_values[six.text_type(value)] | |
except KeyError: | |
return value |