Project

Profile

Help

Refactor #78

closed

Convert pulp.server.db.connection to manage the database connection with an object

Added by Anonymous over 9 years ago. Updated almost 3 years ago.

Status:
CLOSED - WONTFIX
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

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.

3) Ensure that get_collection(), get_database(), and get_connection() raise a consistent Exception if initialize() has not already been called.

4) Update the associated tests

Actions #1

Updated by rbarlow over 9 years ago

  • Tracker changed from Story to Task
Actions #2

Updated by rbarlow over 9 years ago

  • Project changed from 22 to Pulp
Actions #3

Updated by mhrivnak over 9 years ago

Please elaborate on why, and be more specific. Can it not use any globals at all, or are there specific ones you want to eliminate? What is the goal of this change?

Actions #4

Updated by bmbouter over 9 years ago

  • Subject changed from [Task] Convert pulp.server.db.connection to not use globals to Convert pulp.server.db.connection to not use globals
Actions #5

Updated by bmbouter over 9 years ago

  • Description updated (diff)
Actions #6

Updated by bmbouter over 9 years ago

  • Subject changed from Convert pulp.server.db.connection to not use globals to Convert pulp.server.db.connection to manage the database connection with an object
  • Description updated (diff)
Actions #7

Updated by bmbouter over 9 years ago

  • Tracker changed from Task to Refactor
Actions #8

Updated by bmbouter about 5 years ago

  • Status changed from NEW to CLOSED - WONTFIX
Actions #9

Updated by bmbouter about 5 years ago

Pulp 2 is approaching maintenance mode, and this Pulp 2 ticket is not being actively worked on. As such, it is being closed as WONTFIX. Pulp 2 is still accepting contributions though, so if you want to contribute a fix for this ticket, please reopen or comment on it. If you don't have permissions to reopen this ticket, or you want to discuss an issue, please reach out via the developer mailing list.

Actions #10

Updated by bmbouter about 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF