Skip to content

Instantly share code, notes, and snippets.

@minion96
minion96 / main.py
Last active August 29, 2015 12:13 — forked from gergob/main.py
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
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
@minion96
minion96 / project.py
Last active August 29, 2015 12:08 — forked from gergob/project.py
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