the more I think about this the more I think that just using XML(T ("....")) where you need this is better. escape=False would not work because it would return an XML object and not a string. It would not be that explicit and confuse people.
Massimo On Jun 5, 9:49 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > I see what you are doing but I do not like the fact that this promotes > Tx to something special while that is a name that I made up as an > example. I do not like to introduce new symbols and functions in > web2py. What if instead we make a > > T(....,escape=False)? > > with escape=True by default? > > I can implement it easily. > > Massimo > > On Jun 5, 9:40 pm, suiato <homm...@gmail.com> wrote: > > > I changed the regular expression in gluon/languages.py as below, and > > "update all languages" now updates the strings in T() and Tx() :-) > > > PY_STRING_LITERAL_RE = r'(?<=[^\w]T)x?\((?P<name>'\ > > + r"[uU]?[rR]?(?:'''(?:[^']|'{1,2}(?!'))*''')|"\ > > + r"(?:'(?:[^'\\]|\\.)*')|" + r'(?:"""(?:[^"]|"{1,2}(?!")) > > *""")|'\ > > + r'(?:"(?:[^"\\]|\\.)*"))' > > > To follow naming convention in web2py, would it be better called TX() > > instead of Tx()? > > > -- > > Teru > > > On 6月6日, 午前11:17, suiato <homm...@gmail.com> wrote: > > > > On 6月5日, 午後9:59, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > in principle yes. what error do you get? > > > > Adding the line > > > Tx=lambda *a: XML(str(T(*a)) > > > to store.py in the model of eStore doesn't cause any errors. > > > In fact, it seems to be working in Shell. > > > > After a good sleep, I realize findT() is made to look for T(), not Tx > > > ()... isn't it? > > > If so, the regular expression in languages.py in gluon needs to be > > > changed to find Tx() as well as T(). > > > I'm not familiar with regular expression, and will appreciate some > > > advice. The pattern (in ver.1.63.2) is > > > > # pattern to find T(bla bla bla) expressions > > > PY_STRING_LITERAL_RE = r'(?<=[^\w]T\()(?P<name>'\ > > > + r"[uU]?[rR]?(?:'''(?:[^']|'{1,2}(?!'))*''')|"\ > > > + r"(?:'(?:[^'\\]|\\.)*')|" + r'(?:"""(?:[^"]|"{1,2}(?!")) > > > *""")|'\ > > > + r'(?:"(?:[^"\\]|\\.)*"))' > > > regex_translate = re.compile(PY_STRING_LITERAL_RE, re.DOTALL) > > > > By the way, in epydoc(http://mdp.cti.depaul.edu/examples/static/ > > > epydoc/), it's > > > regex_translate = re.compile(r'(?s)(?<=[^\w]T\()(?P<name>[uU]?[rR]?(?: > > > \'\'\'(?:[^\']|\'{\1,2}(?!\'))*\'\'\')|(?:\'(?:[^\'\\]|\\.)*\')| > > > (?:"""(?:[^"]|"{1,2}(?!")\)*""")|(?:"(?:[^"\\]|\\.)*"))') > > > > -- > > > Teru > > > > > On Jun 4, 10:08 pm, suiato <homm...@gmail.com> wrote: > > > > > > On 6月5日, 午前1:47, JorgeR <jorgeh...@gmail.com> wrote: > > > > > > > cool > > > > > > > this should go in the wiki under 'tips and tricks' > > > > > > Oh, inhttps://mdp.cti.depaul.edu/wiki/? > > > > > Actually, it'd be nice to have a topic on translation/i18n/l10n. > > > > > > > On Jun 3, 11:08 pm, suiato <homm...@gmail.com> wrote: > > > > > > > > 2009/06/04 12:57 mdipierro <mdipie...@cs.depaul.edu>: > > > > > > > > > In model you can just do > > > > > > > > > Tx=lambda *a: XML(str(T(*a)) > > > > > > > > > and use Tx instead. > > > > > > In my current effort to translate eStore, XML(T()) for links works > > > > > well and I'm happily using it. > > > > > > I still need to work on making the above lambda function work. > > > > > Do I just add the line into the model store.py? My first try was not > > > > > successful. > > > > > > -- > > > > > Teru > > > > > > > > This is a good learning experience for me. Lots of thanks, > > > > > > > Massimo. > > > > > > > > By the way, XML(T()) seems to work when I tested with an example. > > > > > > > > Cheers, > > > > > > > Teru > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---