Thanks for the information. I will look at this again when I get a chance...
Joe On Tue, Jun 21, 2011 at 5:25 AM, David Watson <[email protected]>wrote: > Hi Joe, > > That report is generated because the types dictionary for that key > doesn't have a value that encodes a template for the field.length to > be written into. If you look at the types at the top of the class, > you'll notice that some types do have a template value and some do > not. > > Unfortunately, you shouldn't have even got that far. If you look > closely at the MongoDBAdapter and compare it to the CouchDB adapter, > you'll notice that the Mongo adapter is barely implemented, and in > fact, needs it's own specialization of the create_table method similar > to the couchdb adapter in order to function correctly, i.e. all that > SQL or DML stuff should not be happening for Mongo, because it doesn't > speak that dialect. > > When I ran the couchdb adapter, it died in similar ways though I'm not > sure why, but I suspect that, again, there's a missing method that > should be marked "not implemented" which causes it to fail. > Unfortunately, it's difficult to find these issues without a rigorous > test suite and also, the design goals are difficult to interpret > because the schemaless DBs simply don't require a lot of the munging > that the relational ones do WRT to schema changes. > > FWIW, I've been using auth as a test for these schemaless DB classes. > It would not be difficult to use that as an acid test (no pun > intended) and automate that such that if the app survives > initialization with auth turned on, you're at least through the C in > CRUD in terms of verifying that the functionality works. > > I'm also a little concerned with the way these adapters are treating > UUIDs in terms of translating from legacy IDs back and forth under the > covers. We use UUIDs as ID fields even when we run PostgreSQL. > > Part of the value proposition of the schemaless DBs is to eliminate > the problem of merging disparate relational database data into a > single global entity, i.e the data silo problem of the last 20 years > or so. UUIDs are a hard-stop requirement for that, and I'm not sure > that this kind of code is a good idea WRT preserving that kind of > functionality. See this article for more info: > > http://en.wikipedia.org/wiki/U-form > > Regards, > David > > On May 5, 10:41 pm, joseph simpson <[email protected]> wrote: > > #!/usr/bin/python > > import sys > > import time > > sys.path.append('/Users/pcode/Desktop/mongodb_test/web2py') > > from gluon.dal import DAL, Field > > > > db = DAL('mongodb://127.0.0.1:5984/db') > > #mongodb test set........ > > #start with simple data types........ > > #then inser into mongodb > > > > db.define_table('m_test', > > Field('name','text'), > > Field('number','integer')) > > > > ######################################################### > > ##### The above code produces the following error > > ######################################################### > > Traceback (most recent call last): > > File "./test_mdb_1.py", line 7, in <module> > > db = DAL('mongodb://127.0.0.1:5984/db') > > File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line > > 3724, in __init__ > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" % > > (attempts, error) > > RuntimeError: Failure to connect, tried 5 times: > > 'MongoDBAdapter' object has no attribute '_uri' > > > > ######################################################### > > ####### Make the following changes > > ######################################################### > > Line number 3342 > > FROM: > > m = re.compile('^(?P<host>[^\:/]+)(\:(?P<port>[0-9]+))?/(?P<db>.+) > > $').match(self._uri[10:]) > > TO: > > m = re.compile('^(?P<host>[^\:/]+)(\:(?P<port>[0-9]+))?/(?P<db>.+) > > $').match(self.uri[10:]) > > > > Line number 3344 > > FROM: > > raise SyntaxError, "Invalid URI string in DAL: %s" % self._uri > > TO: > > raise SyntaxError, "Invalid URI string in DAL: %s" % self.uri > > ######################################################### > > ####### Execute code again > > ######################################################### > > ####### New error listed below > > ######################################################### > > Traceback (most recent call last): > > File "./test_mdb_1.py", line 7, in <module> > > db = DAL('mongodb://127.0.0.1:5984/db') > > File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line > > 3724, in __init__ > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" % > > (attempts, error) > > RuntimeError: Failure to connect, tried 5 times: > > port must be an instance of int > > ######################################################### > > ######### Make the following change > > ######################################################### > > Line 3351 > > FROM: > > port = m.group('port') or 27017 > > TO: > > port = 27017 > > > ########################################################################### > ## > > ######### Now the code connects to the server but the error below is > > reported > > > ########################################################################### > ### > > Traceback (most recent call last): > > File "./test_mdb_1.py", line 14, in <module> > > Field('number','integer')) > > File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line > > 4032, in define_table > > polymodel=polymodel) > > File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line > > 513, in create_table > > % dict(length=field.length) > > TypeError: unsupported operand type(s) for %: 'type' and 'dict' > > ######################################################### > > ####### It is not clear to me why this error is generated > > ####### So report back to the list > > ######################################################### > > > > Have fun, > > > > Joe > -- Joe Simpson Sent From My DROID!!

