[abac] logging instead of print in load_profile_by_dic()

This commit is contained in:
Mikaël Ates 2011-09-02 18:21:05 +02:00
parent ed3bdb6b6c
commit 62c722654b
1 changed files with 22 additions and 15 deletions

View File

@ -708,25 +708,32 @@ def get_all_sources():
def load_profile_by_dic(profile, dic):
if not profile or not dic:
logger.error('load_profile_by_dic: \
Missing profile or dictionnary')
return
for source in dic:
print "Found source in session: %s" % source
logger.debug('load_profile_by_dic: loading from source with name: %s' \
% source)
s = get_source_form_name(source)
if s:
print "Found source in db: %s" % s
if 'attributes' in dic[source]:
print "attributes: %s" % dic[source]['attributes']
for attr in dic[source]['attributes']:
print "With attribute %s of %s with values %s" % \
(attr['name'], attr['namespace'], str([x for x in attr['values']]))
d = get_def_from_name_and_ns(attr['name'], attr['namespace'])
if not d:
print "definition not found for %s %s" %(attr['name'], attr['namespace'])
else:
print "definition found %s" %d
add_assertion_to_profile(profile, s, d, attr['values'])
else:
print "No attributes for this source"
logger.debug('load_profile_by_dic: attributes: %s' \
% str(dic[source]))
for attr in dic[source]:
logger.debug('load_profile_by_dic: attribute %s of %s with values %s' \
% (attr['name'], attr['namespace'], str([x for x in attr['values']])))
d = get_def_from_name_and_ns(attr['name'], attr['namespace'])
if not d:
logger.error('load_profile_by_dic: \
definition not found for %s %s' \
% (attr['name'], attr['namespace']))
else:
logger.debug('load_profile_by_dic: \
definition %s found' % d)
add_assertion_to_profile(profile, s, d, attr['values'])
else:
logger.critical('load_profile_by_dic: \
The source with name %s and attributes %s is unknown of the system'
% (str(source), str(dic[source])))
@transaction.commit_manually