|
Re: the "Cheetah files" (part 1): msg#00019python.cheetah
Hi Mike! I tried to use your href function, but the quoteHtml can not be found on my system. Another question: What is the best way to import such functions in a template: I tried: #from CheetahHelpFunctions import href This does work. However: #from CheetahHelpFunctions import * does not work - I guess this is a feature? Stefan. > I would also use a method to generate the hyperlinks. My favorite is: > > def href(url, label, quoteLabel=True, **attributes): > """If both 'url' and 'label', return a typical hyperlink. > If 'url' but not 'label', make the label identical to the URL. > If 'label' but not 'url', return the label instead of a hyperlink > (assume the link is disabled or not implemented yet). > If 'quoteLabel', HTML-encode the label. Otherwise assume it's > already encoded or doesn't need it. > If '**attributes', convert to hyperlink attributes, URL-encoding > both the key and the value. > """ > if url and label: > pass > elif url: > label = url > elif label: > return label > else: > return '' > if attributes: > atList = [] > for key, value in attributes.iteritems(): > tup = quoteUrl(key), quoteUrl(value) > s = '%s="%s"' % tup > atList.append(tup) > atString = ' '.join(atList) > else: > atString = '' > #url = quoteUrl(url) > if quoteLabel: > label = quoteHtml(label) > return '<A HREF="%s" %s>%s</A>' % (url, atString, label) > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | My real problem with Webware..., JZ |
|---|---|
| Next by Date: | Re: the "Cheetah files" (part 1), Mike Orr |
| Previous by Thread: | Re: the "Cheetah files" (part 1), Mike Orr |
| Next by Thread: | Re: the "Cheetah files" (part 1), Mike Orr |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |