Example #1
0
def check_context():
    webcontexts = athana.contexts
    if (not filter(lambda x: x.name == '/wfs_addpic2pdf', webcontexts)) and athana.GLOBAL_ROOT_DIR != "no-root-dir-set":
        print 'going to add context wfs_addpic2pdf'
        webcontext = athana.addContext("/wfs_addpic2pdf", ".")
        webcontext_file = webcontext.addFile("workflow/addpic2pdf.py")
        webcontext_file.addHandler("handle_request").addPattern("/.*")
Example #2
0
def check_context():
    webcontexts = athana.contexts
    if (not filter(lambda x: x.name == '/wfs_addpic2pdf', webcontexts)) and athana.GLOBAL_ROOT_DIR != "no-root-dir-set":
        print 'going to add context wfs_addpic2pdf'
        webcontext = athana.addContext("/wfs_addpic2pdf", ".")
        webcontext_file = webcontext.addFile("workflow/addpic2pdf.py")
        webcontext_file.addHandler("handle_request").addPattern("/.*")
Example #3
0
    def manageService(servicename, servicedir, servicedata):
        if not os.path.exists(servicedir + "services/" + servicename +
                              "/__init__.py"):
            return

        if config.get('services.' + servicename + '.activate',
                      "").lower() == "false":
            return
        if servicename + '.basecontext' in config.getsubset("services").keys():
            basecontext = config.getsubset("services")[servicename +
                                                       '.basecontext']
        else:
            basecontext = config.get("services.contextprefix",
                                     "services") + '/' + servicename
        basecontext = ('/' + basecontext).replace('//', '/').replace('//', '/')
        context = athana.addContext(basecontext, ".")
        file = context.addFile(servicedir + "services/" + servicename)

        if hasattr(file.m, "request_handler"):
            file.addHandler("request_handler").addPattern("/.*")

            if not os.path.exists(servicedata):
                try:
                    os.makedirs(servicedata)
                    os.makedirs(os.path.join(servicedata, "cache"))
                except OSError:
                    return
Example #4
0
    def manageService(servicename, servicedir, servicedata):
        if not os.path.exists(servicedir + "services/" + servicename + "/__init__.py"):
            return

        if config.get('services.' + servicename + '.activate', "").lower() == "false":
            return
        if servicename + '.basecontext' in config.getsubset("services").keys():
            basecontext = config.getsubset("services")[servicename + '.basecontext']
        else:
            basecontext = config.get("services.contextprefix", "services") + '/' + servicename
        basecontext = ('/' + basecontext).replace('//', '/').replace('//', '/')
        context = athana.addContext(basecontext, ".")
        file = context.addFile(servicedir + "services/" + servicename)

        if hasattr(file.m, "request_handler"):
            file.addHandler("request_handler").addPattern("/.*")

            if not os.path.exists(servicedata):
                try:
                    os.makedirs(servicedata)
                    os.makedirs(os.path.join(servicedata, "cache"))
                except OSError:
                    return
Example #5
0
def initContexts():
    athana.setBase(".")
    athana.setTempDir(config.get("paths.tempdir", "/tmp/"))
    from core.config import resolve_filename
    from core.translation import translate
    from core.ftp import collection_ftpserver
    tal.set_base(".")
    tal.add_macro_resolver(resolve_filename)
    tal.add_translator(translate)

    context = athana.addContext("/", ".")
    # === public area ===
    file = context.addFile("web/frontend/streams.py")
    file.addHandler("send_image").addPattern("/images/.*")
    file.addHandler("send_thumbnail").addPattern("/thumbs/.*")
    file.addHandler("send_thumbnail2").addPattern("/thumb2/.*")
    file.addHandler("send_doc").addPattern("/doc/.*")
    file.addHandler("send_file").addPattern("/file/.*")
    file.addHandler("send_file_as_download").addPattern("/download/.*")
    file.addHandler("send_attachment").addPattern("/attachment/.*")
    file.addHandler("send_attfile").addPattern("/attfile/.*")
    file.addHandler("get_archived").addPattern("/archive/.*")
    file.addHandler("get_root").addPattern(
        "/[a-z,0-9,-]*\.[a-z]*"
    )  # root directory added /web/root (only files with extensions)

    file = context.addFile("web/frontend/zoom.py")
    file.addHandler("send_imageproperties_xml").addPattern(
        "/tile/[0-9]*/ImageProperties.xml")
    file.addHandler("send_tile").addPattern("/tile/[0-9]*/[^I].*")

    #file = context.addFile("web/frontend/flippage.py")
    # file.addHandler("send_bookconfig_xml").addPattern("/[0-9]*/bookconfig.xml")
    # file.addHandler("send_page").addPattern("/[0-9]*/page/[0-9]*\.jpg")

    # === workflow ===
    #file = context.addFile("web/publish/main.py")
    # file.addHandler("publish").addPattern("/publish/.*")

    main_file = file = context.addFile("web/frontend/main.py")
    handler = file.addHandler("display")
    handler.addPattern("/")
    handler.addPattern("/node")
    file.addHandler("display_noframe").addPattern("/mask")
    file.addHandler("xmlsearch").addPattern("/xmlsearch")
    file.addHandler("jssearch").addPattern("/jssearch")
    file.addHandler("show_parent_node").addPattern("/pnode")
    file.addHandler("publish").addPattern("/publish/.*")
    file = context.addFile("web/frontend/popups.py")
    file.addHandler("popup_metatype").addPattern("/metatype/.*")
    file.addHandler("popup_fullsize").addPattern("/fullsize")
    file.addHandler("popup_thumbbig").addPattern("/thumbbig")
    # file.addHandler("show_index").addPattern("/popup_index")
    file.addHandler("show_help").addPattern("/popup_help")
    file.addHandler("show_attachmentbrowser").addPattern("/attachmentbrowser")
    file.addHandler("show_printview").addPattern("/print/.*")

    file = context.addFile("web/frontend/shoppingbag.py")
    file.addHandler("shoppingbag_action").addPattern("/shoppingbag")

    file = context.addFile("web/frontend/login.py")
    file.addHandler("login").addPattern("/login")
    file.addHandler("logout").addPattern("/logout")
    file.addHandler("pwdforgotten").addPattern("/pwdforgotten")
    file.addHandler("pwdchange").addPattern("/pwdchange")

    file = context.addFile("web/frontend/userdata.py")
    file.addHandler("show_user_data").addPattern("/user")

    file = context.addFile("workflow/diagram/__init__.py")
    file.addHandler("send_workflow_diagram").addPattern("/workflowimage")

    # === admin area ===
    context = athana.addContext("/admin", ".")
    file = context.addFile("web/admin/main.py")
    file.addHandler("show_node").addPattern("/(?!export/).*")
    file.addHandler("export").addPattern("/export/.*")

    # === edit area ===
    context = athana.addContext("/edit", ".")
    file = context.addFile("web/edit/edit.py")
    handler = file.addHandler("frameset")
    handler.addPattern("/")
    handler.addPattern("/edit")
    #file.addHandler("showtree").addPattern("/edit_tree")
    file.addHandler("edit_tree").addPattern("/treedata")
    file.addHandler("error").addPattern("/edit_error")
    #file.addHandler("buttons").addPattern("/edit_buttons")
    file.addHandler("content").addPattern("/edit_content")
    file.addHandler("content").addPattern("/edit_content/.*")
    file.addHandler("action").addPattern("/edit_action")

    # === ajax tree ===
    context = athana.addContext("/ftree", ".")
    handler.addPattern("/ftree")
    file = context.addFile("web/ftree/ftree.py")
    file.addHandler("ftree").addPattern("/.*")

    # === help area ===
    context = athana.addContext("/help", '.')
    file = context.addFile("core/help.py")
    file.addHandler("getHelp").addPattern("/(?!img/).*")

    # === services handling ===
    loadServices()

    # === OAI ===
    context = athana.addContext("/oai/", ".")
    file = context.addFile("export/oai.py")
    file.addHandler("oaiRequest").addPattern(".*")

    # === Export ===
    context = athana.addContext("/export", ".")
    file = context.addFile("export/export.py")
    file.addHandler("export").addPattern("/.*")

    # === static files ===
    athana.addFileStore("/ckeditor/", "lib/CKeditor/files.zip")
    athana.addFileStore("/css/", "web/css/")
    athana.addFileStore("/xml/", "web/xml/")
    athana.addFileStore("/img/",
                        ["web/img/", "web/admin/img/", "web/edit/img/"])
    athana.addFileStore("/js/", ["web/js/", "js", "lib/CKeditor/js/"])

    # === last: path aliasing for collections ===
    handler = main_file.addHandler("display_alias")
    handler.addPattern("/[-.~_/a-zA-Z0-9]+$")

    # 404
    handler = main_file.addHandler("display_404")
    handler.addPattern("/(.)+$")

    # === theme handling ===
    loadThemes()

    # === frontend modules handling ===
    try:
        context = athana.addContext("/modules", ".")
        file = context.addFile("web/frontend/modules/modules.py")
        file.addHandler("getContent").addPattern("/.*")
    except IOError:
        print "no frontend modules found"

    #athana.addContext("/flush", ".").addFile("core/webconfig.py").addHandler("flush").addPattern("/py")

    # === check for ftp usage ===
    if config.get("ftp.activate", "") == "true":
        # dummy handler for users
        athana.addFTPHandler(
            collection_ftpserver(None,
                                 port=int(config.get("ftp.port", 21)),
                                 debug=config.get("host.type", "testing")))

        for collection in tree.getRoot("collections").getChildren():
            if collection.get("ftp.user") and collection.get("ftp.passwd"):
                athana.addFTPHandler(
                    collection_ftpserver(collection,
                                         port=int(config.get("ftp.port", 21)),
                                         debug=config.get(
                                             "host.type", "testing")))
Example #6
0
def initContexts():
    athana.setBase(".")
    athana.setTempDir(config.get("paths.tempdir", "/tmp/"))
    from core.config import resolve_filename
    from core.translation import translate
    from core.ftp import collection_ftpserver
    tal.set_base(".")
    tal.add_macro_resolver(resolve_filename)
    tal.add_translator(translate)

    context = athana.addContext("/", ".")
    # === public area ===
    file = context.addFile("web/frontend/streams.py")
    file.addHandler("send_image").addPattern("/images/.*")
    file.addHandler("send_thumbnail").addPattern("/thumbs/.*")
    file.addHandler("send_thumbnail2").addPattern("/thumb2/.*")
    file.addHandler("send_doc").addPattern("/doc/.*")
    file.addHandler("send_file").addPattern("/file/.*")
    file.addHandler("send_file_as_download").addPattern("/download/.*")
    file.addHandler("send_attachment").addPattern("/attachment/.*")
    file.addHandler("send_attfile").addPattern("/attfile/.*")
    file.addHandler("get_archived").addPattern("/archive/.*")
    file.addHandler("get_root").addPattern("/[a-z,0-9,-]*\.[a-z]*")  # root directory added /web/root (only files with extensions)

    file = context.addFile("web/frontend/zoom.py")
    file.addHandler("send_imageproperties_xml").addPattern("/tile/[0-9]*/ImageProperties.xml")
    file.addHandler("send_tile").addPattern("/tile/[0-9]*/[^I].*")

    #file = context.addFile("web/frontend/flippage.py")
    # file.addHandler("send_bookconfig_xml").addPattern("/[0-9]*/bookconfig.xml")
    # file.addHandler("send_page").addPattern("/[0-9]*/page/[0-9]*\.jpg")

    # === workflow ===
    #file = context.addFile("web/publish/main.py")
    # file.addHandler("publish").addPattern("/publish/.*")

    main_file = file = context.addFile("web/frontend/main.py")
    handler = file.addHandler("display")
    handler.addPattern("/")
    handler.addPattern("/node")
    file.addHandler("display_noframe").addPattern("/mask")
    file.addHandler("xmlsearch").addPattern("/xmlsearch")
    file.addHandler("jssearch").addPattern("/jssearch")
    file.addHandler("show_parent_node").addPattern("/pnode")
    file.addHandler("publish").addPattern("/publish/.*")
    file = context.addFile("web/frontend/popups.py")
    file.addHandler("popup_metatype").addPattern("/metatype/.*")
    file.addHandler("popup_fullsize").addPattern("/fullsize")
    file.addHandler("popup_thumbbig").addPattern("/thumbbig")
    # file.addHandler("show_index").addPattern("/popup_index")
    file.addHandler("show_help").addPattern("/popup_help")
    file.addHandler("show_attachmentbrowser").addPattern("/attachmentbrowser")
    file.addHandler("show_printview").addPattern("/print/.*")

    file = context.addFile("web/frontend/shoppingbag.py")
    file.addHandler("shoppingbag_action").addPattern("/shoppingbag")

    file = context.addFile("web/frontend/login.py")
    file.addHandler("login").addPattern("/login")
    file.addHandler("logout").addPattern("/logout")
    file.addHandler("pwdforgotten").addPattern("/pwdforgotten")
    file.addHandler("pwdchange").addPattern("/pwdchange")

    file = context.addFile("web/frontend/userdata.py")
    file.addHandler("show_user_data").addPattern("/user")

    file = context.addFile("workflow/diagram/__init__.py")
    file.addHandler("send_workflow_diagram").addPattern("/workflowimage")

    # === admin area ===
    context = athana.addContext("/admin", ".")
    file = context.addFile("web/admin/main.py")
    file.addHandler("show_node").addPattern("/(?!export/).*")
    file.addHandler("export").addPattern("/export/.*")

    # === edit area ===
    context = athana.addContext("/edit", ".")
    file = context.addFile("web/edit/edit.py")
    handler = file.addHandler("frameset")
    handler.addPattern("/")
    handler.addPattern("/edit")
    #file.addHandler("showtree").addPattern("/edit_tree")
    file.addHandler("edit_tree").addPattern("/treedata")
    file.addHandler("error").addPattern("/edit_error")
    #file.addHandler("buttons").addPattern("/edit_buttons")
    file.addHandler("content").addPattern("/edit_content")
    file.addHandler("content").addPattern("/edit_content/.*")
    file.addHandler("action").addPattern("/edit_action")

    # === ajax tree ===
    context = athana.addContext("/ftree", ".")
    handler.addPattern("/ftree")
    file = context.addFile("web/ftree/ftree.py")
    file.addHandler("ftree").addPattern("/.*")

    # === help area ===
    context = athana.addContext("/help", '.')
    file = context.addFile("core/help.py")
    file.addHandler("getHelp").addPattern("/(?!img/).*")

    # === services handling ===
    loadServices()

    # === OAI ===
    context = athana.addContext("/oai/", ".")
    file = context.addFile("export/oai.py")
    file.addHandler("oaiRequest").addPattern(".*")

    # === Export ===
    context = athana.addContext("/export", ".")
    file = context.addFile("export/export.py")
    file.addHandler("export").addPattern("/.*")

    # === static files ===
    athana.addFileStore("/ckeditor/", "lib/CKeditor/files.zip")
    athana.addFileStore("/css/", "web/css/")
    athana.addFileStore("/xml/", "web/xml/")
    athana.addFileStore("/img/", ["web/img/", "web/admin/img/", "web/edit/img/"])
    athana.addFileStore("/js/", ["web/js/", "js", "lib/CKeditor/js/"])

    # === last: path aliasing for collections ===
    handler = main_file.addHandler("display_alias")
    handler.addPattern("/[-.~_/a-zA-Z0-9]+$")

    # 404
    handler = main_file.addHandler("display_404")
    handler.addPattern("/(.)+$")

    # === theme handling ===
    loadThemes()

    # === frontend modules handling ===
    try:
        context = athana.addContext("/modules", ".")
        file = context.addFile("web/frontend/modules/modules.py")
        file.addHandler("getContent").addPattern("/.*")
    except IOError:
        print "no frontend modules found"

    #athana.addContext("/flush", ".").addFile("core/webconfig.py").addHandler("flush").addPattern("/py")

    # === check for ftp usage ===
    if config.get("ftp.activate", "") == "true":
        # dummy handler for users
        athana.addFTPHandler(collection_ftpserver(None, port=int(config.get("ftp.port", 21)), debug=config.get("host.type", "testing")))

        for collection in tree.getRoot("collections").getChildren():
            if collection.get("ftp.user") and collection.get("ftp.passwd"):
                athana.addFTPHandler(collection_ftpserver(
                    collection, port=int(config.get("ftp.port", 21)), debug=config.get("host.type", "testing")))
Example #7
0
def initContexts():
    athana.setBase(config.basedir)
    athana.setTempDir(config.get("paths.tempdir", "/tmp/"))
    from core.config import resolve_filename
    from core.translation import translate, set_language
    tal.set_base(config.basedir)
    tal.add_macro_resolver(resolve_filename)
    tal.add_translator(translate)
    add_template_globals()

    @athana.request_started
    def set_lang(req, *args):
        set_language(req)

    # XXX: init our temporary child count cahche
    from web.frontend import frame
    frame.init_child_count_cache()

    context = athana.addContext("/", ".")

    workflows_enabled = config.getboolean("workflows.activate", True)
    admin_enabled = config.getboolean("admin.activate", True)
    edit_enabled = config.getboolean("edit.activate", True)
    oai_enabled = config.getboolean("oai.activate", False)

    # === public area ===
    file = context.addFile("web/frontend/filehandlers.py")
    file.addHandler("send_thumbnail").addPattern("/thumbs/.*")
    file.addHandler("send_thumbnail2").addPattern("/thumb2/.*")
    file.addHandler("send_doc").addPattern("/doc/.*")
    file.addHandler("send_image").addPattern("/image/.*")
    file.addHandler("redirect_images").addPattern("/images/.*")
    handler = file.addHandler("send_file")
    handler.addPattern("/file/.*")
    handler.addPattern("/download/.*")
    file.addHandler("send_attachment").addPattern("/attachment/.*")
    file.addHandler("send_attfile").addPattern("/attfile/.*")
    file.addHandler("fetch_archived").addPattern("/archive/.*")
    file.addHandler("send_from_webroot").addPattern("/[a-z,0-9,-]*\.[a-z]*")  # root directory added /web/root (only files with extensions)

    file = context.addFile("web/frontend/zoom.py")
    file.addHandler("send_imageproperties_xml").addPattern("/tile/[0-9]*/ImageProperties.xml")
    file.addHandler("send_tile").addPattern("/tile/[0-9]*/[^I].*")

    main_file = file = context.addFile("web/frontend/main.py")
    handler = file.addHandler("display")
    handler.addPattern("/")
    handler.addPattern("/node")
    handler = file.addHandler("display_newstyle")
    handler.addPattern("/nodes/\d+")
    # /\d+ could also be a node, the handler must check this
    handler.addPattern("/\d+")

    if workflows_enabled:
        file.addHandler("workflow").addPattern("/mask")

    file.addHandler("show_parent_node").addPattern("/pnode")
    file.addHandler("publish").addPattern("/publish/.*")
    file = context.addFile("web/frontend/popups.py")
    file.addHandler("popup_metatype").addPattern("/metatype/.*")
    file.addHandler("popup_fullsize").addPattern("/fullsize")
    file.addHandler("popup_thumbbig").addPattern("/thumbbig")
    # file.addHandler("show_index").addPattern("/popup_index")
    file.addHandler("show_help").addPattern("/popup_help")
    file.addHandler("show_attachmentbrowser").addPattern("/attachmentbrowser")
    
    if config.getboolean("config.enable_printing"):
        file.addHandler("show_printview").addPattern("/print/\d+\.pdf")
        file.addHandler("redirect_old_printview").addPattern("/print/.*")

    file = context.addFile("web/frontend/login.py")
    file.addHandler("login").addPattern("/login")
    file.addHandler("logout").addPattern("/logout")
    file.addHandler("pwdforgotten").addPattern("/pwdforgotten")
    file.addHandler("pwdchange").addPattern("/pwdchange")

    if workflows_enabled:
        file = context.addFile("workflow/diagram/__init__.py")
        file.addHandler("send_workflow_diagram").addPattern("/workflowimage")

    if admin_enabled:
        context = athana.addContext("/admin", ".")
        file = context.addFile("web/handlers/become.py")
        file.addHandler("become_user").addPattern("/_become/.*")
        file = context.addFile("web/admin/main.py")
        file.addHandler("show_node").addPattern("/(?!export/).*")
        file.addHandler("export").addPattern("/export/.*")

    if edit_enabled:
        # === edit area ===
        context = athana.addContext("/edit", ".")
        file = context.addFile("web/edit/edit.py")
        handler = file.addHandler("frameset")
        handler.addPattern("/")
        handler.addPattern("/edit")
        file.addHandler("edit_print").addPattern("/print/\d+_.+\.pdf")
        # file.addHandler("showtree").addPattern("/edit_tree")
        file.addHandler("edit_tree").addPattern("/treedata")
        file.addHandler("error").addPattern("/edit_error")
        # file.addHandler("buttons").addPattern("/edit_buttons")
        file.addHandler("content").addPattern("/edit_content")
        file.addHandler("content").addPattern("/edit_content/.*")
        file.addHandler("action").addPattern("/edit_action")

        # === ajax tree ===
        context = athana.addContext("/ftree", ".")
        handler.addPattern("/ftree")
        file = context.addFile("web/ftree/ftree.py")
        file.addHandler("ftree").addPattern("/.*")

    # === services handling ===
    loadServices()

    # === OAI ===
    if oai_enabled:
        context = athana.addContext("/oai/", ".")
        file = context.addFile("export/oai.py")
        file.addHandler("oaiRequest").addPattern(".*")

    # === Export ===
    context = athana.addContext("/export", ".")
    file = context.addFile("web/frontend/export.py")
    file.addHandler("export").addPattern("/.*")

    # === static files ===
    athana.addFileStore("/ckeditor/", "lib/CKeditor/files.zip")
    athana.addFileStore("/css/", "web/css/")
    athana.addFileStore("/xml/", "web/xml/")
    athana.addFileStore("/img/", ["web/img/", "web/admin/img/", "web/edit/img/"])
    athana.addFileStore("/js/", ["web/js/", "js", "lib/CKeditor/js/"])

    # === last: path aliasing for collections ===
    handler = main_file.addHandler("display_alias")
    handler.addPattern("/([_a-zA-Z][_/a-zA-Z0-9]+)$")

    # 404
    handler = main_file.addHandler("display_404")
    handler.addPattern("/(.)+$")

    init_theme()


    if admin_enabled:
        import web.newadmin
        athana.add_wsgi_context("/f/", web.newadmin.app)

    # testing global exception handler
    context = athana.addContext("/_test", ".")
    file = context.addFile("web/handlers/handlertest.py")
    file.addHandler("error").addPattern("/error")
    file.addHandler("error_variable_msg").addPattern("/error_variable_msg")
    file.addHandler("db_error").addPattern("/db_error")
Example #8
0
def initContexts():
    athana.setBase(config.basedir)
    athana.setTempDir(config.get("paths.tempdir", "/tmp/"))
    from core.config import resolve_filename
    from core.translation import translate, set_language
    tal.set_base(config.basedir)
    tal.add_macro_resolver(resolve_filename)
    tal.add_translator(translate)
    add_template_globals()

    @athana.request_started
    def set_lang(req, *args):
        set_language(req)

    # XXX: init our temporary child count cahche
    from web.frontend import frame
    frame.init_child_count_cache()

    context = athana.addContext("/", ".")

    workflows_enabled = config.getboolean("workflows.activate", True)
    admin_enabled = config.getboolean("admin.activate", True)
    edit_enabled = config.getboolean("edit.activate", True)
    oai_enabled = config.getboolean("oai.activate", False)

    # === public area ===
    file = context.addFile("web/frontend/filehandlers.py")
    file.addHandler("send_thumbnail").addPattern("/thumbs/.*")
    file.addHandler("send_thumbnail2").addPattern("/thumb2/.*")
    file.addHandler("send_doc").addPattern("/doc/.*")
    file.addHandler("send_image").addPattern("/image/.*")
    file.addHandler("redirect_images").addPattern("/images/.*")
    handler = file.addHandler("send_file")
    handler.addPattern("/file/.*")
    handler.addPattern("/download/.*")
    file.addHandler("send_attachment").addPattern("/attachment/.*")
    file.addHandler("send_attfile").addPattern("/attfile/.*")
    file.addHandler("fetch_archived").addPattern("/archive/.*")
    file.addHandler("send_from_webroot").addPattern("/[a-z,0-9,-]*\.[a-z]*")  # root directory added /web/root (only files with extensions)

    file = context.addFile("web/frontend/zoom.py")
    file.addHandler("send_imageproperties_xml").addPattern("/tile/[0-9]*/ImageProperties.xml")
    file.addHandler("send_tile").addPattern("/tile/[0-9]*/[^I].*")

    main_file = file = context.addFile("web/frontend/main.py")
    handler = file.addHandler("display")
    handler.addPattern("/")
    handler.addPattern("/node")
    handler = file.addHandler("display_newstyle")
    handler.addPattern("/nodes/\d+")
    # /\d+ could also be a node, the handler must check this
    handler.addPattern("/\d+")

    if workflows_enabled:
        file.addHandler("workflow").addPattern("/mask")

    file.addHandler("show_parent_node").addPattern("/pnode")
    file.addHandler("publish").addPattern("/publish/.*")
    file = context.addFile("web/frontend/popups.py")
    file.addHandler("popup_metatype").addPattern("/metatype/.*")
    file.addHandler("popup_fullsize").addPattern("/fullsize")
    file.addHandler("popup_thumbbig").addPattern("/thumbbig")
    # file.addHandler("show_index").addPattern("/popup_index")
    file.addHandler("show_help").addPattern("/popup_help")
    file.addHandler("show_attachmentbrowser").addPattern("/attachmentbrowser")
    
    if config.getboolean("config.enable_printing"):
        file.addHandler("show_printview").addPattern("/print/\d+\.pdf")
        file.addHandler("redirect_old_printview").addPattern("/print/.*")

    file = context.addFile("web/frontend/login.py")
    file.addHandler("login").addPattern("/login")
    file.addHandler("logout").addPattern("/logout")
    file.addHandler("pwdforgotten").addPattern("/pwdforgotten")
    file.addHandler("pwdchange").addPattern("/pwdchange")

    if workflows_enabled:
        file = context.addFile("workflow/diagram/__init__.py")
        file.addHandler("send_workflow_diagram").addPattern("/workflowimage")

    if admin_enabled:
        context = athana.addContext("/admin", ".")
        file = context.addFile("web/handlers/become.py")
        file.addHandler("become_user").addPattern("/_become/.*")
        file = context.addFile("web/admin/main.py")
        file.addHandler("show_node").addPattern("/(?!export/).*")
        file.addHandler("export").addPattern("/export/.*")

    if edit_enabled:
        # === edit area ===
        context = athana.addContext("/edit", ".")
        file = context.addFile("web/edit/edit.py")
        handler = file.addHandler("frameset")
        handler.addPattern("/")
        handler.addPattern("/edit")
        file.addHandler("edit_print").addPattern("/print/\d+_.+\.pdf")
        # file.addHandler("showtree").addPattern("/edit_tree")
        file.addHandler("edit_tree").addPattern("/treedata")
        file.addHandler("error").addPattern("/edit_error")
        # file.addHandler("buttons").addPattern("/edit_buttons")
        file.addHandler("content").addPattern("/edit_content")
        file.addHandler("content").addPattern("/edit_content/.*")
        file.addHandler("action").addPattern("/edit_action")

        # === ajax tree ===
        context = athana.addContext("/ftree", ".")
        handler.addPattern("/ftree")
        file = context.addFile("web/ftree/ftree.py")
        file.addHandler("ftree").addPattern("/.*")

    # === services handling ===
    loadServices()

    # === OAI ===
    if oai_enabled:
        context = athana.addContext("/oai/", ".")
        file = context.addFile("export/oai.py")
        file.addHandler("oaiRequest").addPattern(".*")

    # === Export ===
    context = athana.addContext("/export", ".")
    file = context.addFile("web/frontend/export.py")
    file.addHandler("export").addPattern("/.*")

    # === static files ===
    athana.addFileStore("/ckeditor/", "lib/CKeditor/files.zip")
    athana.addFileStore("/css/", "web/css/")
    athana.addFileStore("/xml/", "web/xml/")
    athana.addFileStore("/img/", ["web/img/", "web/admin/img/", "web/edit/img/"])
    athana.addFileStore("/js/", ["web/js/", "js", "lib/CKeditor/js/"])

    # === last: path aliasing for collections ===
    handler = main_file.addHandler("display_alias")
    handler.addPattern("/([_a-zA-Z][_/a-zA-Z0-9]+)$")

    # 404
    handler = main_file.addHandler("display_404")
    handler.addPattern("/(.)+$")

    init_theme()


    if admin_enabled:
        import web.newadmin
        athana.add_wsgi_context("/f/", web.newadmin.app)

    # testing global exception handler
    context = athana.addContext("/_test", ".")
    file = context.addFile("web/handlers/handlertest.py")
    file.addHandler("error").addPattern("/error")
    file.addHandler("error_variable_msg").addPattern("/error_variable_msg")
    file.addHandler("db_error").addPattern("/db_error")