# Path: ringo/lib/helpers/appinfo.py
# def get_app_location(name=None):
#     if not name:
#         name = get_app_name()
#     return pkg_resources.get_distribution(name).location
# 
# Path: ringo/lib/helpers/misc.py
# def dynamic_import(cl):
#     d = cl.rfind(".")
#     classname = cl[d + 1:len(cl)]
#     m = __import__(cl[0:d], globals(), locals(), [classname])
#     return getattr(m, classname)
# 
# Path: ringo/scripts/db.py
# def get_session(config_file, transactional=True):
#     """Will return a database session based on the application
#     configuration"""
#     engine = get_engine(config_file)
#     if transactional:
#         DBSession.configure(bind=engine)
#         return DBSession
#     else:
#         NTDBSession.configure(bind=engine)
#         return NTDBSession
# 
# def create_new_revision(args, msg=None):
#     """Will create a new autogenerated revision file. An returns the
#     path of the new generated file."""
#     cfg = get_alembic_config(args)
#     command.revision(cfg, message=msg, autogenerate=True)
#     revision_file = get_last_revision_file(args)
#     while is_locked(revision_file):
#         time.sleep(1)
#     return revision_file


import os
import fnmatch
import json
import subprocess
import uuid
import transaction
import pkg_resources
from sqlalchemy import func
from mako.lookup import TemplateLookup
from ringo.lib.helpers import get_app_location, dynamic_import
from ringo.scripts.db import (
    get_session, create_new_revision
)
from ringo.model.modul import ModulItem, ActionItem, ACTIONS
        tablename = modul + 's'
        label = modul.capitalize()
        label_plural = label + "s"
        clazzpath = ".".join([package, 'model', modul, label])
        values = {
            'modul': modul,
            'clazzpath': clazzpath,
            'label': label,
            'label_plural': label_plural,
            'modul': modul,
            'table': tablename,
            'id': id,
            'clazz': clazz,
            'mixins': mixinclasses
        }
        template = template_lookup.get_template("model.mako")
        generated = template.render(**values)
        outfile = open(target_file, 'w+')
        outfile.write(generated)
        outfile.close()
        # Import the new model file. This is needed to be able to
        # generate the migration script properly.
        dynamic_import(clazzpath)
        print 'Ok.'
    except Exception:
        print 'Failed.'


def del_form_file(package, modul):
    filename = modul + "s"

# Path: ringo/lib/helpers/appinfo.py
# def get_app_location(name=None):
#     if not name:
#         name = get_app_name()
#     return pkg_resources.get_distribution(name).location
# 
# Path: ringo/lib/helpers/misc.py
# def dynamic_import(cl):
#     d = cl.rfind(".")
#     classname = cl[d + 1:len(cl)]
#     m = __import__(cl[0:d], globals(), locals(), [classname])
#     return getattr(m, classname)
# 
# Path: ringo/scripts/db.py
# def get_session(config_file, transactional=True):
#     """Will return a database session based on the application
#     configuration"""
#     engine = get_engine(config_file)
#     if transactional:
#         DBSession.configure(bind=engine)
#         return DBSession
#     else:
#         NTDBSession.configure(bind=engine)
#         return NTDBSession
# 
# def create_new_revision(args, msg=None):
#     """Will create a new autogenerated revision file. An returns the
#     path of the new generated file."""
#     cfg = get_alembic_config(args)
#     command.revision(cfg, message=msg, autogenerate=True)
#     revision_file = get_last_revision_file(args)
#     while is_locked(revision_file):
#         time.sleep(1)
#     return revision_file


# Path: ringo/scripts/modul.py
import os
import fnmatch
import json
import subprocess
import uuid
import transaction
import pkg_resources
from sqlalchemy import func
from mako.lookup import TemplateLookup
from ringo.lib.helpers import get_app_location, dynamic_import
from ringo.scripts.db import (
    get_session, create_new_revision
)
from ringo.model.modul import ModulItem, ActionItem, ACTIONS

        tablename = modul + 's'
        label = modul.capitalize()
        label_plural = label + "s"
        clazzpath = ".".join([package, 'model', modul, label])
        values = {
            'modul': modul,
            'clazzpath': clazzpath,
            'label': label,
            'label_plural': label_plural,
            'modul': modul,
            'table': tablename,
            'id': id,
            'clazz': clazz,
            'mixins': mixinclasses
        }
        template = template_lookup.get_template("model.mako")
        generated = template.render(**values)
        outfile = open(target_file, 'w+')
        outfile.write(generated)
        outfile.close()
        # Import the new model file. This is needed to be able to
        # generate the migration script properly.
        dynamic_import(clazzpath)
        print 'Ok.'
    except Exception:
        print 'Failed.'


def del_form_file(package, modul):
    filename = modul + "s"

    target_file = os.path.join(get_app_location(package),