I agree. I will take a patch to this effect/ I would not spend time
with sql.py since I am rewriting it from scratch.

On Jun 6, 12:39 am, Hans Donner <hans.don...@pobox.com> wrote:
> Thanks all.
> I'm noot looking for a central place to store it all, or for real
> inmutable constants.
>
> For the example given:
>
> class PasswordWidget
>     DEFAULT_DISPLAY = 8('*')
>     (....)
>
> would be more than enough and in sql.py there could be things like
> DAL.FIELDTYPE_STRING = 'string'
>
> and in cache.py :
> DEFAULT_TIMEEXPIRE = 300
>
> the magic values (strings, numbers etc) are thus now a bit more
> descriptive (and available for autocompletion if not using the online
> environment). I'm not saying that all strings must/should be replaced
> as such.
>
> On Sat, Jun 6, 2009 at 6:37 AM, Yarko Tymciurak<yark...@gmail.com> wrote:
> > On Fri, Jun 5, 2009 at 3:46 PM, Hans Donner <hans.don...@pobox.com> wrote:
>
> >> what is it you do not understand? perhaps I can exaplin it better.
>
> > Hans -
>
> > I get the general idea you are trying to convey ---  for web2conf, we put
> > many configuration items into 'CONSTS' (ok, variables that should not be
> > changed, except in the config file) ... and we probably went too far.
>
> > In general, there's a balance between readability and DRY  (e.g. avoiding
> > errors).
>
> > For "type" checking, tests return strings in python, and these are generally
> > most readable if the tests are against strings too (too much DRY can result
> > in obfuscation, readability falling).
>
> >> Examples of 'strings'
> >> - in PasswordWidget (sqlhtml.py) there is the default display for a
> >> password, in FORM.accepts this is also re-used
>
> > The string '*********'  I would prefer to see as that;  in all of web2py, it
> > occurs only in sqlhtml.py, and only 3 times, twice to set, and once to
> > test.   I suppose for errors, something like 8*('*')  might be used (matter
> > of preference).
>
> >> - In the top of sql.py, when loading the drivers 'Postgre' is used as
> >> a key, while later it looks like it is referred to as 'Postgres'
>
> > In all of web2py source,  there is only ONE string starting with
> > 'Postg.....   and that is (as you point out) probably a typo; as you can
> > see, drivers (the list this string is appended to) is a list of drivers
> > available in your installation.  It is only used for text display at startup
> > of web2py, in widget.py, in start() .... for startup dialog....  I don't see
> > any compelling reason to change this from a string.
>
> > But I think your point is well taken - it would be particularly useful for
> > readability to assign regular expressions to descriptive names (regardless
> > of how many times they are used)...  or even to a concatenation of readable
> > chuncks.
>
> > So keep looking for places to suggest readability improvements - don't be
> > discouraged from your instincts - they are good!
>
> > Kind regards,
> > Yarko
>
> >> On Fri, Jun 5, 2009 at 10:29 PM, mdipierro<mdipie...@cs.depaul.edu> wrote:
>
> >> > I do not understand. I am sure it is because of lack of sleep and
> >> > headache due to broken glasses (waiting for a replament).
>
> >> > Massimo
>
> >> > On Jun 5, 3:09 pm, Hans Donner <hans.don...@pobox.com> wrote:
> >> >> could be my upbringing and my fat fingers/reliance on autocompletion,
> >> >> but I see a lot of repetitive code and strings, eg
> >> >> table_field = re.compile('[\w_]+\.[\w_]+') and 'keyname' etc.
>
> >> >> like the table_field being present in multiple files, why not move
> >> >> them to some shared globals and import from there?
>
> >> >> any reason why frequently reused keynames are not provided as CONST?
> >> >> Esp when used in different parts of web2py.
> >> >> This might also prevent the 'Postgre' (missing s?) in sql.py
>
> >> >> I've only been using python for a short time, so this might be the
> >> >> python way to do it.
>
> >> >> Hans
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to