Project

Profile

Help

Refactor #78

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

Added by Anonymous almost 6 years ago. Updated 3 months 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

History

#1 Updated by rbarlow almost 6 years ago

  • Tracker changed from Story to Task

#3 Updated by mhrivnak over 5 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?

#4 Updated by bmbouter over 5 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

#5 Updated by bmbouter over 5 years ago

  • Description updated (diff)

#6 Updated by bmbouter over 5 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)

#7 Updated by bmbouter over 5 years ago

  • Tracker changed from Task to Refactor

#8 Updated by bmbouter over 1 year ago

  • Status changed from NEW to CLOSED - WONTFIX

#9 Updated by bmbouter over 1 year 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.

#10 Updated by bmbouter over 1 year ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF