aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-11-13 20:23:26 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-11-13 20:23:26 -0600
commitee91c2b88d1a42b9d15d34d2c081cd8394649041 (patch)
tree01a75b958b2814763a0b219145bbe284d1d04931 /mediagoblin/db
parent4671fda345394dad9ca4278b1cf7b2cdf7d2b4ee (diff)
parent285ffeddf3542201b83072d3be544c85e9c487c2 (diff)
downloadmediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.lz
mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.xz
mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.zip
Merge remote-tracking branch 'remotes/nyergler/pep8-ification'
Conflicts: mediagoblin/db/migrations.py mediagoblin/db/models.py mediagoblin/user_pages/views.py mediagoblin/util.py
Diffstat (limited to 'mediagoblin/db')
-rw-r--r--mediagoblin/db/__init__.py2
-rw-r--r--mediagoblin/db/indexes.py5
-rw-r--r--mediagoblin/db/models.py35
-rw-r--r--mediagoblin/db/open.py2
-rw-r--r--mediagoblin/db/util.py7
5 files changed, 27 insertions, 24 deletions
diff --git a/mediagoblin/db/__init__.py b/mediagoblin/db/__init__.py
index c5124b1a..27e8a90f 100644
--- a/mediagoblin/db/__init__.py
+++ b/mediagoblin/db/__init__.py
@@ -23,7 +23,7 @@ Database Abstraction/Wrapper Layer
pymongo. Read beow for why, but note that nobody is actually doing
this and there's no proof that we'll ever support more than
MongoDB... it would be a huge amount of work to do so.
-
+
If you really want to prove that possible, jump on IRC and talk to
us about making such a branch. In the meanwhile, it doesn't hurt to
have things as they are... if it ever makes it hard for us to
diff --git a/mediagoblin/db/indexes.py b/mediagoblin/db/indexes.py
index 75394a31..1dd73f2b 100644
--- a/mediagoblin/db/indexes.py
+++ b/mediagoblin/db/indexes.py
@@ -93,8 +93,9 @@ MEDIAENTRY_INDEXES = {
('created', DESCENDING)]},
'state_uploader_tags_created': {
- # Indexing on processed?, media uploader, associated tags, and timestamp
- # Used for showing media items matching a tag search, most recent first.
+ # Indexing on processed?, media uploader, associated tags, and
+ # timestamp Used for showing media items matching a tag
+ # search, most recent first.
'index': [('state', ASCENDING),
('uploader', ASCENDING),
('tags.slug', DESCENDING),
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index 0f5174cc..c010cb89 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -14,7 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import datetime, uuid
+import datetime
+import uuid
from mongokit import Document
@@ -67,17 +68,17 @@ class User(Document):
'username': unicode,
'email': unicode,
'created': datetime.datetime,
- 'plugin_data': dict, # plugins can dump stuff here.
+ 'plugin_data': dict, # plugins can dump stuff here.
'pw_hash': unicode,
'email_verified': bool,
'status': unicode,
'verification_key': unicode,
'is_admin': bool,
- 'url' : unicode,
- 'bio' : unicode, # May contain markdown
- 'bio_html': unicode, # May contain plaintext, or HTML
- 'fp_verification_key': unicode, # forgotten password verification key
- 'fp_token_expire': datetime.datetime
+ 'url': unicode,
+ 'bio': unicode, # May contain markdown
+ 'bio_html': unicode, # May contain plaintext, or HTML
+ 'fp_verification_key': unicode, # forgotten password verification key
+ 'fp_token_expire': datetime.datetime,
}
required_fields = ['username', 'created', 'pw_hash', 'email']
@@ -172,8 +173,8 @@ class MediaEntry(Document):
critical to this piece of media but may be usefully relevant to people
viewing the work. (currently unused.)
- - fail_error: path to the exception raised
- - fail_metadata:
+ - fail_error: path to the exception raised
+ - fail_metadata:
"""
__collection__ = 'media_entries'
@@ -182,11 +183,11 @@ class MediaEntry(Document):
'title': unicode,
'slug': unicode,
'created': datetime.datetime,
- 'description': unicode, # May contain markdown/up
- 'description_html': unicode, # May contain plaintext, or HTML
+ 'description': unicode, # May contain markdown/up
+ 'description_html': unicode, # May contain plaintext, or HTML
'media_type': unicode,
- 'media_data': dict, # extra data relevant to this media_type
- 'plugin_data': dict, # plugins can dump stuff here.
+ 'media_data': dict, # extra data relevant to this media_type
+ 'plugin_data': dict, # plugins can dump stuff here.
'tags': [dict],
'state': unicode,
@@ -218,7 +219,8 @@ class MediaEntry(Document):
return self.db.MediaComment.find({
'media_entry': self['_id']}).sort('created', DESCENDING)
- def get_display_media(self, media_map, fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
+ def get_display_media(self, media_map,
+ fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
"""
Find the best media for display.
@@ -271,7 +273,7 @@ class MediaEntry(Document):
"""
Provide a url to the previous entry from this user, if there is one
"""
- cursor = self.db.MediaEntry.find({'_id' : {"$gt": self['_id']},
+ cursor = self.db.MediaEntry.find({'_id': {"$gt": self['_id']},
'uploader': self['uploader'],
'state': 'processed'}).sort(
'_id', ASCENDING).limit(1)
@@ -284,7 +286,7 @@ class MediaEntry(Document):
"""
Provide a url to the next entry from this user, if there is one
"""
- cursor = self.db.MediaEntry.find({'_id' : {"$lt": self['_id']},
+ cursor = self.db.MediaEntry.find({'_id': {"$lt": self['_id']},
'uploader': self['uploader'],
'state': 'processed'}).sort(
'_id', DESCENDING).limit(1)
@@ -351,4 +353,3 @@ def register_models(connection):
Register all models in REGISTER_MODELS with this connection.
"""
connection.register(REGISTER_MODELS)
-
diff --git a/mediagoblin/db/open.py b/mediagoblin/db/open.py
index e73b6258..e677ba12 100644
--- a/mediagoblin/db/open.py
+++ b/mediagoblin/db/open.py
@@ -29,7 +29,7 @@ def connect_database_from_config(app_config, use_pymongo=False):
port = app_config.get('db_port')
if port:
port = asint(port)
-
+
if use_pymongo:
connection = pymongo.Connection(
app_config.get('db_host'), port)
diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py
index 84a6cbce..52e97f6d 100644
--- a/mediagoblin/db/util.py
+++ b/mediagoblin/db/util.py
@@ -118,11 +118,12 @@ def remove_deprecated_indexes(database, deprecated_indexes=DEPRECATED_INDEXES):
#################
# The default migration registry...
-#
+#
# Don't set this yourself! RegisterMigration will automatically fill
# this with stuff via decorating methods in migrations.py
-class MissingCurrentMigration(Exception): pass
+class MissingCurrentMigration(Exception):
+ pass
MIGRATIONS = {}
@@ -147,7 +148,7 @@ class RegisterMigration(object):
"""
def __init__(self, migration_number, migration_registry=MIGRATIONS):
assert migration_number > 0, "Migration number must be > 0!"
- assert not migration_registry.has_key(migration_number), \
+ assert migration_number not in migration_registry, \
"Duplicate migration numbers detected! That's not allowed!"
self.migration_number = migration_number