Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
>>>
if ((isinstance(database_port, types.StringType) or
isinstance(database_port, types.UnicodeType)) and
(isinstance(database_host, types.StringType) or
isinstance(database_host, types.UnicodeType))):
......
<<<
This will only execute when both database_port and database_host must be of
type basestring.
we are doing this check not only to avoid None value, this check is for to
avoid any
unexpected input (like True, False and other object).
your second alternative( isinstance(database_host, basestring) ) is really
good. we
wouldn't gain any performance due to this, but it will make code more readable
and
simple.
I will use your second alternative in our next release.
Original comment by rahul.pr...@in.ibm.com
on 30 Mar 2010 at 11:42
For this django settings:
DATABASE_ENGINE = 'ibm_db_django'
DATABASE_NAME = 'sample'
DATABASE_USER = 'user'
DATABASE_PASSWORD = 'password'
The database sample is registred on my machine and is located on another
machine.
I'll get error that there is no such database on localhost. This is because
django
default values (global_settings.py):
DATABASE_HOST = '' # Set to empty string for localhost. Not used with
sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with
sqlite3.
which will trigger "if" term with host/port that I reported. I think this is not
correct.
In order to avoid this we defined settings like this:
DATABASE_ENGINE = 'ibm_db_django'
DATABASE_NAME = 'sample'
DATABASE_USER = 'user'
DATABASE_PASSWORD = 'password'
DATABASE_HOST = None # workaround!!!
If you need to check values than I would suggest this:
if database_port and database_host:
assert isinstance(database_host, basestring), "database_host should be string type"
assert isinstance(database_port, basestring), "database_port should be string type"
Original comment by trebor74hr@gmail.com
on 1 Apr 2010 at 2:39
Fixed in ibm_db-1.0.2
Original comment by rahul.pr...@in.ibm.com
on 29 Apr 2010 at 12:33
Original issue reported on code.google.com by
trebor74hr@gmail.com
on 29 Mar 2010 at 11:41