Exemplo n.º 1
0
	def __create_variable_info( self, options ):
		all_info = ConfigRegistryInfo( registered_only = False )
		info = ConfigRegistryInfo( install_mode = True )
		info.read_customized()
		var = Variable()

		# description
		for line in options[ 'descriptions' ]:
			text = line[ 'text' ]
			if not text: continue
			if 'lang' in line:
				var[ 'description[%s]' % line[ 'lang' ] ] = text
			else:
				var[ 'description' ] = text
		# categories
		if options[ 'categories' ]:
			var[ 'categories' ] = ','.join( options[ 'categories' ] )

		# type
		var[ 'type' ] = options[ 'type' ]

		# are there any modifications?
		old_value = all_info.get_variable( options[ 'key' ] )
		if old_value != var:
			# save
			info.add_variable( options[ 'key' ], var )
			info.write_customized()
Exemplo n.º 2
0
    def get(self, request):
        ucrReg = ConfigRegistry()
        ucrReg.load()
        ucrInfo = ConfigRegistryInfo(registered_only=False)

        # iterate over all requested variables
        results = []
        for key in request.options:
            info = ucrInfo.get_variable(str(key))
            value = ucrReg.get(str(key))
            if not info and (value or '' == value):
                # only the value available
                results.append({'key': key, 'value': value})
            elif info:
                # info (categories etc.) available
                info['value'] = value
                info['key'] = key
                results.append(info.normalize())
            else:
                # variable not available, request failed
                raise UMC_Error(
                    _('The UCR variable %(key)s could not be found') %
                    {'key': key})
        self.finished(request.id, results)
Exemplo n.º 3
0
	def get( self, request ):
		ucrReg = ucr.ConfigRegistry()
		ucrReg.load()
		ucrInfo = ConfigRegistryInfo( registered_only = False )

		# iterate over all requested variables
		results = []
		for key in request.options:
			info = ucrInfo.get_variable( str( key ) )
			value = ucrReg.get( str( key ) )
			if not info and (value or '' == value):
				# only the value available
				results.append( {'key': key, 'value': value} )
			elif info:
				# info (categories etc.) available
				info['value'] = value
				info['key'] = key
				results.append(info.normalize())
			else:
				# variable not available, request failed
				request.status = BAD_REQUEST_INVALID_OPTS
				self.finished( request.id, False, message = _( 'The UCR variable %(key)s could not be found' ) % { 'key' : key } )
				return
		self.finished( request.id, results )
	def is_readonly(self, key):
		ucrinfo_system = ConfigRegistryInfo(registered_only=False, load_customized=False)
		var = ucrinfo_system.get_variable(key)
		if var:
			return var.get('readonly') in ('yes', '1', 'true')
		return False
Exemplo n.º 5
0
	def is_readonly( self, key ):
		ucrinfo_system = ConfigRegistryInfo( registered_only = False, load_customized = False )
		var = ucrinfo_system.get_variable( key )
		if var:
			return var.get( 'readonly' ) in  ( 'yes', '1', 'true' )
		return False