I tried setting it to true, but no luck.
From what I understand from the code though, I wouldn't expect it to -
the credential_decoder lambda that gets set up based on that flag
isn't used until after the regex tries to split the URI, ie:
m = re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:@/]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?sslmode=(?P<sslmode>.+))?$').match(uri)
if not m:
raise SyntaxError, "Invalid URI string in DAL"
user = credential_decoder(m.group('user'))
The match is failing (ie m is None) when passed in a credential string
like this, from db.py:
from gluon.tools import Service
db = DAL('postgres://user:p@ssword@host/db')
response.generic_patterns = ['*']
service = Service()
Forgot to mention - running web2py 1.99.4 against PostgreSQL 9.1.
To my mind, the bug lies with the regex. I asked a question on Stack
Overflow to see if I could come up with a solution with their help:
http://stackoverflow.com/questions/9156195/python-regex-escaping/9160293
Using the regex in the answer I accepted works when I try it in a mini
test script, ie:
uri = 'postgres://username:p@ssword@host/database'
uri = uri.split('://')[1]
m = re.compile('((?P<user>.*):)((?P<pass>.*)@)((?P<host>.*)/)((?P<db>.*))').match(uri)
if not m:
raise SyntaxError, "Invalid URI string in DAL " + uri
else:
print m.groupdict()
will result in:
{'host': 'host', 'db': 'database', 'user': 'username', 'pass': 'p@ssword'}
(note I've ignored port and SSL)
However if I modify dal.py, swapping line 1877 with:
m = re.compile('((?P<user>.*):)((?P<pass>.*)@)((?P<host>.*)/)((?P<db>.*))').match(uri)
I get:
Traceback (most recent call last):
File "/var/www/web2py/gluon/restricted.py", line 204, in restricted
exec ccode in environment
File "/var/www/web2py/applications/geospatial/models/db.py", line 3,
in <module>
db = DAL('postgres://username:p@ssword@host/database')
File "/var/www/web2py/gluon/dal.py", line 4736, in __init__
driver_args or {}, adapter_args or {})
File "/var/www/web2py/gluon/dal.py", line 1878, in __init__
if not m:
SyntaxError: Invalid URI string in DAL
IE no match (m is None).
Any help would be much appreciated. Happy to provide any more
information as required.
Cheers,
Hugh.
2012/2/8 Niphlod <nip...@gmail.com>: