Jorge Godoy wrote:
> Em Segunda 08 Maio 2006 17:16, Robin Haswell escreveu:
>> Jorge Godoy wrote:
>>> I prefer spending a bit more of my time to make users
>>> happy.
>> Good to know you'll never write for the gnome project then ;-)
>>
>> (Sorry)
>
> Why? I won't indeed. ;-)
Oh, my pet hate about GNOME is that their idea of "user friendliness" is
drastically slashing
features and functionality that users are crying out for (and ignoring pleas
for re-inclusion). I
swear most of the checkins to GNOME must be on the lines of
@@ 100 @@
+ /* Our users don't need this
@@ 1500
+ */
>> On a more constructive note, this might sound silly but can't we just do
>> this by performing a regular expression on quickstarted source?
>>
>> Try this:
>>
>> $ cat controllers.py|sed -r 's/^(\s+)@([a-z_]+\(.*\))\s*$/\1[\2]/i'
>>
>> It only works on single-line decorators (multiline might be a little beyond
>> my regexp skill) but it seems to do the job. I think the experession for a
>> python symbol - [a-z_] - is a little off, but someone can easily sort that
>> out. You could even replace it with [^(] .
>>
>> Of course that regexp is fine to just dump in to re.compile() -
>> re.compile(r's/^(\s+)@([a-z_]+\(.*\))\s*$/\1[\2]/', re.I)
>>
>> Quick question - why does the "[expose(...)]" work?
>
> I prefer maintaining an English template -- even though English is not my
> primary language -- than working with regular expressions (and I have a Perl
> (!!!) background... ;-)).
>
> I believe that there's some way to declare it like this:
>
> #if python23
> #def expose_decorator
> [turbogears.expose()]
> #end def
> #def identity_decorator
> [identity.require(...)]
> #end def
> #else if python24
> #def expose_decorator
> @turbogears.expose()
> #end def
> #def identity_decorator
> @identity.require(...)
> #end def
> #end if
>
> and then use it like:
>
> #expose_decorator
>
> or
>
> #insert expose_decorator
>
> Something like this looks much more maintainable to me and it is easy to
> use...
>
> BUT, I don't know the syntax for this template, so...
I don't think this scales.. if decorators transformations really are as simple
as my regular
expression, then using an intermediate syntax for a decorator and then doing
the appropriate
substitutions would be better. Just as an example, something like:
class Something(controller.Root):
$[[[expose(template="...")]]]
def index(self):
""" ... """
pass
Then when we write the template we can change those to the correct form.
... with a regular expression ;-)
-Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---