On 8/13/07, Brian Harring <[EMAIL PROTECTED]> wrote:
> As hinted at earlier on the ml, have started doing some work on
> refactoring the actual db backend; ticket 5106 holds the current
> version (http://code.djangoproject.com/ticket/5106).
Hey Brian,
These look like solid improvements to me.
After a cursory read-through the patch, my only major complaint is the
unnecessary cleverness of some of the code. The stuff in BackendOps,
for example, could be rewritten in a much clearer way. (Granted, it
would be longer, but that's an acceptable tradeoff, in my opinion.)
For example, this is in the patch:
class BackendOps(object):
required_methods = ["%s_sql" % x for x in
('autoinc', 'date_extract', 'date_trunc', 'datetime_cast',
'deferrable', 'drop_foreignkey', 'fulltext_search', 'limit_offset',
'random_function', 'start_transaction', 'tablespace')]
required_methods += ['last_insert_id', 'max_name_length',
'pk_default_value', 'sequence_name', 'get_trigger_name']
required_methods = ["get_%s" % x for x in required_methods]
required_methods = tuple(required_methods)
And this is a much, much clearer way of expressing exactly the same thing:
class BackendOps(object):
required_methods = (
'get_autoinc_sql',
'get_date_extract_sql',
'get_date_trunc_sql',
'get_datetime_cast_sql',
'get_deferrable_sql',
'get_drop_foreignkey_sql',
'get_fulltext_search_sql',
'get_limit_offset_sql',
'get_random_function_sql',
'get_start_transaction_sql',
'get_tablespace_sql',
'get_last_insert_id',
'get_max_name_length',
'get_pk_default_value',
'get_sequence_name',
'get_get_trigger_name'
)
Not only is it clearer, but it saves us from having to do calculations
at run time. (Granted, the calculations would only have to be done
once, at import time, but why calculate at all if nothing is dynamic?)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---