Skip to content

Commit

Permalink
demo update
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSaelen committed Apr 11, 2014
1 parent 05e7550 commit cc08f5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
3 changes: 2 additions & 1 deletion atramhasis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def includeme(config):
config.include('pyramid_jinja2')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()


def main(global_config, **settings):
Expand All @@ -22,5 +23,5 @@ def main(global_config, **settings):
Base.metadata.bind = engine
config = Configurator(settings=settings)
includeme(config)
config.scan()

return config.make_wsgi_app()
13 changes: 12 additions & 1 deletion atramhasis/scaffolds/atramhasis_demo/+package+/__init__.py_tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config

from atramhasis.models import (
DBSession,
Base,
)

def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""

print("--{{project}}--MAIN--")
# Set up sqlalchemy
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine

# Set up pyramid
config = Configurator(settings=settings)

# Set up atramhasis
config.include('atramhasis')

#Add skos support
config.include('{{package}}.skos')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,9 @@ TREES = DictionaryProvider(
[larch, chestnut, species]
)


def unicode_csv_reader(utf8_data, dialect=csv.excel, **kwargs):
csv_reader = csv.reader(utf8_data, dialect=dialect, **kwargs)
for row in csv_reader:
yield [unicode(cell, 'utf-8') for cell in row]

reader = unicode_csv_reader(
open(os.path.join(os.path.dirname(__file__), 'menu.csv'), 'r'),
delimiter=',',
quotechar='"'
)

MENU = SimpleCsvProvider(
{'id': 'MENU'},
reader
)


def includeme(config):
config.include('pyramid_skosprovider')
config.scan('pyramid_skosprovider')
skosregis = config.get_skos_registry()
skosregis.register_provider(TREES)
skosregis.register_provider(MENU)

2 changes: 1 addition & 1 deletion atramhasis/scaffolds/atramhasis_demo/development.ini_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
###

[app:main]
use = egg:atramhasis
use = egg:{{project}}

pyramid.reload_templates = true
pyramid.debug_authorization = false
Expand Down

0 comments on commit cc08f5c

Please sign in to comment.