Jason R. Coombs avatar Jason R. Coombs committed 5ad0b8a Draft

Fixed failures under pymongo 2.2 due to use of deprecated module pymongo.objectid

Comments (0)

Files changed (4)

 
 import itertools
 import re
+import importlib
 
 from . import storage
 
 	Karma.store = Karma.from_URI(uri)
 	# for backward compatibility
 	globals().update(karma=Karma.store)
-	__import__('pmxbot.util').util.karma = Karma.store
+	importlib.import_module('pmxbot.util').karma = Karma.store
 
 
 # for backward compatibility:
 # vim:ts=4:sw=4:noexpandtab
 
 import random
+import importlib
+
 from . import storage
 
 def init_quotes(uri):
 	Quotes.store = Quotes.from_URI(uri)
 	# for backward compatibility
 	globals().update(quotes = Quotes.store)
-	__import__('pmxbot.util').util.quotes = Quotes.store
+	importlib.import_module('pmxbot.util').quotes = Quotes.store
 
 class Quotes(storage.SelectableStorage):
 	lib = 'pmx'

pmxbot/storage.py

 import os
 import itertools
 import urlparse
+import importlib
 
 from .classutil import itersubclasses
 
 
 class SQLiteStorage(Storage):
 	scheme = 'sqlite'
-	
+
 	@classmethod
 	def uri_matches(cls, uri):
 		return uri.endswith('.sqlite')
 
 class MongoDBStorage(Storage):
 	scheme = 'mongodb'
-	
+
 	@classmethod
 	def uri_matches(cls, uri):
 		return uri.startswith('mongodb:')
 
 	def __init__(self, host_uri):
-		# for now do a delayed import to avoid interfering with
-		# canonical logging module.
-		globals().update(pymongo=__import__('pymongo.objectid'))
+		pymongo = importlib.import_module('pymongo')
+		bson = importlib.import_module('bson')
+		globals().update(
+			pymongo=pymongo,
+			bson=bson,
+		)
 		self.db = pymongo.Connection(host_uri).pmxbot[self.collection_name]
 
 def migrate_all(source, dest):
 # -*- coding: utf-8 -*-
 # vim:ts=4:sw=4:noexpandtab
 # c-basic-indent: 4; tab-width: 4; indent-tabs-mode: true;
-from setuptools import find_packages
+import sys
+
+import setuptools
+
+py26reqs = ['importlib'] if sys.version_info < (2, 7) else []
 
 setup_params = dict(
 	name="pmxbot",
 	use_hg_version=True,
-	packages=find_packages(),
+	packages=setuptools.find_packages(),
 	include_package_data=True,
 	entry_points=dict(
 		console_scripts = [
 		#for viewer
 		"jinja2",
 		"cherrypy",
-	],
+	] + py26reqs,
 	dependency_links=[
 		'https://bitbucket.org/jaraco/httplib2/downloads',
 		'https://github.com/jaraco/wordnik-python/downloads',
 )
 
 if __name__ == '__main__':
-	from setuptools import setup
-	setup(**setup_params)
+	setuptools.setup(**setup_params)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.