This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from projects_repository import ProjectsRepository | |
from project import Project | |
def load_all_items_from_database(repository): | |
print("Loading all items from database:") | |
projects = repository.read() | |
at_least_one_item = False | |
for p in projects: | |
at_least_one_item = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
from bson.objectid import ObjectId | |
from project import Project | |
class ProjectsRepository(object): | |
""" Repository implementing CRUD operations on projects collection in MongoDB """ | |
def __init__(self): | |
# initializing the MongoClient, this helps to | |
# access the MongoDB databases and collections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bson.objectid import ObjectId | |
class Project(object): | |
"""A class for storing Project related information""" | |
def __init__(self, project_id=None, title=None, description=None, price=0.0, assigned_to=None): | |
if project_id is None: | |
self._id = ObjectId() | |
else: | |
self._id = project_id |