Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
* Freeze pymongo version to 2.3 in setup because 2.4 is not compatibl…
Browse files Browse the repository at this point in the history
…e with

  last mongokit version.
* No more need to have MONGO_DB_NAME in environm it is deduced from mongo db
  uri
  • Loading branch information
hadrien committed Dec 5, 2012
1 parent 264775c commit b9ec1bf
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 36 deletions.
25 changes: 25 additions & 0 deletions .gitignore
@@ -0,0 +1,25 @@
*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.noseids
velo/.noseids
velo/coverage.xml
velo/tests/.noseids
velo/tests/coverage.xml
coverage.xml
nosetests.xml
9 changes: 0 additions & 9 deletions .hgignore

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
@@ -0,0 +1 @@
include *.rst
1 change: 1 addition & 0 deletions README.rst
Expand Up @@ -72,6 +72,7 @@ Pyramid REST
What next?
----------

#. Security
#. HTTP PATCH method: http://tools.ietf.org/html/rfc5789
#. Resource Scaffolding command;
#. Links;
Expand Down
1 change: 0 additions & 1 deletion example/model/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import


from example.model.application import Application
Expand Down
3 changes: 1 addition & 2 deletions example/model/application.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from mongokit import Document

Expand All @@ -12,7 +11,7 @@ class Application(Document):

structure = {
'name': unicode,
'secret_key': basestring,
'secret_key': unicode,
}

required_fields = ['name', 'secret_key']
1 change: 0 additions & 1 deletion example/model/message.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from bson.objectid import ObjectId

Expand Down
1 change: 0 additions & 1 deletion example/model/user.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from bson.objectid import ObjectId

Expand Down
1 change: 0 additions & 1 deletion example/views/application_user_messages.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from pyramid_rest.mongo import CollectionView

Expand Down
1 change: 0 additions & 1 deletion example/views/application_users.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from pyramid_rest.resource import method_config

Expand Down
1 change: 0 additions & 1 deletion example/views/applications.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from pyramid_rest.mongo import CollectionView

Expand Down
1 change: 0 additions & 1 deletion example/views/messages.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from pyramid_rest.mongo import CollectionView

Expand Down
10 changes: 4 additions & 6 deletions pyramid_rest/mongo.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os
import logging
from urlparse import urlparse

from bson.objectid import ObjectId, InvalidId
import mongokit
Expand All @@ -23,13 +22,12 @@

log = logging.getLogger(__name__)

DATABASE_NAME = os.environ['MONGO_DB_NAME']

__all__ = ['register_document', 'CollectionView', ]


def includeme(config):
log.info('Configure mongo...')
os.environ['MONGO_URL_NAME'] = urlparse(os.environ['MONGO_URI']).path[1:]
connection = MongoConnection(
os.environ['MONGO_URI'],
auto_start_request=False,
Expand Down Expand Up @@ -79,7 +77,7 @@ def mongo_connection(request):


def mongo_db(request):
return getattr(request.mongo_connection, DATABASE_NAME)
return getattr(request.mongo_connection, os.environ['MONGO_DB_NAME'])


def begin_request(event):
Expand Down Expand Up @@ -172,6 +170,6 @@ def show(self, **identifiers):
return self._get_document_or_404(identifiers)

def delete(self, **identifiers):
# XXX: cascade delete sub resources?
"""No delete cascade on sub resources."""
self._get_document_or_404(identifiers).delete()
return HTTPOk()
1 change: 0 additions & 1 deletion pyramid_rest/renderer.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from datetime import datetime, date
from decimal import Decimal
import json
Expand Down
3 changes: 2 additions & 1 deletion pyramid_rest/resource.py
Expand Up @@ -120,7 +120,8 @@ def add_resource(
try:
cls = config.maybe_dotted(dotted_class)
except ImportError:
raise ImportError('No class %s found.' % dotted_class)
log.error('No class %s found.', dotted_class)
raise
config.scan(dotted_module)

res(cls) # decorate class to register config
Expand Down
1 change: 0 additions & 1 deletion pyramid_rest/tests/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import os


Expand Down
6 changes: 3 additions & 3 deletions pyramid_rest/tests/functional/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import os
import sys
import unittest

Expand All @@ -18,10 +18,10 @@ def setUp(self):

@property
def mongo_db(self):
from pyramid_rest.mongo import IMongoConnection, DATABASE_NAME
from pyramid_rest.mongo import IMongoConnection
return getattr(
self.app.app.registry.getUtility(IMongoConnection),
DATABASE_NAME
os.environ['MONGO_DB_NAME']
)

def tearDown(self):
Expand Down
1 change: 0 additions & 1 deletion pyramid_rest/tests/functional/test_resource.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import unittest

from pyramid import testing
Expand Down
1 change: 0 additions & 1 deletion pyramid_rest/tests/unittests/test_mongo.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import unittest


Expand Down
1 change: 0 additions & 1 deletion pyramid_rest/tests/unittests/test_renderer.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import unittest
from decimal import Decimal
from bson.objectid import ObjectId
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = pyramid_rest
version = 0.1.0
version = 0.2.1
summary = Pyramid Rest Extension
requires-dist =
pyramid
Expand Down
3 changes: 1 addition & 2 deletions setup.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from __future__ import absolute_import
import setuptools

if not getattr(setuptools, "_distribute", False):
Expand All @@ -20,7 +19,7 @@
'yanc',
]

extras_require = {'mongo': ['mongokit', ]}
extras_require = {'mongo': ['mongokit', 'pymongo==2.3']}

setuptools.setup(
setup_requires=setup_requires,
Expand Down

0 comments on commit b9ec1bf

Please sign in to comment.