Skip to content

Commit

Permalink
Merge pull request #17 from uralbash/path-3
Browse files Browse the repository at this point in the history
clean and delete trailing space
  • Loading branch information
ergo committed Aug 28, 2015
2 parents 8f2a823 + d16941e commit c0276f6
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 119 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
^\.settings$
^alembic\.ini$
^test\.py$
^docs/_build$
^dist$
docs/_build
build/
dist/
ziggurat_foundations.egg-info
venv*
*.pyc
Expand Down
2 changes: 2 additions & 0 deletions .rstcheck.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[directives]
ignore=automodule,autoclass,autofunction
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ notifications:
on_failure: always

python:
- "2.7"
- "3.3"
- "3.4"
- "pypy"
- "pypy3"

matrix:
include:
- python: "2.7"
env: RSTCHECK=1

install:
- pip install flake8 rstcheck

script:
- python setup.py develop
- py.test ziggurat_foundations/tests.py

# flake8 and rstcheck
- if [ -n "$RSTCHECK" ]; then ./test.sh; fi

after_success:
- pip install coveralls
- coveralls
Binary file added docs/_static/flask_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/pyramid_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -25,7 +23,12 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig']
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.ifconfig'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -95,18 +98,23 @@


# -- Options for HTML output ---------------------------------------------------
import itcase_sphinx_theme

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'itcase'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
html_theme_options = {
'github_button': True,
'github_user': 'Ergo',
'github_repo': 'ziggurat_foundations',
}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
html_theme_path = [itcase_sphinx_theme.get_html_themes_path()]

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
Expand Down
55 changes: 30 additions & 25 deletions docs/extensions/pyramid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pyramid Extensions
==================

ziggurat_foundations can provide some shortcuts that help build pyramid
ziggurat_foundations can provide some shortcuts that help build pyramid
applications faster.

-------------------------------
Expand All @@ -11,15 +11,17 @@ Automatic user sign in/sign out

**ziggurat_foundations.ext.pyramid.sign_in**

This extension registers basic views for user authentication using
**AuthTktAuthenticationPolicy**, and can fetch user object and verify it
This extension registers basic views for user authentication using
**AuthTktAuthenticationPolicy**, and can fetch user object and verify it
against supplied password.

Extension setup
---------------

To enable this extension it needs to be included via pyramid include mechanism
for example::
To enable this extension it needs to be included via pyramid include mechanism
for example:

.. code-block:: ini
pyramid.includes = pyramid_tm
ziggurat_foundations.ext.pyramid.sign_in
Expand All @@ -30,52 +32,55 @@ or using configurator directives ::

this will register 2 routes:

* ziggurat.routes.sign_in with pattern */sign_in*
* ziggurat.routes.sign_in with pattern */sign_in*
* ziggurat.routes.sign_out with pattern */sign_out*

.. tip ::
those patterns can be configured to match your app route patterns via
.. tip::

those patterns can be configured to match your app route patterns via
following config keys:

* ziggurat_foundations.sign_in.sign_in_pattern = /custom_pattern
* ziggurat_foundations.sign_in.sign_out_pattern = /custom_pattern
* ziggurat_foundations.sign_in.sign_out_pattern = /custom_pattern

It is also required to tell the extension where User model is located in your
It is also required to tell the extension where User model is located in your
application for example::

ziggurat_foundations.model_locations.User = yourapp.models:User

Additional config options for extensions include:

* ziggurat_foundations.sign_in.username_key = login *(name of POST key that will
* ziggurat_foundations.sign_in.username_key = login *(name of POST key that will
be used to supply user name )*
* ziggurat_foundations.sign_in.password_key = password *(name of POST key that
* ziggurat_foundations.sign_in.password_key = password *(name of POST key that
will be used to supply user password)*
* ziggurat_foundations.sign_in.came_from_key = came_from *(name of POST key that
will be used to provide additional value that can be used to redirect user back
will be used to provide additional value that can be used to redirect user back
to area that required authentication/authorization)*

Configuring your application views
-----------------------------------

First you need to make a form used for user authentication and send info to one
of views registered by extension ::
First you need to make a form used for user authentication and send info to one
of views registered by extension:

.. code-block:: html+jinja

<form action="{{request.route_url('ziggurat.routes.sign_in')}}" method="post">
<input type="hidden" value="OPTIONAL" name="came_from" id="came_from">
<input type="text" value="" name="login">
<input type="password" value="" name="password">
<input type="submit" value="Sign In" name="submit" id="submit">
</form>
In next step it is required to register 3 views that will listen for specific

In next step it is required to register 3 views that will listen for specific
context objects that extension can return upon form submission/ logout request:

* **ZigguratSignInSuccess** - user and password were matched
* contains headers that set cookie to persist user identity,
fetched user object, "came from" value
* **ZigguratSignInBadAuth** - there were no positive matches for user and password
* contains headers used to unauthenticate any current user identity
* contains headers used to unauthenticate any current user identity
* **ZigguratSignOut** - user signed out of application
* contains headers used to unauthenticate any current user identity

Expand All @@ -90,7 +95,7 @@ Required imports for all 3 views
from ziggurat_foundations.ext.pyramid.sign_in import ZigguratSignInBadAuth
from ziggurat_foundations.ext.pyramid.sign_in import ZigguratSignOut


ZigguratSignInSuccess context view example
..........................................

Expand Down Expand Up @@ -118,8 +123,8 @@ ZigguratSignInBadAuth context view example
# action like a warning flash message on bad logon
return HTTPFound(location=request.route_url('/'),
headers=request.context.headers)


ZigguratSignOut context view example
..........................................

Expand All @@ -128,4 +133,4 @@ ZigguratSignOut context view example
@view_config(context=ZigguratSignOut, permission=NO_PERMISSION_REQUIRED)
def sign_out(request):
return HTTPFound(location=request.route_url('/'),
headers=request.context.headers)
headers=request.context.headers)
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ziggurat_foundations's documentation!
================================================
ziggurat_foundations
====================

.. image:: https://errormator.com/static/images/logos/pyramid_small.png
.. image:: /_static/pyramid_small.png
:alt: Pyramid Logo

.. image:: https://errormator.com/static/images/logos/flask_small.png
.. image:: /_static/flask_small.png
:alt: Flask Logo

Framework agnostic set of sqlalchemy classes that make building applications
Expand Down
27 changes: 14 additions & 13 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@ Overview
========

ziggurat_foundations supplies a set of *sqlalchemy mixins* that can be used to extend
models in your application. The aim of this project is to supply set of generic
models that cover the most common needs in application development when it comes
models in your application. The aim of this project is to supply set of generic
models that cover the most common needs in application development when it comes
to authorization - using flat and tree like data structures.

So far following basics are supplied:

- User - base for user accounts
- Group - container for many users
- Resource - Arbitrary database entity that can represent various object hierarchies - blogs, forums, cms documents, pages etc.
- Group - container for many users
- Resource - Arbitrary database entity that can represent various object
hierarchies - blogs, forums, cms documents, pages etc.

Currently following information and data manipulation is supported:

- assigning arbitrary permissions directly to users (ie. access admin panel)
- assigning arbitrary permissions directly to users (ie. access admin panel)
- assigning users to groups
- assigning arbitrary permissions to groups
- assigning arbitrary permissions to groups
- assigning arbitrary resource permissions to users (ie. only user X can access private forum)
- assigning arbitrary resource permissions to groups
- assigning arbitrary resource permissions to groups


All permutations between those patterns allow for complex and flexible permission
All permutations between those patterns allow for complex and flexible permission
systems that are easly understandable for non-technical users.
The sqlalchemy mixins make all the interactions easy to use in your application

The sqlalchemy mixins make all the interactions easy to use in your application
and save development time.

.. warning::
Be cautious about creating your database models directly with sqlalchemy - **be sure
to at least stamp the database with latest alembic timestamp. It is recommended
to at least stamp the database with latest alembic timestamp. It is recommended
to use alembic for table creation**.

Quick usage examples
Expand All @@ -40,7 +41,7 @@ assigning custom "read" permission for user "foo" for a given resource::
permission = UserResourcePermission()
permission.perm_name = "read"
permission.user_name = "foo"
resource.user_permissions.append(permission)
resource.user_permissions.append(permission)

fetching all resources with permissions "edit", "vote"::

Expand All @@ -50,7 +51,7 @@ fetching all non-resource based permissions for user::

user.permissions

given a resource fetching all permissions for user, both direct and
given a resource fetching all permissions for user, both direct and
inherited from groups user belongs to::

resource.perms_for_user(user_instance)
Expand Down

0 comments on commit c0276f6

Please sign in to comment.