Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 16 commits
  • 12 files changed
  • 0 commit comments
  • 3 contributors
Commits on May 02, 2012
@llacroix llacroix Merge pull request #1 from mcdonc/fix.coverage
add coverage, add dev and docs aliases, add a tox configuration, make te...
8cb653a
@llacroix llacroix Added documentation for addons,
I took it from zodbconn so there might be some things I forgot to remove
fb08ae3
@llacroix llacroix Modification to the doc
removed PersistentMapping
removed docs/_themes in gitignore
c3b24fe
@llacroix llacroix Renamed for github 9f8a5e9
Commits on May 06, 2012
@llacroix llacroix Added some documentation and tutorial 754d06e
@llacroix llacroix Added some docs and extended mongo config 1f7ceb5
@llacroix llacroix Change tests and some fixes 4073d34
@llacroix llacroix updated doc b96b360
@llacroix llacroix Change to README 682f537
Commits on Aug 18, 2012
Loïc Faure-Lacroix Added support for mongonengine 3fb6df5
Commits on Aug 20, 2012
Loïc Faure-Lacroix Fixed some bug with mongoengine 2f9c078
Commits on Sep 23, 2012
Loïc Faure-Lacroix Added support for greenlets 5700a53
Commits on Nov 12, 2013
@brandonjschwartz brandonjschwartz Python 3 compatibility and PEP8 cleanup (since I'm OCD) 8fd5357
Commits on Sep 12, 2014
@llacroix llacroix Merge pull request #2 from brandonjschwartz/master
Python 3 compatibility and PEP8 cleanup (since I'm OCD)
d9351a2
@llacroix llacroix Updated __init__.py to remove print statement 1546c1f
@llacroix llacroix Updated version to 0.2.1 1307db2
Showing with 632 additions and 33 deletions.
  1. +3 −0 .gitignore
  2. +0 −17 README
  3. +32 −0 README.md
  4. +86 −0 docs/Makefile
  5. +13 −0 docs/api.rst
  6. +235 −0 docs/conf.py
  7. +28 −0 docs/glossary.rst
  8. +151 −0 docs/index.rst
  9. +4 −0 docs/tutorials/index.rst
  10. +65 −3 pyramid_mongo/__init__.py
  11. +10 −8 pyramid_mongo/tests/test_init.py
  12. +5 −5 setup.py
View
3 .gitignore
@@ -1,5 +1,8 @@
*.pyc
*.egg-info
+.idea
.tox
.coverage
nosetests.xml
+docs/_build
+docs/_themes
View
17 README
@@ -1,17 +0,0 @@
-About
-=====
-
-pyramid_mongo is intended for use with the default python driver for mongodb
-
-How to use
-==========
-
-You have to define at least 3 things in your settings
-
- mongo.uri = uri of your database (mongodb://localhost/)
- mondo.db = name of the database you want to use
-
-Those two are optional
-
- mongo.username = username for authentication to the db
- mongo.password = password used for authentication to the db
View
32 README.md
@@ -0,0 +1,32 @@
+About
+=====
+
+pyramid_mongo is intended for use with the default python driver for mongodb
+
+How to use
+==========
+
+You have to define at least 3 things in your settings
+
+ mongo.uri = uri of your database (mongodb://localhost/)
+ mondo.db = name of the database you want to use
+
+Those two are optional
+
+ mongo.username.dbname = username for authentication to dbname
+ mongo.password.dbname = password used for authentication to dbname
+
+Mongodb uri format
+==================
+
+The format of the mongodb uri is the one that use mongodb. You can pass
+multiple uris to mongo.uri. They must be separated by newlines and they
+must be uniques. MongoDb will not accept two identical uri. But it will
+accept uris reffering to the same host and same server if hostnames are
+not identical.
+
+ mongo.uri = localhost
+ 127.0.0.1
+
+Is something valid and will work. Connection will open 2 connections on the
+default port.
View
86 docs/Makefile
@@ -0,0 +1,86 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS = -W
+SPHINXBUILD = sphinx-build
+PAPER =
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " changes to make an overview over all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+
+clean:
+ -rm -rf _build/*
+
+html:
+ mkdir -p _build/html _build/doctrees
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
+ @echo
+ @echo "Build finished. The HTML pages are in _build/html."
+
+text:
+ mkdir -p _build/text _build/doctrees
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) _build/text
+ @echo
+ @echo "Build finished. The HTML pages are in _build/text."
+
+pickle:
+ mkdir -p _build/pickle _build/doctrees
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files or run"
+ @echo " sphinx-web _build/pickle"
+ @echo "to start the sphinx-web server."
+
+web: pickle
+
+htmlhelp:
+ mkdir -p _build/htmlhelp _build/doctrees
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in _build/htmlhelp."
+
+latex:
+ mkdir -p _build/latex _build/doctrees
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+ cp _static/*.png _build/latex
+ ./convert_images.sh
+ cp _static/latex-warning.png _build/latex
+ cp _static/latex-note.png _build/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in _build/latex."
+ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+ "run these through (pdf)latex."
+
+changes:
+ mkdir -p _build/changes _build/doctrees
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
+ @echo
+ @echo "The overview file is in _build/changes."
+
+linkcheck:
+ mkdir -p _build/linkcheck _build/doctrees
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in _build/linkcheck/output.txt."
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) _build/epub
+ @echo
+ @echo "Build finished. The epub file is in _build/epub."
+
View
13 docs/api.rst
@@ -0,0 +1,13 @@
+.. _pyramid_mongo:
+
+:mod:`pyramid_mongo` API
+---------------------------
+
+.. automodule:: pyramid_mongo
+
+.. autofunction:: includeme
+
+.. autofunction:: get_db
+
+.. autofunction:: get_connection
+
View
235 docs/conf.py
@@ -0,0 +1,235 @@
+# -*- coding: utf-8 -*-
+#
+# pyramid_mongo documentation build configuration file
+#
+# This file is execfile()d with the current directory set to its containing
+# dir.
+#
+# The contents of this file are pickled, so don't put values in the
+# namespace that aren't pickleable (module imports are okay, they're
+# removed automatically).
+#
+# All configuration values have a default value; values that are commented
+# out serve to show the default value.
+
+# If your extensions are in another directory, add it here. If the
+# directory is relative to the documentation root, use os.path.abspath to
+# make it absolute, like shown here.
+#sys.path.append(os.path.abspath('some/directory'))
+
+
+import sys, os
+
+# Add and use Pylons theme
+if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
+ from subprocess import call, Popen, PIPE
+
+ p = Popen('which git', shell=True, stdout=PIPE)
+ git = p.stdout.read().strip()
+ cwd = os.getcwd()
+ _themes = os.path.join(cwd, '_themes')
+
+ if not os.path.isdir(_themes):
+ call([git, 'clone', 'git://github.com/Pylons/pylons_sphinx_theme.git',
+ '_themes'])
+ else:
+ os.chdir(_themes)
+ call([git, 'checkout', 'master'])
+ call([git, 'pull'])
+ os.chdir(cwd)
+
+ sys.path.append(os.path.abspath('_themes'))
+
+ parent = os.path.dirname(os.path.dirname(__file__))
+ sys.path.append(os.path.abspath(parent))
+ wd = os.getcwd()
+ os.chdir(parent)
+ os.system('%s setup.py test -q' % sys.executable)
+ os.chdir(wd)
+
+ for item in os.listdir(parent):
+ if item.endswith('.egg'):
+ sys.path.append(os.path.join(parent, item))
+
+# General configuration
+# ---------------------
+
+# 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.intersphinx',
+ ]
+
+# Looks for pyramid's objects
+intersphinx_mapping = {
+ 'pyramid':
+ ('http://docs.pylonsproject.org/projects/pyramid/dev/', None)}
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['.templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General substitutions.
+project = 'pyramid_mongo'
+copyright = '2012, Loic Faure-Lacroix <lamerstar@gmail.com>'
+
+# The default replacements for |version| and |release|, also used in various
+# other places throughout the built documents.
+#
+# The short X.Y version.
+version = '0.1'
+# The full version, including alpha/beta/rc tags.
+release = version
+
+# There are two options for replacing |today|: either, you set today to
+# some non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directories, that shouldn't be
+# searched for source files.
+#exclude_dirs = []
+
+exclude_patterns = ['_themes/README.rst',]
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+
+# Options for HTML output
+# -----------------------
+
+# Add and use Pylons theme
+html_theme_path = ['_themes']
+html_theme = 'pyramid'
+html_theme_options = dict(
+ github_url='https://github.com/llacroix/pyramid_mongo',
+ in_progress='true'
+ )
+
+# The style sheet to use for HTML and HTML Help pages. A file of that name
+# must exist either in Sphinx' static/ path, or in one of the custom paths
+# given in html_static_path.
+# html_style = 'repoze.css'
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as
+# html_title.
+#html_short_title = None
+
+# The name of an image file (within the static path) to place at the top of
+# the sidebar.
+# html_logo = '.static/logo_hi.gif'
+
+# The name of an image file (within the static path) to use as favicon of
+# the docs. This file should be a Windows icon file (.ico) being 16x16 or
+# 32x32 pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets)
+# here, relative to this directory. They are copied after the builtin
+# static files, so a file named "default.css" will overwrite the builtin
+# "default.css".
+#html_static_path = ['.static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page
+# bottom, using the given strftime format.
+html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, the reST sources are included in the HTML build as
+# _sources/<name>.
+#html_copy_source = True
+
+# If true, an OpenSearch description file will be output, and all pages
+# will contain a <link> tag referring to it. The value of this option must
+# be the base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'atemplatedoc'
+
+
+# Options for LaTeX output
+# ------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, document class [howto/manual]).
+latex_documents = [
+ ('index', 'pyramid_mongo.tex', 'pyramid_mongo Documentation',
+ 'Loic Faure-Lacroix', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the
+# top of the title page.
+latex_logo = '.static/logo_hi.gif'
+
+# For "manual" documents, if this is true, then toplevel headings are
+# parts, not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
View
28 docs/glossary.rst
@@ -0,0 +1,28 @@
+.. _glossary:
+
+Glossary
+========
+
+.. glossary::
+ :sorted:
+
+ Pyramid
+ A `web framework <http://pylonsproject.org>`_.
+
+ tween
+ A bit of code that sits between the Pyramid router's main request
+ handling function and the upstream WSGI component that uses Pyramid as
+ its 'app'. The word "tween" is a contraction of "between". A tween may
+ be used by Pyramid framework extensions, to provide, for example,
+ Pyramid-specific view timing support, bookkeeping code that examines
+ exceptions before they are returned to the upstream WSGI application, or
+ a variety of other features. Tweens behave a bit like WSGI 'middleware'
+ but they have the benefit of running in a context in which they have
+ access to the Pyramid application registry as well as the Pyramid
+ rendering machinery. See the main Pyramid documentation for more
+ information about tweens.
+
+ Exception view
+ An exception view is a :Pyramid view callable which may be invoked when
+ an exception is raised during request processing.
+
View
151 docs/index.rst
@@ -0,0 +1,151 @@
+pyramid_mongo
+================
+
+Overview
+--------
+
+A package which provides integration between the Pyramid web application
+server and the `MongoDB` object database.
+
+
+Installation
+------------
+
+Install using setuptools, e.g. (within a virtualenv)::
+
+ $ easy_install pyramid_mongo
+
+ $ pip install pyramid_mongo
+
+Setup
+-----
+
+Once ``pyramid_mongo`` is installed, you must use the ``config.include``
+mechanism to include it into your Pyramid project's configuration. In your
+Pyramid project's ``__init__.py``:
+
+.. code-block:: python
+ :linenos:
+
+ config = Configurator(.....)
+ config.include('pyramid_mongo')
+
+Alternately you can use the ``pyramid.includes`` configuration value in your
+``.ini`` file:
+
+.. code-block:: ini
+ :linenos:
+
+ [app:myapp]
+ pyramid.includes = pyramid_mongo
+
+Using
+-----
+
+For :mod:`pyramid_mongo` to work properly, you must add at least two
+setting to your of your Pyramid's ``.ini`` file configuration (or to the
+``settings`` dictionary if you're not using ini configuration):
+``mongo.uri`` and ``mongo.db`` For example:
+
+.. code-block:: ini
+
+ [app:myapp]
+ ...
+ mongo.uri = mongodb://localhost/
+ mongo.db = mongo_pyramid
+ ...
+
+The ``mongo.uri`` parameter is a URL which describes a mongodb connection uri.
+
+Once you've both included the ``pyramid_mongo`` into your configuration
+via ``config.include('pyramid_mongo')`` and you've added a
+``mongo.uri`` setting to your configuration, you can then use the
+:func:`pyramid_mongo.get_db` API in your Pyramid application, most
+commonly in a Pyramid *root factory*:
+
+.. code-block:: python
+ :linenos:
+
+ from pyramid_mongo import get_db
+
+ class MyModel(object):
+ __parent__ = __name__ = None
+
+ def to_dict(self):
+ return dict()
+
+ def root_factory(request):
+ db = get_db(request)
+
+ root = db.root.find_one()
+ if not root:
+ root = MyModel()
+ db.root.insert(root.to_dict())
+
+ return root
+
+The :func:`pyramid_mongo.get_db` API returns a MongoDB database to
+the main database you've specified via ``mongo.db`` in your
+configuration.
+
+When the request is finalized, the database you've opened via
+``get_db`` will be freeed to the next thread.
+
+Examples with authentication
+++++++++++++++++++++++++++++
+
+A config file with authentication should look like that
+
+.. code-block:: ini
+
+ [app:myapp]
+ ...
+ mongo.uri = mongodb://localhost/
+ mongo.db = mongo_pyramid
+
+ mongo.username.mongo_pyramid = username
+ mongo.password.mongo_pyramid = password
+
+
+In this example, you can see that ``mongo.username`` and ``mongo.password`` is
+followed by a dot and the name of the database. In this example, the primary
+database is ``mongo_pyramid``. That is why we have to set ``mongo.username.mongo_pyramid``
+and ``mongo.password.mongo_pyramid``
+
+If we had a different database from the primary one we could also add those settings like that
+
+.. code-block:: ini
+ mongo.username.other = username
+ mongo.password.other = password
+
+Keep in mind that each database has its own users. If you connect to ``pyramid_mongo``, it
+won't connect to other database. On the other hand, if you set a password for the admin
+database, it should give you access to every other database.
+
+
+More Information
+----------------
+
+.. toctree::
+ :maxdepth: 1
+
+ api.rst
+ tutorials/index.rst
+ glossary.rst
+
+
+Reporting Bugs / Development Versions
+-------------------------------------
+
+Visit http://github.com/llacroix/pyramid_mongo to download development or
+tagged versions.
+
+Visit http://github.com/llacroix/pyramid_mongo/issues to report bugs.
+
+Indices and tables
+------------------
+
+* :ref:`glossary`
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
View
4 docs/tutorials/index.rst
@@ -0,0 +1,4 @@
+Wiki tutorial
+=============
+
+Creating a wiki using pyramid_mongo
View
68 pyramid_mongo/__init__.py
@@ -1,25 +1,70 @@
from pyramid.exceptions import ConfigurationError
+from pyramid.settings import asbool
from pymongo import Connection
+import logging
+log = logging.getLogger(__name__)
URI = 'mongo.uri'
+MONGOENGINE = 'mongo.mongoengine'
USERNAME = 'mongo.username'
PASSWORD = 'mongo.password'
DBNAME = 'mongo.db'
+GREENLETS = 'mongo.use_greenlets'
+
def get_connection(config, conn_cls=None):
+ """get_connection creates a connection to one or more mongodb server.
+ It take as argument a config that should have the "mongo.uri" set
+ to a string separated by new lines for each server.
+
+ The uri must be of a form acceptable by mongodb.
+ http://www.mongodb.org/display/DOCS/Connections
+ """
+
if conn_cls is None:
conn_cls = Connection
registry = config.registry
uri = registry.settings.get(URI)
+ greenlets = registry.settings.get(GREENLETS)
if uri is None:
raise ConfigurationError('There is no configured "mongo.uri"')
- return conn_cls(uri)
+ # Spliting configs to get more than one uri
+ if not isinstance(uri, list):
+ uri = uri.splitlines()
+
+ kargs = {
+ 'use_greenlets': asbool(greenlets)
+ }
+
+ return conn_cls(uri, **kargs)
def get_db(request, name=None):
+ """get_db opens a handle for a database using a connection.
+ the primary database is defined by the setting "mongo.db".
+
+ If passed "name" as argument, get_db will return a different
+ database than the one set in the settings.
+
+ If you have mongo.username and mongo.password set, it will try
+ to connecto to the database.
+
+ Here is an example
+
+ mongo.uri = 127.0.0.1
+ localhost
+ mongo.db = blog
+
+ mongo.username.blog = theuser
+ mongo.password.blog = thepassword
+
+ mongo.username.blog2 = theuser2
+ mongo.password.blog2 = thepassword2
+ """
+
dbname = name
registry = request.registry
@@ -45,8 +90,8 @@ def get_db(request, name=None):
mongodbs[dbname] = db
request._mongo_dbs = mongodbs
- username = registry.settings.get(USERNAME)
- password = registry.settings.get(PASSWORD)
+ username = registry.settings.get(USERNAME + '.' + dbname)
+ password = registry.settings.get(PASSWORD + '.' + dbname)
if not username is None and not password is None:
db.authenticate(username, password)
@@ -59,6 +104,19 @@ def end_request(request):
return db
+def setup_mongoengine(config):
+ # Simple setup mongoengine
+ from mongoengine import connection
+ log.debug("Loading mongoengine")
+ registry = config.registry
+
+ connection._connections['default'] = config.registry._mongo_conn
+ connection._connection_settings['default'] = {
+ 'name': registry.settings.get(DBNAME),
+ 'username': registry.settings.get(USERNAME),
+ 'password': registry.settings.get(PASSWORD),
+ }
+
def includeme(config, get_connection=get_connection):
# get_connection passed for testing
@@ -67,3 +125,7 @@ def includeme(config, get_connection=get_connection):
mongodb.uri
"""
config.registry._mongo_conn = get_connection(config)
+
+ mongoengine = asbool(config.registry.settings.get(MONGOENGINE))
+ if mongoengine and config.registry._mongo_conn:
+ setup_mongoengine(config)
View
18 pyramid_mongo/tests/test_init.py
@@ -3,6 +3,7 @@
from pyramid.exceptions import ConfigurationError
from pymongo.errors import AutoReconnect
+
class Test_get_connection(TestCase):
def setUp(self):
@@ -31,7 +32,8 @@ def test_with_invalid_uri(self):
def test_with_valid_uri(self):
self.config.registry.settings['mongo.uri'] = "mongodb://localhost/"
conn = self._callFUT(self.config, DummyConnection)
- self.assertEqual(conn.uri, 'mongodb://localhost/')
+ self.assertEqual(conn.uri[0], 'mongodb://localhost/')
+
class Test_get_db(TestCase):
@@ -76,13 +78,13 @@ def test_auth(self):
request = self._makeRequest()
request.registry._mongo_conn = DummyConnection()
- request.registry.settings['mongo.username'] = 'fun'
- request.registry.settings['mongo.password'] = 'fusdn'
+ request.registry.settings['mongo.username.test'] = 'fun'
+ request.registry.settings['mongo.password.test'] = 'fusdn'
db = self._callFUT(request, 'test')
self.assertEqual(db.authenticated, False)
- request.registry.settings['mongo.username'] = 'admin'
- request.registry.settings['mongo.password'] = 'fun'
+ request.registry.settings['mongo.username.test'] = 'admin'
+ request.registry.settings['mongo.password.test'] = 'fun'
db = self._callFUT(request, 'test')
self.assertEqual(db.authenticated, True)
@@ -96,6 +98,7 @@ def test_endrequest_callback(self):
self.assertTrue(db.logged_out)
self.assertTrue(conn.ended)
+
class Test_includeme(TestCase):
def _callFUT(self, config, get_connection):
from pyramid_mongo import includeme
@@ -115,6 +118,7 @@ def get_connection(request):
self._callFUT(self.config, get_connection)
self.assertEqual(self.config.registry._mongo_conn, 'conn')
+
class DummyDB(object):
def authenticate(self, username, password):
@@ -124,7 +128,6 @@ def authenticate(self, username, password):
def logout(self):
self.logged_out = True
-
class DummyConnection(object):
def __init__(self, uri=None):
@@ -134,5 +137,4 @@ def __getitem__(self, name):
return DummyDB()
def end_request(self):
- self.ended = True
-
+ self.ended = True
View
10 setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-version = '0.1'
+version = '0.2.1'
testing_extras = ['nose', 'coverage']
docs_extras = ['Sphinx']
@@ -27,10 +27,10 @@
'pyramid',
'pymongo',
],
- extras_require = {
- 'dev':testing_extras,
- 'docs':docs_extras,
- },
+ extras_require={
+ 'dev': testing_extras,
+ 'docs': docs_extras,
+ },
entry_points="""
# -*- Entry points: -*-
""",

No commit comments for this range

Something went wrong with that request. Please try again.