Пример #1
0
	def getattr(self, sid, path, obj, name):
		'''
		'''
		if hasattr(self, '__acl_lib__') and self.__acl_lib__ != None:
			acl = self.__acl_lib__ 
			# form the result
			return acl.getattr(obj, name)
		else:
			# form the result
			return getattr(obj, name)
Пример #2
0
	def get_methods(self, sid, path, obj):
		'''
		'''
		if hasattr(self, '__acl_lib__') and self.__acl_lib__ != None:
			acl = self.__acl_lib__ 
##		else:
##			global acl
		# call the doc makic method if it exists...
		if hasattr(obj, '__method_doc__'):
			##!!!
			return obj.__method_doc__()
		res = {}
		# session/object specific methods...
		if hasattr(obj, '__public_attrs__'):
			lst = list(obj.__public_attrs__)
		else:
			lst = dir(obj)
		for attr in lst:
			try:
				o = acl.getattr(obj, attr)
			except AttributeError:
				continue
			else:
				if callable(o) and acl.isaccessible(o):
					if hasattr(o, '__doc__') and type(o.__doc__) is str:
						res[attr] = o.__doc__
					else:
						res[attr] = ''
		# do global methods (interface I)...
		if hasattr(self, '__global_methods__') or True:
			for meth in self.__global_methods__:
				o = getattr(self, meth)
				if hasattr(o, '__doc__') and type(o.__doc__) is str:
					res[meth] = o.__doc__
				else:
					res[meth] = ''
		# do global methods (interface II)...
		lst = dir(self)
		pattern = self.__globalmethodnameformat__.split('%s')
		for attr in lst:
			if attr.startswith(pattern[0]) and attr.endswith(pattern[-1]):
				o = getattr(self, attr)
				meth = '' not in pattern and attr.split(pattern[0])[-1].split(pattern[-1])[0] or \
						pattern[0] != '' and attr.split(pattern[0])[-1] or \
						pattern[-1] != '' and attr.split(pattern[-1])[0]
				# sanity check...
				if meth == '':
					continue
				if hasattr(o, '__doc__') and type(o.__doc__) is str:
					res[meth] = o.__doc__
				else:
					res[meth] = ''
		return res
Пример #3
0
	def _getobject(self, sid, obj, path):
		'''
		get an object by its path (with ACL).
		'''
		if hasattr(self, '__acl_lib__') and self.__acl_lib__ != None:
			acl = self.__acl_lib__ 
##		else:
##			global acl
		if hasattr(self, '__path_acl_check__') and self.__path_acl_check__:
			acl_check_cutoff = False
			for obj_name in path:
				##!!! REWRITE !!!##
				if hasattr(self, '__acl_lib__') and self.__acl_lib__ != None and not acl_check_cutoff:
					# check if this attr is accessible...
					obj = acl.getattr(obj, obj_name)
					if hasattr(obj, '__acl_check_cutoff__') and obj.__acl_check_cutoff__:
						acl_check_cutoff = True
				else:
					obj = getattr(obj, obj_name)
		else:
			for obj_name in path:
				obj = getattr(obj, obj_name)
		return obj