Thanks Massimo

The keyfilter example you provided does not work but this one does
with the current BEAUTIFY in the trunk
keyfilter=lambda key=' '.join([x.capitalize() for x in
key[2:].split('_')]) if key[1]=='_' else key

A typical view file is now
{{extend 'layout.html'}}
<br />
{{=BEAUTIFY(response._vars, keyfilter=lambda key: '
'.join([x.capitalize() for x in key[2:].split('_')]) if key[1]=='_'
else key)}}

John Heenan

On Feb 18, 6:47 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I looked again.
>
> You try to achieve two things:
> 1) As you say if the key starts with a_, this is removed. This is a
> trick to make sure elements are sorted as you like them.
>
> 2) You capitalize the words and replace _ with spaces.
>
> I think these are wrong solution to the problem. Look into trunk. The
> new BEAUTIFY now takes two optional named arguments: sorted,
> keyfilter.
>
> You can do what you want with
>
> BEAUTIFY(dict(....),keyfilter=lambda key: ' '.join([x.capitalize() for
> x in key.split('_')[1:]) if key[1:2]=='_' else key)
>
> On Feb 17, 5:49 am, John Heenan <johnmhee...@gmail.com> wrote:
>
> > The code I posted does not replace the normal behaviour of BEAUTIFY.
> > There is choice. In the four line example code I posted (which is from
> > a web2py slice) the keys are only changed if the second character is
> > an underscore.
>
> > I accept there is little enthusiasm. It is ironic because I think
> > there is potential to generalise an approach (such as with functional
> > hooks as mentioned) and show  the framework working in a way that
> > would generate more interest from the Python community (no web2py at
> > PyCon). If there was a suitable hook then there would be no need to
> > modify the BEAUTIFY class in  the web2py core.
>
> > John Heenan
>
> > On Feb 17, 2:55 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > Sorry I did not comment. I think this this can be very useful but it
> > > should not be a replacement for the current beautify. I think it is
> > > important to leave the keys unchanged for debugging purposes. That is
> > > what most people use BEAUTIFY for.
>
> > > You should post a slice about the improved function and I am sure it
> > > will be useful.
>
> > > On Feb 16, 9:20 pm, John Heenan <johnmhee...@gmail.com> wrote:
>
> > > > True. But surely better organised or prettier prototypes are
> > > > preferable when prototyping, as they gives a more realistic idea of a
> > > > final desired layout before the prettifiers get called in!
>
> > > > You can see the effect using just BEAUTIFY 
> > > > athttp://www.zgus.com/zgus/products/category_item/1
>
> > > > I don't have the skills or time to make the site pretty. If I start to
> > > > make money using the site then I will be happy to pay someone to give
> > > > my drab functional site a really pretty look!
>
> > > > What I would really prefer in web2py is a hook in BEAUTIFY and other
> > > > helpers so I could bypass them and not have my changes overridden
> > > > every time I do an upgrade. Even a hook in a low level inherited base
> > > > class would be enough, if using the hook would enable the name of the
> > > > helper to be determined and to override the helper. However I reckon
> > > > this is too much to ask!
>
> > > > John Heenan
>
> > > > On Feb 17, 11:57 am, villas <villa...@gmail.com> wrote:
>
> > > > > On Feb 17, 12:07 am, John Heenan <johnmhee...@gmail.com> wrote:
>
> > > > > > No reaction to including a four line big productivity booster into
> > > > > > web2py!
>
> > > > > Hi John,
> > > > > Sorry no one commented!  At least I looked at it, and liked it.  But
> > > > > Beautify is only a prototyping & testing thing for most so it's making
> > > > > something prettier that no one will see. But it's still better, so why
> > > > > not? +1
> > > > > David


On Feb 18, 6:47 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I looked again.
>
> You try to achieve two things:
> 1) As you say if the key starts with a_, this is removed. This is a
> trick to make sure elements are sorted as you like them.
>
> 2) You capitalize the words and replace _ with spaces.
>
> I think these are wrong solution to the problem. Look into trunk. The
> new BEAUTIFY now takes two optional named arguments: sorted,
> keyfilter.
>
> You can do what you want with
>
> BEAUTIFY(dict(....),keyfilter=lambda key: ' '.join([x.capitalize() for
> x in key.split('_')[1:]) if key[1:2]=='_' else key)
>
> On Feb 17, 5:49 am, John Heenan <johnmhee...@gmail.com> wrote:
>
> > The code I posted does not replace the normal behaviour of BEAUTIFY.
> > There is choice. In the four line example code I posted (which is from
> > a web2py slice) the keys are only changed if the second character is
> > an underscore.
>
> > I accept there is little enthusiasm. It is ironic because I think
> > there is potential to generalise an approach (such as with functional
> > hooks as mentioned) and show  the framework working in a way that
> > would generate more interest from the Python community (no web2py at
> > PyCon). If there was a suitable hook then there would be no need to
> > modify the BEAUTIFY class in  the web2py core.
>
> > John Heenan
>
> > On Feb 17, 2:55 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > Sorry I did not comment. I think this this can be very useful but it
> > > should not be a replacement for the current beautify. I think it is
> > > important to leave the keys unchanged for debugging purposes. That is
> > > what most people use BEAUTIFY for.
>
> > > You should post a slice about the improved function and I am sure it
> > > will be useful.
>
> > > On Feb 16, 9:20 pm, John Heenan <johnmhee...@gmail.com> wrote:
>
> > > > True. But surely better organised or prettier prototypes are
> > > > preferable when prototyping, as they gives a more realistic idea of a
> > > > final desired layout before the prettifiers get called in!
>
> > > > You can see the effect using just BEAUTIFY 
> > > > athttp://www.zgus.com/zgus/products/category_item/1
>
> > > > I don't have the skills or time to make the site pretty. If I start to
> > > > make money using the site then I will be happy to pay someone to give
> > > > my drab functional site a really pretty look!
>
> > > > What I would really prefer in web2py is a hook in BEAUTIFY and other
> > > > helpers so I could bypass them and not have my changes overridden
> > > > every time I do an upgrade. Even a hook in a low level inherited base
> > > > class would be enough, if using the hook would enable the name of the
> > > > helper to be determined and to override the helper. However I reckon
> > > > this is too much to ask!
>
> > > > John Heenan
>
> > > > On Feb 17, 11:57 am, villas <villa...@gmail.com> wrote:
>
> > > > > On Feb 17, 12:07 am, John Heenan <johnmhee...@gmail.com> wrote:
>
> > > > > > No reaction to including a four line big productivity booster into
> > > > > > web2py!
>
> > > > > Hi John,
> > > > > Sorry no one commented!  At least I looked at it, and liked it.  But
> > > > > Beautify is only a prototyping & testing thing for most so it's making
> > > > > something prettier that no one will see. But it's still better, so why
> > > > > not? +1
> > > > > David

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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.

Reply via email to