I'm currently modifing the DAL.py file to get DAL working with mongoDB. I got the insert part working, but the of the select method. So __select is working, but select() ain't. Because I need to convert a pymongo collection to a row. The line I point to has been written by Massimo, but isn't working. I have no idea's at the moment to do this in a general way. The returned value is a dict or a list of dict's, but of course not formatted in a DAL way.
-----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Alan Etkin Verzonden: zaterdag 3 december 2011 17:14 Aan: web2py-users Onderwerp: [web2py] Re: Converting mongodb collection to row Mark, i don't understand your post. Did you modify web2py code? Could you provide a little background on the interface you are working on? Thank you On Nov 30, 10:50 am, Mark Breedveld <[email protected]> wrote: > I have got the select function of mongodb adapter working, but know I > need to convert a pymongo cursor to row. > The point is the pymongo supports nested documents and that can be a > bit hard to convert for a parameter of the parse method. > > Here is the select function a have ajusted, but this one won't work > with yours because I also altered a lot of other functions. But this > is to get the idea. The line that has to be changed is pointed to with > <-- > def select(self,query,fields,attributes): > #if not isinstance(query,Query): > # raise SyntaxError, "Not Supported" > definition = self._select(query,fields,attributes) > > ctable = self.connection[str(definition['tablename'])] > if ((definition['sort'] == None) & (definition['skip'] == > None)): > result = ctable.find(definition['query']) > elif((definition['sort'] != None) & (definition['skip'] == > None)): > result = > ctable.find(definition['query']).sort(definition['sort']) > elif((definition['sort'] == None) & (definition['skip'] != > None)): > result = > ctable.find(definition['query']).skip(definition['skip']) > elif((definition['sort'] != None) & (definition['skip'] != > None)): > result = > ctable.find(definition['query']).sort(definition['sort']).skip(definit > ion['skip']) > else: > raise RuntimeError, "No valid query information found" > print str(result) > #rows = [cols['value'] for cols in result] <--- This line > converts the result to be parsed > return self.parse(rows, definition['colnames'], False) > > Anyone with advise on the matter or ideas? ----- Geen virus gevonden in dit bericht. Gecontroleerd door AVG - www.avg.com Versie: 2012.0.1873 / Virusdatabase: 2102/4653 - datum van uitgifte: 12/02/11

