On 10 déc, 10:50, pielgrzym <[EMAIL PROTECTED]> wrote: > Hi there, > > I followed some examples in the documentation regarding contenttype > and I wanted to write my own simple, generig tagging app. I know there > is tagging application but it's troublesome when you try to pass tag > names in GET (language specific chars).
http://docs.python.org/library/urllib.html#utility-functions > Here is my code - it doesn't > work "doesn't work" is one of the most useless possible description of a problem. What happens exactly ? > - could anyone point me to the right direction? I'd say urllib.quote and unicode.encode... (snip) > tags/fields.py: > > # -*- coding: utf-8 -*- > from django.db import models > from tags.models import * > > def _tag_split(string): > list = string.split(",") <ot>this will shadow the list builtin type. </ot> > i = 0 > for val in list: > list[i] = val.strip() > i = i + 1 Use enumerate(seq) if you want to iterate over a sequence and have indices too: for i, val in enumerate(thelist): thelist[i] = val.strip() > clear_list = [x for x in list if x] > return clear_list Somehow complexificated way to do a simple thing: def _split_tags(tags): return filter(None, [tag.strip() for tag in tags.split(',')]) > _transliteration_pl = ( > (u"Ä ", r'a'), > (u"\xc4\x85", r'a'), > (u"Ä ", r'c'), > (u"\xc4\x87", r'c'), > (u"Ä ", r'e'), > (u"\xc4\x99", r'e'), > (u"Ĺ ", r'l'), > (u"\xc5\x82", r'l'), > (u"Ĺ ", r'n'), > (u"\xc5\x84", r'n'), > (u"Ăł", r'o'), > (u"\xc3\xb3", r'o'), > (u"Ĺ ", r's'), > (u"\xc5\x9b", r's'), > (u"Ĺź", r'z'), > (u"\xc5\xbc", r'z'), > (u"Ĺş", r'z'), > (u"\xc5\xba", r'z') > ) > > def _transliterate(value): > """Replaces language specific chars with theis non-specific > equivalents""" What about hebrew characters ?-) > for bad, good in _transliteration_pl: > value = value.replace(bad, good) > return value > (snip) Ok, you may have perfectly valid reasons to roll your own tag application, but if it's just a problem with encoding, using unicode.encode and urllib.quote should be enough to solve it IMHO. My 2 cents... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

