Exemple #1
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config`` object"""
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(
        root=root,
        controllers=os.path.join(root, "controllers"),
        static_files=os.path.join(root, "public"),
        templates=[os.path.join(root, "templates")],
    )

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package="ocsmanager", paths=paths)

    config["routes.map"] = make_map(config)
    config["pylons.app_globals"] = app_globals.Globals(config)
    config["pylons.h"] = ocsmanager.lib.helpers

    # Setup cache object as early as possible
    import pylons

    pylons.cache._push_object(config["pylons.app_globals"].cache)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config["pylons.app_globals"].mako_lookup = TemplateLookup(
        directories=paths["templates"],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf["cache_dir"], "templates"),
        input_encoding="utf-8",
        default_filters=["escape"],
        imports=["from webhelpers.html import escape"],
    )

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    ocsconfig = OCSConfig.OCSConfig(global_conf["__file__"])
    config["ocsmanager"] = ocsconfig.load()

    config["samba"] = _load_samba_environment()
    config["ocdb"] = get_openchangedb(config["samba"]["samdb_ldb"].lp)

    mapistore.set_mapping_path(config["ocsmanager"]["main"]["mapistore_data"])
    mstore = mapistore.MAPIStore(config["ocsmanager"]["main"]["mapistore_root"])
    config["mapistore"] = mstore
    config["management"] = mstore.management()
    if config["ocsmanager"]["main"]["debug"] == "yes":
        config["management"].verbose = True

    return config
Exemple #2
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()
    
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='ocsmanager', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = ocsmanager.lib.helpers
    
    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)
    

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    ocsconfig = OCSConfig.OCSConfig(global_conf['__file__'])
    config['ocsmanager'] = ocsconfig.load()

    config['samba'] = _load_samba_environment()
    config['oc_ldb'] = _load_ocdb()

    mapistore.set_mapping_path(config['ocsmanager']['main']['mapistore_data'])
    mstore = mapistore.MAPIStore(config['ocsmanager']['main']['mapistore_root'])
    config['mapistore'] = mstore
    config['management'] = mstore.management()
    if config['ocsmanager']['main']['debug'] == "yes":
        config['management'].verbose = True;
    
    return config
Exemple #3
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config`` object"""
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='ocsmanager', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = ocsmanager.lib.helpers

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8',
        default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    ocsconfig = OCSConfig.OCSConfig(global_conf['__file__'])
    config['ocsmanager'] = ocsconfig.load()

    config['samba'] = _load_samba_environment()
    config['ocdb'] = get_openchangedb(config['samba']['samdb_ldb'].lp)

    mapistore.set_mapping_path(config['ocsmanager']['main']['mapistore_data'])
    mstore = mapistore.MAPIStore(
        config['ocsmanager']['main']['mapistore_root'])
    config['mapistore'] = mstore
    config['management'] = mstore.management()
    if config['ocsmanager']['main']['debug'] == "yes":
        config['management'].verbose = True

    return config
#
# Do not forget to run memcached with the user account running the
# script.
#

import os
import sys
import time

sys.path.append("python")

import openchange.mapistore as mapistore

dirname = "/usr/local/samba/private/mapistore"
if not os.path.exists(dirname):
    os.mkdir("/usr/local/samba/private/mapistore")

mapistore.set_mapping_path(dirname)
MAPIStore = mapistore.mapistore(syspath="/usr/local/samba/private")
mgmt = MAPIStore.management()
#while 1:
#    time.sleep(5)
#    d = mgmt.registered_users("SOGo", "Administrator")
#    print d
print "Is SOGo backend registered: %s" % mgmt.registered_backend("SOGo")
print "Is NonExistent backend registered: %s" % mgmt.registered_backend("NonExistent")
print "Registered message: %s" % mgmt.registered_message("SOGo", "Administrator", "Administrator", "inbox", "61")
print "Registered message: %s" % mgmt.registered_message("SOGo", "Administrator", "Administrator", "inbox", "74")

mgmt.existing_users("SOGo", "Administrator", "inbox")
# script.
#

import os
import sys
import time

sys.path.append("python")

import openchange.mapistore as mapistore

dirname = "/usr/local/samba/private/mapistore"
if not os.path.exists(dirname):
    os.mkdir("/usr/local/samba/private/mapistore")

mapistore.set_mapping_path(dirname)
MAPIStore = mapistore.mapistore(syspath="/usr/local/samba/private")
mgmt = MAPIStore.management()
#while 1:
#    time.sleep(5)
#    d = mgmt.registered_users("SOGo", "Administrator")
#    print d
print "Is SOGo backend registered: %s" % mgmt.registered_backend("SOGo")
print "Is NonExistent backend registered: %s" % mgmt.registered_backend(
    "NonExistent")
print "Registered message: %s" % mgmt.registered_message(
    "SOGo", "Administrator", "Administrator", "inbox", "61")
print "Registered message: %s" % mgmt.registered_message(
    "SOGo", "Administrator", "Administrator", "inbox", "74")

mgmt.existing_users("SOGo", "Administrator", "inbox")
Exemple #6
0
#!/usr/bin/python

import sys

sys.path.append("python")

import os
import openchange
import openchange.mapistore as mapistore
from openchange import mapi

dirname = "/tmp/mapistore"
if not os.path.exists(dirname):
    os.mkdir("/tmp/mapistore")

mapistore.set_mapping_path("/tmp/mapistore")
MAPIStore = mapistore.mapistore()
ctx_id = MAPIStore.add_context("sogo://*****:*****@mail/")

SPropParent = mapi.SPropValue()
SPropParent.add(mapi.PR_FID, 0x0000000000160001)
SPropParent.add(mapi.PR_DISPLAY_NAME, "parent")
SPropParent.add(mapi.PR_COMMENT, "test parent")
SPropParent.add(mapi.PR_FOLDER_TYPE, 1)
MAPIStore.setprops(ctx_id, 0x0000000000160001, mapistore.MAPISTORE_FOLDER,
                   SPropParent)

SPropValue = mapi.SPropValue()
SPropValue.add(mapi.PR_PARENT_FID, 0x0000000000010001)
SPropValue.add(mapi.PR_DISPLAY_NAME, "test")
SPropValue.add(mapi.PR_COMMENT, "test folder")
Exemple #7
0
#!/usr/bin/python

import sys

sys.path.append("python")

import os
import openchange
import openchange.mapistore as mapistore
from openchange import mapi

dirname = "/tmp/mapistore"
if not os.path.exists(dirname):
    os.mkdir("/tmp/mapistore")

mapistore.set_mapping_path("/tmp/mapistore")
MAPIStore = mapistore.mapistore()
ctx_id = MAPIStore.add_context("sogo://*****:*****@mail/")

SPropParent = mapi.SPropValue()
SPropParent.add(mapi.PR_FID, 0x0000000000160001)
SPropParent.add(mapi.PR_DISPLAY_NAME, "parent")
SPropParent.add(mapi.PR_COMMENT, "test parent")
SPropParent.add(mapi.PR_FOLDER_TYPE, 1)
MAPIStore.setprops(ctx_id, 0x0000000000160001, mapistore.MAPISTORE_FOLDER, SPropParent)

SPropValue = mapi.SPropValue()
SPropValue.add(mapi.PR_PARENT_FID, 0x0000000000010001)
SPropValue.add(mapi.PR_DISPLAY_NAME, "test")
SPropValue.add(mapi.PR_COMMENT, "test folder")
SPropValue.add(mapi.PR_FOLDER_TYPE, 1)