Exemple #1
0
    def __init__(self):

        request = current.request

        # Load s3cfg => but why do this so complicated?
        #name = "applications.%s.modules.s3cfg" % request.application
        #s3cfg = __import__(name)
        #for item in name.split(".")[1:]:
        ## Remove the dot
        #s3cfg = getattr(s3cfg, item)
        #settings = s3cfg.S3Config()

        # Can use normal import here since executed in web2py environment:
        import s3cfg
        settings = s3cfg.S3Config()

        # Pass into template
        current.deployment_settings = settings

        # Read settings
        model = "%s/models/000_config.py" % request.folder
        code = getcfs(model, model, None)
        response = current.response

        # Needed as some Templates look at this & we don't wish to crash:
        response.s3 = Storage()

        # Global variables for 000_config.py
        environment = build_environment(request, response, current.session)
        environment["settings"] = settings
        # Some (older) 000_config.py also use "deployment_settings":
        environment["deployment_settings"] = settings
        # For backwards-compatibility with older 000_config.py:
        #def template_path():
        #    # When you see this warning, you should update 000_config.py
        #    # See: http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/Templates/Migration#Changesin000_config.py
        #    print "template_path() is deprecated, please update 000_config.py"
        #    # Return just any valid path to make sure the path-check succeeds,
        #    # => modern S3Config will find the template itself
        #    return request.folder
        #environment["template_path"] = template_path
        environment["os"] = os
        environment["Storage"] = Storage

        # Execute 000_config.py
        restricted(code, environment, layer=model)

        self.db_engine = settings.get_database_type()
        (db_string, pool_size) = settings.get_database_string()

        # Get a handle to the database
        self.db = DAL(
            db_string,
            #folder="%s/databases" % request.folder,
            auto_import=True,
            # @ToDo: Set to False until we migrate
            migrate_enabled=True,
        )
Exemple #2
0
CURRENT_UPDATE_CHECK_ID = 4
update_check_needed = False
try:
    if CANARY_UPDATE_CHECK_ID != CURRENT_UPDATE_CHECK_ID:
        update_check_needed = True
except NameError:
    update_check_needed = True

# shortcut
appname = request.application

if update_check_needed:
    # @ToDo: Load deployment_settings so that we can configure the update_check
    # - need to rework so that 000_config.py is parsed 1st
    import s3cfg
    settings = s3cfg.S3Config()
    # Run update checks
    from s3_update_check import update_check
    errors = []
    warnings = []
    messages = update_check(settings)
    errors.extend(messages.get("error_messages", []))
    warnings.extend(messages.get("warning_messages", []))

    # Catch-all check for dependency errors.
    # NB This does not satisfy the goal of calling out all the setup errors
    #    at once - it will die on the first fatal error encountered.
    try:
        import s3 as s3base
    except Exception, e:
        errors.append(e.message)
Exemple #3
0
    canary = open(
        "applications/%s/models/0000_update_check.py" % request.application,
        "w")
    portalocker.lock(canary, portalocker.LOCK_EX)
    statement = "CANARY_UPDATE_CHECK_ID = %s" % CURRENT_UPDATE_CHECK_ID
    canary.write(statement)
    canary.close()

# -----------------------------------------------------------------------------
from gluon import current
from gluon.storage import Storage
from gluon.contrib.simplejson.ordered_dict import OrderedDict

current.cache = cache

# Keep all S3 framework-level elements stored in response.s3, so as to avoid
# polluting global namespace & to make it clear which part of the framework is
# being interacted with.
# Avoid using this where a method parameter could be used:
# http://en.wikipedia.org/wiki/Anti_pattern#Programming_anti-patterns
response.s3 = Storage()
s3 = response.s3
response.s3.gis = Storage()  # Defined early for use by S3Config.

# Import S3Config
import s3cfg
deployment_settings = s3cfg.S3Config()
current.deployment_settings = deployment_settings

# END =========================================================================
Exemple #4
0
CURRENT_UPDATE_CHECK_ID = 4
update_check_needed = False
try:
    if CANARY_UPDATE_CHECK_ID != CURRENT_UPDATE_CHECK_ID:
        update_check_needed = True
except NameError:
    update_check_needed = True

# shortcut
appname = request.application

if update_check_needed:
    # @ToDo: Load deployment_settings so that we can configure the update_check
    # - need to rework so that 000_config.py is parsed 1st
    import s3cfg
    settings = s3cfg.S3Config()
    # Run update checks
    from s3_update_check import update_check
    errors = []
    warnings = []
    messages = update_check(settings)
    errors.extend(messages.get("error_messages", []))
    warnings.extend(messages.get("warning_messages", []))

    # Catch-all check for dependency errors.
    # NB This does not satisfy the goal of calling out all the setup errors
    #    at once - it will die on the first fatal error encountered.
    try:
        import s3 as s3base
    except Exception as e:
        errors.append(e.message)