Beispiel #1
0
def edit_display_name(source_string, translation, language=get_settings().get('default_language', _default_language)):
    if language != get_settings().get('base_language', _default_language) and get_settings().get('i18n_support_enabled', False):
        db_result = getattr(_t, language).get(source_string=source_string)
        if db_result:
            db_result.translation = translation
            db_result.save()
        else:
            getattr(_t, language).create(source_string=source_string, translation=translation)
    def view_path(view, dc_obj):
        """
        Generator of paths in which to look for the template

        :param view: name of the view
        :param dc_obj: DynamicContent instance
        :return: generator of paths
        """
        view = view if view.endswith('.html') else view + '.html'
        if view.startswith('/'):
            yield view[1:]
        else:
            if 'template_directory' in dc_obj.config:
                yield dc_obj.config['template_directory'] + '/' + view

            yield get_settings().get('project_dir', '.') + '/templates/' + view
            yield get_settings()['dc_basedir'] + '/templates/' + view
Beispiel #3
0
 def __getattr__(self, item):
     if item in get_settings().get('supported_languages', (_default_language, )):
         table = _get_table(item)
         table.create_table(fail_silently=True)
         setattr(self, item, table)
         return table
     else:
         raise AttributeError
Beispiel #4
0
from framework.includes import get_settings
from . import users, model, client, session, decorator , middleware


if get_settings().get('use_login_page', False):
    from . import login

__author__ = 'Justus Adam'


START_REGION = 'sidebar_left'

START_THEME = 'default_theme'


added_default_settings = {
    'sess_token_length': 16,
    'sess_length': -1
}
Beispiel #5
0
def translate(settings, source_string, language=get_settings().get('default_language',_default_language)):
    if settings.get('i18n_support_enabled', False) and language != settings.get('base_language', _default_language):
        db_result = getattr(_t, language).get(source_string=source_string)
        return db_result.translation if db_result else source_string
    else:
        return source_string
Beispiel #6
0
    return Lang


class T:
    def __getattr__(self, item):
        if item in get_settings().get('supported_languages', (_default_language, )):
            table = _get_table(item)
            table.create_table(fail_silently=True)
            setattr(self, item, table)
            return table
        else:
            raise AttributeError


_t = T() if get_settings().get('i18n_support_enabled', False) is True else None

del T


@component.inject(SettingsDict)
def translate(settings, source_string, language=get_settings().get('default_language',_default_language)):
    if settings.get('i18n_support_enabled', False) and language != settings.get('base_language', _default_language):
        db_result = getattr(_t, language).get(source_string=source_string)
        return db_result.translation if db_result else source_string
    else:
        return source_string


def edit_display_name(source_string, translation, language=get_settings().get('default_language', _default_language)):
    if language != get_settings().get('base_language', _default_language) and get_settings().get('i18n_support_enabled', False):
Beispiel #7
0
            args = []
            kwargs = {}
            for targ, val in zip(typeargs, values):
                if targ == '**':
                    args.append(request.path)
                elif isinstance(targ, TypeArg):
                    kwargs[targ.name] = val
                elif isinstance(targ, type):
                    args.append(val)
                else:
                    raise TypeError('Expected Type {} or {} got {}'.format(
                        type, TypeArg, type(targ))
                        )

            return tuple(args), kwargs

        if handler.typeargs:
            args, kwargs = process_args(handler.typeargs, typeargs)

            return handler, args, kwargs

        return handler, (), {}


component.Component('PathMap')(
    {
        structures.PathMaps.MULTI_TABLE: MultiTablePathMap,
        structures.PathMaps.TREE: TreePathMap
    }[get_settings()['pathmap_type']]
)