Beispiel #1
0
	def set_config() :
	
		from pylons import config, app_globals
	
		new_config = {}
		for k in config.keys() :
		
			if k.startswith('facebook.') : setattr( app_globals, k[9:].upper(), config[k] )
    def project_root(self):
        """
        Return the root of the current pylons project on the filesystem.
        """

        if "exceptional.root" in config.keys():
            return config["exceptional.root"]
        else:
            return "/I/don/t/know"
Beispiel #3
0
    def project_root(self):

        """
        Return the root of the current pylons project on the filesystem.
        """

        if "exceptional.root" in config.keys():
            return config["exceptional.root"]
        else:
            return "/I/don/t/know"
Beispiel #4
0
    def setup_class(cls):
        cls._original_config = config.copy()
        for key in config.keys():
            if key.startswith('ofs'):
                del config[key]
        config['ofs.impl'] = 'pairtree'
        config['ckan.storage.bucket'] = 'ckantest'
        config['ofs.storage_dir'] = '/tmp/ckan-test-ckanext-storage'

        create_pairtree_marker( config['ofs.storage_dir'] )
        wsgiapp = make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)

        CreateTestData.create_test_user()
Beispiel #5
0
 def setup_class(cls):
     cls._original_config = config.copy()
     for key in config.keys():
         if key.startswith('ofs'):
             del config[key]
     config['ckan.storage.bucket'] = 'ckantest'
     config['ofs.impl'] = 'pairtree'
     config['ofs.storage_dir'] = '/tmp/ckan-test-ckanext-storage'
     create_pairtree_marker( config['ofs.storage_dir'] )
     wsgiapp = make_app(config['global_conf'], **config)
     cls.app = paste.fixture.TestApp(wsgiapp)
     CreateTestData.create()
     model.Session.remove()
     user = model.User.by_name('tester')
     cls.extra_environ = {'Authorization': str(user.apikey)}
Beispiel #6
0
	def check_config() :
	
		from pylons import config
		class ConfigError(Exception) : pass

		error_str = 'fbpylons requires that the following variables be set in your development.ini: %s. For details, see the Facebook API documentation.' % ( ', '.join(REQUIRED), )
		
		if not all( [config.has_key(r) for r in REQUIRED] ) : raise ConfigError(error_str)
		if not all( [config[r] for r in REQUIRED] ) : raise ConfigError(error_str)
	
		extraneous = []
		for k in config.keys() :
			if k.startswith('facebook.') and k not in REQUIRED and k not in OPTIONAL : extraneous.append(k)
	
		if len(extraneous) > 0 : raise ConfigError( extraneous )
def get_urls(text):
    user_roles = session.get('ckanext-cas-roles', [])
    _list =sorted([x for x in set( x.split('.')[2] for x in [x for x in config.keys() if text in x])])
    result = []
    for i in _list:

        try:
            sk_text = config.get(text+i+'.description_sk').decode('utf8')
        except AttributeError:
            sk_text = ""
        try:
            en_text = config.get(text+i+'.description_en').decode('utf8')
        except AttributeError:
            en_text = ""

        try:
            popis = config.get(text+i+'.title').decode('utf8')
        except AttributeError:
            popis = ""

        try:
            role = [x.strip() for x in config.get(text+i+'.privilege').split(',')]
        except AttributeError:
            role = ["MOD-R-DATA"]

        try:
            name = config.get(text+i+'.name').decode('utf8')
        except AttributeError:
            try:
                link = config.get(text+i+'.url')
                if link[0] =='*':
                    a = config.get(text+i+'.url')[1:]
                    a = a.split(',')
                    ll = {}
                    ll['controller'] = a[0].split('=')[1]
                    ll['action'] = a[1].split('=')[1]
                    link = toolkit.url_for(controller=ll['controller'], action=ll['action'])
                name = link
            except AttributeError:
                name = ""
            

        try:
            result.append({'name':name, 
                           'url':config.get(text+i+'.url'), 
                           'role':role, 
                           'popis':popis,
                           'sk_text':sk_text,
                           'en_text':en_text})
        except AttributeError:
            pass
    result = [x for x in result if x != None]
    sys = False
    if c.userobj and c.userobj.sysadmin:
        sys = True
    result = [x for x in result if (HR(user_roles, x['role']) or sys)]
    result2 = []
    for i in result:
        if i['url'][0] == '*':
            a = i['url'][1:]
            a = a.split(',')
            ll = {}
            ll['controller'] = a[0].split('=')[1]
            ll['action'] = a[1].split('=')[1]
            i['url'] = toolkit.url_for(controller=ll['controller'], action=ll['action'])
        result2.append(i)
    return result2