Project

Profile

Help

Refactor #78

Updated by bmbouter about 9 years ago

This Task is designed to solve two problems. (1) To remove the use of globals and replace it with a class based design and (2) to consolidate the database getter methods onto the class managing the database singleton. 

 I generally avoid the use of globals because they casually share state and promote a non object oriented paradigm. Using a class to store any globals requires developers to be more explicit, and access functions can be getter methods instead of module level functions. 

 The specifics: 
 1) Introduce a new class in pulp.server.db.connection and move the initialize method into it as a @classmethod. Refactor all calls to the old pulp.server.db.connection.initialize method to use the new class method. The @classmethod initialize should store the _CONNECTION and _DATABASE objects as class attributes. 

 2) Move the get_collection(), get_database(), and get_connection() methods to be @classmethods on the new class introduced in (1). Refactor the usages of these 3 functions to use them as classmethods.

Back