Skip to content

Commit

Permalink
Upgrading to Cookiecutter template and Morepath0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
henri-hulski committed May 4, 2016
1 parent e9b5e8e commit 59066ca
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 233 deletions.
27 changes: 20 additions & 7 deletions .gitignore
@@ -1,7 +1,20 @@
.installed.cfg
.mr.developer.cfg
parts
src
bin
develop-eggs
contents/*
# Byte-compiled / optimized
__pycache__/
*.py[co]

# Distribution / packaging
env/
build/
dist/
*.egg-info/

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Sphinx documentation
docs/_build/
11 changes: 11 additions & 0 deletions .travis.yml
@@ -0,0 +1,11 @@
language: python

cache: pip
env:
- TOXENV=pep8
before_install:
- pip install --upgrade pip setuptools
install:
- pip install tox
script:
- tox -e $TOXENV
7 changes: 7 additions & 0 deletions CHANGES.rst
@@ -0,0 +1,7 @@
CHANGES
*******

0.1 (unreleased)
================

- Initial public release.
24 changes: 24 additions & 0 deletions LICENSE
@@ -0,0 +1,24 @@
Copyright (c) 2014-2016, Morepath Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL FANSTATIC DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 8 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,8 @@
recursive-include morepath_batching *
include *.txt
include *.rst
include *.ini
include LICENSE
global-exclude *.pyc
global-exclude *.pyo
global-exclude __pycache__/*
25 changes: 25 additions & 0 deletions README.rst
@@ -0,0 +1,25 @@
Morepath SQLAlchemy Demo
========================

Show how to create a server web application with Morepath that integrates
a database based on SQLAlchemy.
It uses the more.transaction plugin.

See also more.transaction on Github:

https://github.com/morepath/more.transaction

Installation
------------

You can use pip in a virtual env::

$ virtualenv env
$ source env/bin/activate
$ env/bin/pip install -e .

Then to run the web server::

$ env/bin/morepath_sqlalchemy

You can now access the application through http://localhost:5000
170 changes: 0 additions & 170 deletions bootstrap.py

This file was deleted.

25 changes: 0 additions & 25 deletions buildout.cfg

This file was deleted.

Binary file modified morepath_sqlalchemy.db
Binary file not shown.
3 changes: 3 additions & 0 deletions morepath_sqlalchemy/__init__.py
@@ -0,0 +1,3 @@
# flake8: noqa

from morepath_sqlalchemy.app import App
5 changes: 5 additions & 0 deletions morepath_sqlalchemy/app.py
@@ -0,0 +1,5 @@
from more.transaction import TransactionApp


class App(TransactionApp):
pass
2 changes: 1 addition & 1 deletion morepath_sqlalchemy/collection.py
@@ -1,5 +1,5 @@
from .model import Document
from .main import Session
from .run import Session


MAX_LIMIT = 20
Expand Down
2 changes: 1 addition & 1 deletion morepath_sqlalchemy/model.py
Expand Up @@ -2,7 +2,7 @@
Column,
Integer,
Text,
)
)
from sqlalchemy.ext.declarative import declarative_base


Expand Down
3 changes: 2 additions & 1 deletion morepath_sqlalchemy/path.py
@@ -1,4 +1,5 @@
from .main import App, Session
from .app import App
from .run import Session
from .model import Document, Root
from .collection import DocumentCollection

Expand Down
10 changes: 3 additions & 7 deletions morepath_sqlalchemy/main.py → morepath_sqlalchemy/run.py
@@ -1,24 +1,20 @@
import morepath
import sqlalchemy
from more.transaction import TransactionApp
from sqlalchemy.orm import scoped_session, sessionmaker
from zope.sqlalchemy import register
from .model import Base
from .app import App


Session = scoped_session(sessionmaker())
register(Session)


class App(TransactionApp):
pass


def main():
def run(): # pragma: no cover
engine = sqlalchemy.create_engine('sqlite:///morepath_sqlalchemy.db')
Session.configure(bind=engine)
Base.metadata.create_all(engine)
Base.metadata.bind = engine

morepath.autosetup()
morepath.autoscan()
morepath.run(App())
4 changes: 2 additions & 2 deletions morepath_sqlalchemy/view.py
@@ -1,5 +1,5 @@
from .model import Document, Root
from .main import App
from .app import App
from .collection import DocumentCollection
from morepath import redirect

Expand All @@ -26,7 +26,7 @@ def document_collection_default(self, request):
'previous': request.link(self.previous(), default=None),
'next': request.link(self.next(), default=None),
'add': request.link(self, 'add'),
}
}


@App.html(model=DocumentCollection, name='add')
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[pytest]
testpaths = morepath_sqlalchemy

0 comments on commit 59066ca

Please sign in to comment.