def render(self):
     ret = {'imageid': ''}
     medienart = self.request.get('medienart')
     artikelnummer = self.request.get('artikelnummer')
     if artikelnummer and medienart:
         ret['imageid'] = getPlaceholder(medienart, artikelnummer)
         print getPlaceholder(medienart, artikelnummer)
     payload = jsonlib2.write(ret)
     return payload
Example #2
0
 def render(self):
     registry = getUtility(IRegistry)
     wartung = registry[
         'bgetem.medienshop.settings.IMedienportalSettings.wartung']
     data = {'wartung': False}
     if wartung:
         data = {'wartung': True}
     payload = jsonlib2.write(data)
     return payload
Example #3
0
    def render(self):
        alsoProvides(self.request, IDisableCSRFProtection)
        ret = {u'wartung': u'es ist ein Fehler aufgetreten'}
        if not ploneapi.user.is_anonymous():
            user = ploneapi.user.get_current()
            if user:
                roles = ploneapi.user.get_roles(user=user)
                if not 'Manager' in roles:
                    self.request.response.status = 403
                    return u"403:Forbidden"
        else:
            self.request.response.status = 401
            return u"401:Unauthorized"

        registry = getUtility(IRegistry)
        registry[
            'bgetem.medienshop.settings.IMedienportalSettings.wartung'] = False
        ret = {'wartung': False}
        payload = jsonlib2.write(ret)
        return payload
        return "ERROR: Cannot read YAML\n"

    try:
        curr = config[env]
    except KeyError:
        return "ERROR: Invalid environment\n"

    try:
        data = parse_yaml_env(curr, confpath)
    except NameError:
        try:
            data = parse_yaml_env(config['all'], confpath)
        except NameError:
            return "ERROR: Config variable not found\n"

    return jsonlib2.write(data) + "\n"


def parse_yaml_env(curr, confpath):
    """Walk through YAML data and pull out vars for specific env"""

    for elem in confpath:
        try:
            # see if we can find this element
            curr = curr[elem]
        except (TypeError, KeyError):
            # if not, lets try to take the rest of the elements, join them with _ and keep trying
            for elem in confpath:
                index = confpath.index(elem) + 1
                elem = elem + '_' + '_'.join(confpath[index:])
                try: