A workflow for docker that separates build-time dependencies from run-time dependencies.
Create the image used for building apps.
docker build -t pybuilder pybuilder
Create the image used for running apps.
| def commit_veto(environ, status, headers): | |
| for good in ('1', '2', '3'): | |
| if status.startswith(good): | |
| break | |
| else: | |
| return True | |
| for header_name, header_value in headers: | |
| if header_name.lower() == 'x-tm-abort': | |
| return True |
| class DayZeroContainer(ModelContainer): | |
| def __init__(self, request, cls): | |
| self.cls = cls | |
| self.request = request | |
| @property | |
| def __acl__(self): | |
| return [ | |
| (Allow, 'owner:{0}'.format(cls.ownerid), ('add', 'edit)), | |
| # ... some other acls for this particular resource? |
| # tutorial/__init__.py | |
| from pyramid.config import Configurator | |
| from tutorial.model.meta import init_model | |
| from tutorial.request import TutorialRequest | |
| def main(global_config, **settings): | |
| init_model(settings) |
| from pyramid.decorator import reify | |
| from pyramid_traversalwrapper import LocationProxy | |
| class traversable_attrs(object): | |
| """ A decorator that adds a "wrap" attribute to the given class | |
| in the form of a dict-like class that does item lookup based on | |
| the attrs given. | |
| """ |
| from pyramid.response import Response | |
| from pyramid.view import view_config | |
| class Test12: | |
| def __init__(self, request): | |
| self.request = request | |
| @view_config(route_name='test1') | |
| def test1(self): | |
| return Response('I am from test 1') |
| class rest_resource(object): | |
| all_methods = frozenset([ | |
| 'head', 'get', 'post', 'put', 'patch', 'delete']) | |
| def __init__(self, **kw): | |
| self.kw = kw # view defaults | |
| def __call__(self, wrapped): | |
| # grab the supported methods from the class | |
| methods = self.all_methods.intersection(set(vars(wrapped).keys())) |
| from sqlalchemy import ( | |
| create_engine, | |
| Column, | |
| ForeignKey, | |
| ) | |
| from sqlalchemy import ( | |
| Integer, | |
| String, | |
| ) | |
| from sqlalchemy.ext.declarative import declarative_base |
A workflow for docker that separates build-time dependencies from run-time dependencies.
Create the image used for building apps.
docker build -t pybuilder pybuilder
Create the image used for running apps.
| from ConfigParser import RawConfigParser | |
| def load_settings(global_config, app_settings): | |
| """ | |
| Load an INI file with multiple sections into a single dictionary. | |
| .. code-block:: ini | |
| [sqlalchemy] | |
| url = sqlite://%(here)s |
| from hashlib import sha256 | |
| import os | |
| from pyramid.session import SignedCookieSessionFactory | |
| def make_session_id(): | |
| rand = os.urandom() | |
| return sha256(sha256(rand).digest()).hexdigest() | |
| class MemorySessionSerializer(object): |