Quote:
Originally Posted by Wiggo
There's a strange bug in the book details with my alias column.
The name is cutted off, and it happens with this name only.
|
It doesn't fail for me.
Is the 'P' in 'Petra' a non-Latin unicode character? I can see something like this happening if it is a unicode composed character.
FWIW: there is some strange (to me) code in your function:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, col_name, user_cat_prefix):
new_val = ''
if hasattr(mi, '_proxy_metadata'):
# Below should be mi.user_categories
all_cats = mi._proxy_metadata.user_categories
cats = {k:v for k,v in all_cats.items() if k.startswith(user_cat_prefix)}
SEP = mi.metadata_for_field(col_name)['is_multiple'].get('list_to_ui', '')
new_val = set()
if SEP:
val_ = val.split(SEP)
else:
val_ = [val]
for user_cat, v in cats.items():
repl = user_cat.lstrip(user_cat_prefix)
for user_cat_item, src_cat in v:
if src_cat == col_name:
# Why does the next line have the slice?
# I think it should be
# for item in val_:
for item in val_[:]:
if item == user_cat_item:
new_val.add(repl)
# Why are you removing the item from the list?
# Sometimes that will mess up the for loop. Or
# at least it could in python 2.
val_.remove(item)
else:
new_val.add(item)
if new_val:
return ', '.join(list(new_val))
return val