why do you need execs? import gluon.validators for key in dict(gluon.validators): globals()[key.lower()]=gluon.validators.__dict__[key]
On Oct 29, 10:49 pm, "mr.freeze" <nat...@freezable.com> wrote: > That makes sense. With that in mind, if I am doing this for my own > convenience is doing this with exec too costly on performance or > unsafe? > > On Oct 29, 10:31 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > There is a reason for UPPERCASE. All the web2py API that are defined > > outside the thread are uppercase. Those defined in the thread are > > lowercase. This means you should treat the uppercase ones as constants > > and not change class attributes or your app will affect other apps. > > > Massimo > > > On Oct 29, 9:42 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > > I love web2py, but I hate the convention of all uppercase separated > > > with commas in validators. It's like hitting a speed bump when you're > > > doing 80. I am experimenting with converting them to camelcase in my > > > model and it seems to work fine. > > > > def camelcase_validators(): > > > from gluon.validators import __all__ as all_validators > > > cmd = ";".join([ ''.join([a.lower().capitalize() for a in v.split > > > ("_")]) + "=" + v for v in all_validators]) > > > return cmd > > > > exec(camelcase_validators()) > > > > My questions: > > > 1) Is there a better way? > > > 2) Is exec really that bad? > > > > I know it's a silly venture, but indulge me :) > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" 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 -~----------~----~----~----~------~----~------~--~---