Commits

Jason R. Coombs committed 5ad0b8a

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

  • Participants
  • Parent commits 653941a

Comments (0)

Files changed (4)

File pmxbot/karma.py

 
 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:

File pmxbot/quotes.py

 # 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'

File 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)