Skip to content

Instantly share code, notes, and snippets.

@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
# 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
==================================================================================== test session starts ====================================================================================
platform linux2 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.3
rootdir: /home/piotr/projects/kotti_content_proxy, inifile: setup.cfg
plugins: Kotti, xdist, xdist, xdist, cache, pep8, cov, pycharm
collected 8 items
kotti_content_proxy/__init__.py s
kotti_content_proxy/resources.py s
kotti_content_proxy/views.py s
kotti_content_proxy/tests/conftest.py s
class Base(object):
pass
class C(Base):
an_attr = None
def __init__(self):
self.an_attr = 1