# Path: entity/category.py
# class Category:
#     def __init__(self, id=None, name=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def name_exists(db, name):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/image.py
# class Image:
#     def __init__(self, id=None, recipe_id=None, path=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/synonym.py
# class Synonym:
#     def __init__(self, id=None, recipe_id=None, name=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/tag.py
# class Tag:
#     def __init__(self, id=None, name='', synonym_of=None, synonyms=[]):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def find_synonyms(self, db):
#     def from_row(db, row, find_synonyms=True):
#     def is_new(self):
#     def name_exists(db, name):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/url.py
# class Url:
#     def __init__(self, id=None, recipe_id=None, name='', url=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/user.py
# class User:
#     def __init__(self, id=None, name=None, pw_hash=None, salt=None, session=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def from_row(db, row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):


from entity import category as category_entity
from entity import image as image_entity
from entity import synonym as synonym_entity
from entity import tag as tag_entity
from entity import url as url_entity
from entity import user as user_entity
import os
                    'VALUES (?, ?)'
            params = [self.id, category.id]
            cursor.execute(query, params)

        # Synonyms
        self.__delete_synonyms(db)
        for synonym in self.synonyms:
            synonym.recipe_id = self.id
            synonym.save(db)

        # Tags
        self.__delete_recipe_has_tag(db)
        for tag in self.tags:
            query = 'INSERT INTO recipe_has_tag (recipe_id, tag_id) ' \
                    'VALUES (?, ?)'
            params = [self.id, tag.id]
            cursor.execute(query, params)

        # Urls
        self.__delete_urls(db)
        for url in self.urls:
            url.recipe_id = self.id
            url.save(db)

    def __delete_images(self, db, force=False):
        """ Deletes entries in images and from file system. If force is set to
        True files will always be removed. """
        # Files (load currently stored from database, ignore possible new ones
        # in self.images)
        image_pathes = [image.path for image in self.images]

# Path: entity/category.py
# class Category:
#     def __init__(self, id=None, name=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def name_exists(db, name):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/image.py
# class Image:
#     def __init__(self, id=None, recipe_id=None, path=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/synonym.py
# class Synonym:
#     def __init__(self, id=None, recipe_id=None, name=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/tag.py
# class Tag:
#     def __init__(self, id=None, name='', synonym_of=None, synonyms=[]):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def find_synonyms(self, db):
#     def from_row(db, row, find_synonyms=True):
#     def is_new(self):
#     def name_exists(db, name):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/url.py
# class Url:
#     def __init__(self, id=None, recipe_id=None, name='', url=''):
#     def __str__(self):
#     def delete(self, db):
#     def find_all(db):
#     def find_pk(db, id):
#     def find_recipe(db, recipe):
#     def from_row(row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):
# 
# Path: entity/user.py
# class User:
#     def __init__(self, id=None, name=None, pw_hash=None, salt=None, session=None):
#     def __str__(self):
#     def count_all(db):
#     def delete(self, db):
#     def find_all(db):
#     def find_name(db, name):
#     def find_pk(db, id):
#     def from_row(db, row):
#     def is_new(self):
#     def save(self, db):
#     def __generic_find(db, query, params):


# Path: entity/recipe.py
from entity import category as category_entity
from entity import image as image_entity
from entity import synonym as synonym_entity
from entity import tag as tag_entity
from entity import url as url_entity
from entity import user as user_entity
import os

                    'VALUES (?, ?)'
            params = [self.id, category.id]
            cursor.execute(query, params)

        # Synonyms
        self.__delete_synonyms(db)
        for synonym in self.synonyms:
            synonym.recipe_id = self.id
            synonym.save(db)

        # Tags
        self.__delete_recipe_has_tag(db)
        for tag in self.tags:
            query = 'INSERT INTO recipe_has_tag (recipe_id, tag_id) ' \
                    'VALUES (?, ?)'
            params = [self.id, tag.id]
            cursor.execute(query, params)

        # Urls
        self.__delete_urls(db)
        for url in self.urls:
            url.recipe_id = self.id
            url.save(db)

    def __delete_images(self, db, force=False):
        """ Deletes entries in images and from file system. If force is set to
        True files will always be removed. """
        # Files (load currently stored from database, ignore possible new ones
        # in self.images)
        image_pathes = [image.path for image in self.images]

        images = image_entity.Image.find_recipe(db, self)