Skip to content

Instantly share code, notes, and snippets.

@piotr-dobrogost
piotr-dobrogost / app:__init__.py
Created November 6, 2015 14:42
Interaction between overrides and translations in Pyramid – difference with and without config.begin()
from pyramid.config import Configurator
config = Configurator()
config.begin()
config.override_asset('framework', 'app:framework-overrides/')
config.commit()
config.add_translation_dirs('framework:locale')
@piotr-dobrogost
piotr-dobrogost / app:__init__.py
Created November 5, 2015 12:13
Interaction between overrides and translations in Pyramid – trying to reproduce behavior (error) seen in project based on Kotti
def includeme(config):
config.add_translation_dirs('app:locale')
config.add_translation_dirs('app:framework-locale')
config.commit()
config.scan(__name__)
@piotr-dobrogost
piotr-dobrogost / main.py
Last active November 4, 2015 11:25
Interaction between overrides and translations in Pyramid
from pyramid.config import Configurator
if __name__ == '__main__':
config = Configurator()
config.override_asset('app', 'app.subapp:app-overrides/')
config.commit()
config.add_translation_dirs('app:locale')
@piotr-dobrogost
piotr-dobrogost / output
Created October 29, 2015 13:53
Test for difference in .add_translation_dirs() with and without .commit()
(pyramid)[piotr@demon pyramid]$ nosetests -t test_xxx
E
======================================================================
ERROR: test_xxx (pyramid.tests.test_config.test_i18n.TestI18NConfiguratorMixin)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/piotr/projects/pyramid/pyramid/tests/test_config/test_i18n.py", line 95, in test_xxx
dirs = config.registry.getUtility(ITranslationDirectories)
File "/home/piotr/.virtualenvs/pyramid/lib/python2.7/site-packages/zope/interface/registry.py", line 172, in getUtility
raise ComponentLookupError(provided, name)
@fixture(scope='session')
def custom_settings():
return {}
def create_proxy(node, context):
name = title_to_name(node.name, blacklist=context.keys())
if node.id is None:
DBSession.flush(objects=(node,))
proxy = context[name] = ContentProxy(proxied_id=node.id)
return proxy
import sys
from requests import request
from requests import async
URL = 'http://httpbin.org/get'
def get():
return request('get', URL)
def async_get():
# User specific aliases and functions (.bashrc)
# Source global definitions
if [ -f /etc/bashrc ]; then
source /etc/bashrc
fi
# Source common definitions
if [ -f ~/.bashrc_common ]; then
Traceback (most recent call last):
File "/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/tests/conftest.py", line 12, in foo_proxy
from kotti_content_proxy.resources import ContentProxy
File "/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/__init__.py", line 10, in <module>
from .resources import ContentProxy
File "/home/piotr/projects/kotti_content_proxy/kotti_content_proxy/resources.py", line 14, in <module>
from kotti_content_proxy import _
ImportError: cannot import name _
# -*- coding: utf-8 -*-
"""
Created on 2015-09-16
:author: Piotr Dobrogost (email)
"""
from kotti.resources import File
from pyramid.i18n import TranslationStringFactory
from pyramid.view import view_config