[web2py] Anvanced applications in gae
Hi, I have developed some applications in web2py, and 2 are running currently in gae, but now i have serious problem. My current project is a social application, and when i design (example) the tables to make an user follow the actions other user (twitter like) I find that many-to-many relationships in app-engine are not easily supported. >From my understanding using the tools present in web2py right i would need to do a lot of processing in memory, an that would hurt performance greatly. The pattern proposed by app store developers uses lists and "parent" relationship: class Message(db.Model): sender = db.StringProperty() body = db.TextProperty() class MessageIndex(db.Model): receivers = db.StringListProperty() indexes = MessageIndex.all(keys_only = True).filter('receivers = ', user_id) keys = [k.parent() for k in indexes) messages = db.get(keys) For using that pattern in web2py I would need a method for specifying the parent of a model instance. Can I specify that relationship using any method I don't know? If not, would it be hard to implement? Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
Ok, thanks! I would like to make the patch myself, but the innards of web2py are somewhat complex... Thanks again, Carles. On Mon, Jun 21, 2010 at 6:43 PM, mdipierro wrote: > Probably it would not be hard to implement. I will look into this next > week but if somebody sends me a patch before that I will take it. > > Massimo > > On Jun 21, 9:25 am, Carles Gonzalez wrote: >> Hi, >> >> I have developed some applications in web2py, and 2 are running >> currently in gae, but now i have serious problem. >> >> My current project is a social application, and when i design >> (example) the tables to make an user follow the actions other user >> (twitter like) I find that many-to-many relationships in app-engine >> are not easily supported. >> >> From my understanding using the tools present in web2py right i would >> need to do a lot of processing in memory, an that would hurt >> performance greatly. >> >> The pattern proposed by app store developers uses lists and "parent" >> relationship: >> >> class Message(db.Model): >> sender = db.StringProperty() >> body = db.TextProperty() >> >> class MessageIndex(db.Model): >> receivers = db.StringListProperty() >> >> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', user_id) >> keys = [k.parent() for k in indexes) >> messages = db.get(keys) >> >> For using that pattern in web2py I would need a method for specifying >> the parent of a model instance. Can I specify that relationship using >> any method I don't know? If not, would it be hard to implement? >> >> Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
My english is horrible, an maybe it wasn't clear, but that was exactly my problem :). Currently i'm looking at the code massimo told me about but i think that the problem isn't here. I explain: the parent is assigned when the child entity is created (at the constructor level), to ensure all entities on the same group are stored together (or close), that way transactions are feasible. I don't think i'm capable of doing that right now, but my proposed soultion (just an idea) is to extend the field definition syntax for reference fields, adding an atribute to indicate this tipe of relationship. Example (blatantly stolen from the book): db.define_table('person', Field('name')) db.define_table('dog', Field('name'), Field('owner', db.person, relationship="parent")) On SQL databases that attribute would be ignored, but in GAE web2py would enforce the parent relationship at creation and dog[id].parent would return the result of dog_instance.parent() I don't know if this is feasible or if i'm total crazy (an option to consider). Opinions? On Tue, Jun 22, 2010 at 1:42 AM, Matt wrote: > Any chance this could be considered as well? > > Currently the DAL doesn't allow you to set the parent which is > required for GAE entity groups. > > http://groups.google.com/group/web2py/browse_thread/thread/3c11deb2bfadf207/96a4324e5fd0cf71?lnk=gst&q=GAE+parent#96a4324e5fd0cf71 > > On Jun 22, 7:35 am, Carles wrote: >> Ok, I'll try. >> >> Carles >> >> El 21/06/2010, a las 19:03, mdipierro escribió: >> >> > The only file you need to look into is gluon/contrib/gql.py >> >> > specifically the select() function which calls filter returns the Rows >> > object >> >> > On Jun 21, 11:55 am, Carles Gonzalez wrote: >> >> Ok, thanks! I would like to make the patch myself, but the innards of >> >> web2py are somewhat complex... >> >> >> Thanks again, Carles. >> >> >> On Mon, Jun 21, 2010 at 6:43 PM, mdipierro >> >> wrote: >> >>> Probably it would not be hard to implement. I will look into this next >> >>> week but if somebody sends me a patch before that I will take it. >> >> >>> Massimo >> >> >>> On Jun 21, 9:25 am, Carles Gonzalez wrote: >> >>>> Hi, >> >> >>>> I have developed some applications in web2py, and 2 are running >> >>>> currently in gae, but now i have serious problem. >> >> >>>> My current project is a social application, and when i design >> >>>> (example) the tables to make an user follow the actions other user >> >>>> (twitter like) I find that many-to-many relationships in app-engine >> >>>> are not easily supported. >> >> >>>> From my understanding using the tools present in web2py right i would >> >>>> need to do a lot of processing in memory, an that would hurt >> >>>> performance greatly. >> >> >>>> The pattern proposed by app store developers uses lists and "parent" >> >>>> relationship: >> >> >>>> class Message(db.Model): >> >>>> sender = db.StringProperty() >> >>>> body = db.TextProperty() >> >> >>>> class MessageIndex(db.Model): >> >>>> receivers = db.StringListProperty() >> >> >>>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', >> >>>> user_id) >> >>>> keys = [k.parent() for k in indexes) >> >>>> messages = db.get(keys) >> >> >>>> For using that pattern in web2py I would need a method for specifying >> >>>> the parent of a model instance. Can I specify that relationship using >> >>>> any method I don't know? If not, would it be hard to implement? >> >> >>>> Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
Thanks! On Thu, Jun 24, 2010 at 2:27 PM, mdipierro wrote: > thinking about how to handle this... > > On Jun 22, 12:56 pm, Carles Gonzalez wrote: >> My english is horrible, an maybe it wasn't clear, but that was exactly >> my problem :). >> >> Currently i'm looking at the code massimo told me about but i think >> that the problem isn't here. >> >> I explain: the parent is assigned when the child entity is created (at >> the constructor level), to ensure all entities on the same group are >> stored together (or close), that way transactions are feasible. >> >> I don't think i'm capable of doing that right now, but my proposed >> soultion (just an idea) is to extend the field definition syntax for >> reference fields, adding an atribute to indicate this tipe of >> relationship. >> >> Example (blatantly stolen from the book): >> >> db.define_table('person', >> Field('name')) >> db.define_table('dog', >> Field('name'), >> Field('owner', db.person, relationship="parent")) >> >> On SQL databases that attribute would be ignored, but in GAE web2py >> would enforce the parent relationship at creation and dog[id].parent >> would return the result of dog_instance.parent() >> >> I don't know if this is feasible or if i'm total crazy (an option to >> consider). Opinions? >> >> On Tue, Jun 22, 2010 at 1:42 AM, Matt wrote: >> > Any chance this could be considered as well? >> >> > Currently the DAL doesn't allow you to set the parent which is >> > required for GAE entity groups. >> >> >http://groups.google.com/group/web2py/browse_thread/thread/3c11deb2bf... >> >> > On Jun 22, 7:35 am, Carles wrote: >> >> Ok, I'll try. >> >> >> Carles >> >> >> El 21/06/2010, a las 19:03, mdipierro escribió: >> >> >> > The only file you need to look into is gluon/contrib/gql.py >> >> >> > specifically the select() function which calls filter returns the Rows >> >> > object >> >> >> > On Jun 21, 11:55 am, Carles Gonzalez wrote: >> >> >> Ok, thanks! I would like to make the patch myself, but the innards of >> >> >> web2py are somewhat complex... >> >> >> >> Thanks again, Carles. >> >> >> >> On Mon, Jun 21, 2010 at 6:43 PM, mdipierro >> >> >> wrote: >> >> >>> Probably it would not be hard to implement. I will look into this next >> >> >>> week but if somebody sends me a patch before that I will take it. >> >> >> >>> Massimo >> >> >> >>> On Jun 21, 9:25 am, Carles Gonzalez wrote: >> >> >>>> Hi, >> >> >> >>>> I have developed some applications in web2py, and 2 are running >> >> >>>> currently in gae, but now i have serious problem. >> >> >> >>>> My current project is a social application, and when i design >> >> >>>> (example) the tables to make an user follow the actions other user >> >> >>>> (twitter like) I find that many-to-many relationships in app-engine >> >> >>>> are not easily supported. >> >> >> >>>> From my understanding using the tools present in web2py right i would >> >> >>>> need to do a lot of processing in memory, an that would hurt >> >> >>>> performance greatly. >> >> >> >>>> The pattern proposed by app store developers uses lists and "parent" >> >> >>>> relationship: >> >> >> >>>> class Message(db.Model): >> >> >>>> sender = db.StringProperty() >> >> >>>> body = db.TextProperty() >> >> >> >>>> class MessageIndex(db.Model): >> >> >>>> receivers = db.StringListProperty() >> >> >> >>>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', >> >> >>>> user_id) >> >> >>>> keys = [k.parent() for k in indexes) >> >> >>>> messages = db.get(keys) >> >> >> >>>> For using that pattern in web2py I would need a method for specifying >> >> >>>> the parent of a model instance. Can I specify that relationship using >> >> >>>> any method I don't know? If not, would it be hard to implement? >> >> >> >>>> Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
Very interesting! I'll try tomorrow. Thanks a lot, Dave. On Fri, Jun 25, 2010 at 1:21 AM, dlypka wrote: > I've done a parent - to - many child GAE / web2py implementation using > SelfReference fields (or you can use Reference as well) using the > technique for adding native GAE fields into a web2py table definition. > > It gives fantastic retrieval performance because GAE automatically > adds the link from the child back into the parent's reference list > at the time you create each child. When you later query for the > parent, voila GAE retrieves all the child entities along with it in > one backend call! > > Hopefully this technique is relevant to your application. > > I also develop some other tricks for inheriting native GAE classes > into your web2py model, though > this is less attractive perhaps now that GAE native properties can be > directly declared in web2py tables. > > - Dave Lypka. > > On Jun 21, 10:25 am, Carles Gonzalez wrote: >> Hi, >> >> I have developed some applications in web2py, and 2 are running >> currently in gae, but now i have serious problem. >> >> My current project is a social application, and when i design >> (example) the tables to make an user follow the actions other user >> (twitter like) I find that many-to-many relationships in app-engine >> are not easily supported. >> >> From my understanding using the tools present in web2py right i would >> need to do a lot of processing in memory, an that would hurt >> performance greatly. >> >> The pattern proposed by app store developers uses lists and "parent" >> relationship: >> >> class Message(db.Model): >> sender = db.StringProperty() >> body = db.TextProperty() >> >> class MessageIndex(db.Model): >> receivers = db.StringListProperty() >> >> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', user_id) >> keys = [k.parent() for k in indexes) >> messages = db.get(keys) >> >> For using that pattern in web2py I would need a method for specifying >> the parent of a model instance. Can I specify that relationship using >> any method I don't know? If not, would it be hard to implement? >> >> Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
Not to be annoying, but can you post an example? Just to organize the things in my head... Thanks again. On Fri, Jun 25, 2010 at 2:41 AM, Carles Gonzalez wrote: > Very interesting! > > I'll try tomorrow. > > Thanks a lot, Dave. > > On Fri, Jun 25, 2010 at 1:21 AM, dlypka wrote: >> I've done a parent - to - many child GAE / web2py implementation using >> SelfReference fields (or you can use Reference as well) using the >> technique for adding native GAE fields into a web2py table definition. >> >> It gives fantastic retrieval performance because GAE automatically >> adds the link from the child back into the parent's reference list >> at the time you create each child. When you later query for the >> parent, voila GAE retrieves all the child entities along with it in >> one backend call! >> >> Hopefully this technique is relevant to your application. >> >> I also develop some other tricks for inheriting native GAE classes >> into your web2py model, though >> this is less attractive perhaps now that GAE native properties can be >> directly declared in web2py tables. >> >> - Dave Lypka. >> >> On Jun 21, 10:25 am, Carles Gonzalez wrote: >>> Hi, >>> >>> I have developed some applications in web2py, and 2 are running >>> currently in gae, but now i have serious problem. >>> >>> My current project is a social application, and when i design >>> (example) the tables to make an user follow the actions other user >>> (twitter like) I find that many-to-many relationships in app-engine >>> are not easily supported. >>> >>> From my understanding using the tools present in web2py right i would >>> need to do a lot of processing in memory, an that would hurt >>> performance greatly. >>> >>> The pattern proposed by app store developers uses lists and "parent" >>> relationship: >>> >>> class Message(db.Model): >>> sender = db.StringProperty() >>> body = db.TextProperty() >>> >>> class MessageIndex(db.Model): >>> receivers = db.StringListProperty() >>> >>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', user_id) >>> keys = [k.parent() for k in indexes) >>> messages = db.get(keys) >>> >>> For using that pattern in web2py I would need a method for specifying >>> the parent of a model instance. Can I specify that relationship using >>> any method I don't know? If not, would it be hard to implement? >>> >>> Thanks in advance! >
Re: [web2py] Re: Anvanced applications in gae
Very interesting, i didn't know about collection_name and the associated query. You are shedding some light on doing relationships the GAE way. Thanks again. On Sat, Jun 26, 2010 at 8:52 AM, dlypka wrote: > > For starters: > > Refer to > http://arbingersys.blogspot.com/2008/04/google-app-engine-one-to-many-join_26.html?showComment=1244344382942#c5661660955046324965 > > And Here is the posting about using native GAE properties > > http://groups.google.com/group/web2py/browse_thread/thread/7112ef7dee1ccf32/d2b0d24c0e499924?lnk=gst&q=native#d2b0d24c0e499924 > > So for example you would do > > from gluon.contrib.gql import gae > : > : > db.define_table('ChildItem', > # NOTE: web2py provides the 'id' > column automatically > db.Field('idParentFolder','reference > MyParent'), > db.Field('name','text'), > db.Field('gaeParentInstance', > gae.ReferenceProperty(MyParent, > required=False, > collection_name='linksFromChildItemToParent'))) > > ) > > and define the parent class in a similar fashion. > > It is also necessary to add some plumbing to find and track the native > GAE references > which lie underneath the web2py sql objects because the native refs > have to be > put into the collections. > > I'll provide more details in some followup posts. > > On Jun 25, 2:48 pm, Carles wrote: >> Thanks a lot Dave. >> >> There isn't a deadline, tale your time :) >> >> Carles >> >> El 25/06/2010, a las 20:42, dlypka escribió: >> >> >> >> > OK will do - please give me a few days... >> >> > On Jun 24, 8:43 pm, Carles Gonzalez wrote: >> >> Not to be annoying, but can you post an example? >> >> >> Just to organize the things in my head... >> >> >> Thanks again. >> >> >> On Fri, Jun 25, 2010 at 2:41 AM, Carles Gonzalez >> >> wrote: >> >>> Very interesting! >> >> >>> I'll try tomorrow. >> >> >>> Thanks a lot, Dave. >> >> >>> On Fri, Jun 25, 2010 at 1:21 AM, dlypka wrote: >> >>>> I've done a parent - to - many child GAE / web2py implementation using >> >>>> SelfReference fields (or you can use Reference as well) using the >> >>>> technique for adding native GAE fields into a web2py table definition. >> >> >>>> It gives fantastic retrieval performance because GAE automatically >> >>>> adds the link from the child back into the parent's reference list >> >>>> at the time you create each child. When you later query for the >> >>>> parent, voila GAE retrieves all the child entities along with it in >> >>>> one backend call! >> >> >>>> Hopefully this technique is relevant to your application. >> >> >>>> I also develop some other tricks for inheriting native GAE classes >> >>>> into your web2py model, though >> >>>> this is less attractive perhaps now that GAE native properties can be >> >>>> directly declared in web2py tables. >> >> >>>> - Dave Lypka. >> >> >>>> On Jun 21, 10:25 am, Carles Gonzalez wrote: >> >>>>> Hi, >> >> >>>>> I have developed some applications in web2py, and 2 are running >> >>>>> currently in gae, but now i have serious problem. >> >> >>>>> My current project is a social application, and when i design >> >>>>> (example) the tables to make an user follow the actions other user >> >>>>> (twitter like) I find that many-to-many relationships in app-engine >> >>>>> are not easily supported. >> >> >>>>> From my understanding using the tools present in web2py right i would >> >>>>> need to do a lot of processing in memory, an that would hurt >> >>>>> performance greatly. >> >> >>>>> The pattern proposed by app store developers uses lists and "parent" >> >>>>> relationship: >> >> >>>>> class Message(db.Model): >> >>>>> sender = db.StringProperty() >> >>>>> body = db.TextProperty() >> >> >>>>> class MessageIndex(db.Model): >> >>>>> receivers = db.StringListProperty() >> >> >>>>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', >> >>>>> user_id) >> >>>>> keys = [k.parent() for k in indexes) >> >>>>> messages = db.get(keys) >> >> >>>>> For using that pattern in web2py I would need a method for specifying >> >>>>> the parent of a model instance. Can I specify that relationship using >> >>>>> any method I don't know? If not, would it be hard to implement? >> >> >>>>> Thanks in advance!
Re: [web2py] Re: Anvanced applications in gae
One word: WOW! I look forward to the next message, this way gae is really appeling. And your way of teaching is fun, really!. Moreover, Massimo, can't this method be the default behaviour to IS_IN_DB when running on gae? I't seems a good fit. Just my 2 cents. On Sun, Jun 27, 2010 at 4:36 PM, dlypka wrote: > Assuming you have > try: > from gluon.contrib.gql import * # if running on Google App > Engine > except: > db=SQLDB('sqlite://storage.db') # if not, use SQLite or > other DB - Used by T2 > datastoretype = 'SQL' > else: > db=GQLDB() # connect to Googl > datastoretype = 'GAE' > > # So now, db is the GAE db > > # To use those Collections in the Reference properites, you need to > insert NATIVE GAE references, > # so you need to somehow find the GAE entity instance reference given > a web2py sql row > > # Here is the 'Stargate / wormhole' code which takes you from web2py > back down into the native GAE Datastore alternate universe: > > > # So if you have a web2py table name 'ChildTable': > > web2pyChildTableClass = db.ChildTable # gives the web2py Table > class > > theNativeGAEChildTableClass = web2pyChildTableClass._tableobj # > magic... into GAE > > # > > # Now do a native GAE query to find the native GAE instance so it > # can be put into the Reference collection: > > nativeGAE ChildTableQuery = theNativeGAEChildTableClass.all() > > nativeGAEChildTableQuery.filter('id =', 25) # get for id = 25 > > nativeresults = nativeGAEChildTableQuery.fetch(limit=1) > > myGAENativeChild = nativeresults[0] > > # Now myGAENativeChild can be inserted into the native GAE Reference > collection > > - Dave Lypka > > On Jun 26, 5:48 am, Carles Gonzalez wrote: >> Very interesting, i didn't know about collection_name and the associated >> query. >> >> You are shedding some light on doing relationships the GAE way. >> >> Thanks again. >> >> >> >> On Sat, Jun 26, 2010 at 8:52 AM, dlypka wrote: >> >> > For starters: >> >> > Refer to >> >http://arbingersys.blogspot.com/2008/04/google-app-engine-one-to-many... >> >> > And Here is the posting about using native GAE properties >> >> >http://groups.google.com/group/web2py/browse_thread/thread/7112ef7dee... >> >> > So for example you would do >> >> > from gluon.contrib.gql import gae >> > : >> > : >> > db.define_table('ChildItem', >> > # NOTE: web2py provides the 'id' >> > column automatically >> > db.Field('idParentFolder','reference >> > MyParent'), >> > db.Field('name','text'), >> > db.Field('gaeParentInstance', >> > gae.ReferenceProperty(MyParent, >> > required=False, >> > collection_name='linksFromChildItemToParent'))) >> >> > ) >> >> > and define the parent class in a similar fashion. >> >> > It is also necessary to add some plumbing to find and track the native >> > GAE references >> > which lie underneath the web2py sql objects because the native refs >> > have to be >> > put into the collections. >> >> > I'll provide more details in some followup posts. >> >> > On Jun 25, 2:48 pm, Carles wrote: >> >> Thanks a lot Dave. >> >> >> There isn't a deadline, tale your time :) >> >> >> Carles >> >> >> El 25/06/2010, a las 20:42, dlypka escribió: >> >> >> > OK will do - please give me a few days... >> >> >> > On Jun 24, 8:43 pm, Carles Gonzalez wrote: >> >> >> Not to be annoying, but can you post an example? >> >> >> >> Just to organize the things in my head... >> >> >> >> Thanks again. >> >> >> >> On Fri, Jun 25, 2010 at 2:41 AM, Carles Gonzalez >> >> >> wrote: >> >> >>> Very interesting! >> >> >> >>> I'll try tomorrow. >> >> >> >>> Thanks a lot, Dave. >> >> >> >>> On Fri, Jun 25, 2010 at 1:21 AM, dlypka wrote: >> >>
Re: [web2py] Re: Anvanced applications in gae
I thought that IS_IN_DB() could do all the heavy lifting, searching by gae keys instead of integers and updating references. That way we wouldn't lose SQLFORM and the api would be the same on both on SQL and GQL. But i'm drifting, your explanations are great and when you tell us the last part of the method (putting references on the parent) i'd be glad to code a working example and send to the list. On Sun, Jun 27, 2010 at 6:36 PM, dlypka wrote: > I am not sure what functionality is being requested to add GAE > specific support to > IS_IN_DB. > My discussion has been about high performance links from parent to > children. > What native GAE object(s) would you need to check in IS_IN_DB ? > > Anyway, one nice to have patch would be to have insert() return the > native GAE ref > to the newly inserted row, so that the GAE ref would be immediately > available > for insertion into the native Reference collection. > > That would reduce the need for querying for the native reference as in > my previous post. > > So, in gql.py > in the method > def insert(self, **fields): > > at the last line where it does > return rid > > I suggest we need to also return tmp > because tmp is in fact the native GAE instance. > > I suppose adding a field to gluon.sql.Reference is a 'non starter'. > > Maybe just add a new property dynamically to the row > We could call it 'nativeRef' > > Would it be something like: > self.nativeRef = tmp # Python can add new properties 'on-the- > fly', right? > > as the new 2nd last statement of insert()? > > > > On Jun 27, 11:54 am, mdipierro wrote: >> I will wait for a patch from Dave. He knows more than I know about >> this. >> >> Massimo >> >> On Jun 27, 10:44 am, Carles Gonzalez wrote: >> >> >> >> > One word: WOW! >> >> > I look forward to the next message, this way gae is really appeling. >> > And your way of teaching is fun, really!. >> >> > Moreover, Massimo, can't this method be the default behaviour to >> > IS_IN_DB when running on gae? >> > I't seems a good fit. Just my 2 cents. >> >> > On Sun, Jun 27, 2010 at 4:36 PM, dlypka wrote: >> > > Assuming you have >> > > try: >> > > from gluon.contrib.gql import * # if running on Google App >> > > Engine >> > > except: >> > > db=SQLDB('sqlite://storage.db') # if not, use SQLite or >> > > other DB - Used by T2 >> > > datastoretype = 'SQL' >> > > else: >> > > db=GQLDB() # connect to Googl >> > > datastoretype = 'GAE' >> >> > > # So now, db is the GAE db >> >> > > # To use those Collections in the Reference properites, you need to >> > > insert NATIVE GAE references, >> > > # so you need to somehow find the GAE entity instance reference given >> > > a web2py sql row >> >> > > # Here is the 'Stargate / wormhole' code which takes you from web2py >> > > back down into the native GAE Datastore alternate universe: >> >> > > # So if you have a web2py table name 'ChildTable': >> >> > > web2pyChildTableClass = db.ChildTable # gives the web2py Table >> > > class >> >> > > theNativeGAEChildTableClass = web2pyChildTableClass._tableobj # >> > > magic... into GAE >> >> > > # >> >> > > # Now do a native GAE query to find the native GAE instance so it >> > > # can be put into the Reference collection: >> >> > > nativeGAE ChildTableQuery = theNativeGAEChildTableClass.all() >> >> > > nativeGAEChildTableQuery.filter('id =', 25) # get for id = 25 >> >> > > nativeresults = nativeGAEChildTableQuery.fetch(limit=1) >> >> > > myGAENativeChild = nativeresults[0] >> >> > > # Now myGAENativeChild can be inserted into the native GAE Reference >> > > collection >> >> > > - Dave Lypka >> >> > > On Jun 26, 5:48 am, Carles Gonzalez wrote: >> > >> Very interesting, i didn't know about collection_name and the >> > >> associated query. >> >> > >> You are shedding some light on doing relationships the GAE way. >> >> > >> Thanks again. >> >> > >>
Re: [web2py] Re: Anvanced applications in gae
Hi, i was trying this technique but i'm getting this traceback when using gae_google_account: Traceback (most recent call last): File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", line 56, in File "/Users/lauer/web2py/gluon/globals.py", line 96, in self._caller = lambda f: f() File "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", line 35, in user File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__ return self.login() File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login self.log_event(log % self.user) File "/Users/lauer/web2py/gluon/tools.py", line 1180, in log_event origin=origin, user_id=user_id) File "/Users/lauer/web2py/gluon/contrib/gql.py", line 281, in insert self._last_reference = tmp File "/Users/lauer/web2py/gluon/sql.py", line 1611, in __setattr__ raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference On Mon, Jun 28, 2010 at 7:04 AM, dlypka wrote: > OK I downloaded the trunk and tested this mod. > > myParent = db.ParentTable.insert(name='Bill') > myParentNativeRef = myParent._table._last_reference > > works > > Thanks again. > > On Jun 27, 3:28 pm, mdipierro wrote: >> > Maybe just add a new property dynamically to the row >> > We could call it 'nativeRef' >> >> > Would it be something like: >> > self.nativeRef = tmp # Python can add new properties 'on-the-fly', >> > right? >> >> > as the new 2nd last statement of insert()? >> >> If that is useful we can do it. I just did it in trunk so you can test >> it but I called self._last_reference to avoid possible naming >> conflicts. >> >> Massimo Any thoughts?
Re: [web2py] Re: Anvanced applications in gae
Now is working. Thanks, let's continue testing... On Wed, Jun 30, 2010 at 10:39 PM, mdipierro wrote: > You are right... fixing it in trunk..1..2..3..done. Please check it. > > Massimo > > On 30 Giu, 15:25, Carles Gonzalez wrote: >> Hi, i was trying this technique but i'm getting this traceback when >> using gae_google_account: >> >> Traceback (most recent call last): >> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >> exec ccode in environment >> File >> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> line 56, in >> File "/Users/lauer/web2py/gluon/globals.py", line 96, in >> self._caller = lambda f: f() >> File >> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> line 35, in user >> File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__ >> return self.login() >> File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login >> self.log_event(log % self.user) >> File "/Users/lauer/web2py/gluon/tools.py", line 1180, in log_event >> origin=origin, user_id=user_id) >> File "/Users/lauer/web2py/gluon/contrib/gql.py", line 281, in insert >> self._last_reference = tmp >> File "/Users/lauer/web2py/gluon/sql.py", line 1611, in __setattr__ >> raise SyntaxError, 'Object exists and cannot be redefined: %s' % key >> SyntaxError: Object exists and cannot be redefined: _last_reference >> >> >> >> On Mon, Jun 28, 2010 at 7:04 AM, dlypka wrote: >> > OK I downloaded the trunk and tested this mod. >> >> > myParent = db.ParentTable.insert(name='Bill') >> > myParentNativeRef = myParent._table._last_reference >> >> > works >> >> > Thanks again. >> >> > On Jun 27, 3:28 pm, mdipierro wrote: >> >> > Maybe just add a new property dynamically to the row >> >> > We could call it 'nativeRef' >> >> >> > Would it be something like: >> >> > self.nativeRef = tmp # Python can add new properties >> >> > 'on-the-fly', right? >> >> >> > as the new 2nd last statement of insert()? >> >> >> If that is useful we can do it. I just did it in trunk so you can test >> >> it but I called self._last_reference to avoid possible naming >> >> conflicts. >> >> >> Massimo >> >> Any thoughts?
Re: [web2py] Re: Anvanced applications in gae
Sorry, but I've encontured another error. The relevant part of my code is following: if request.env.web2py_runtime_gae:# if running on Google App Engine from gluon.contrib.login_methods.gae_google_account import GaeGoogleAccount auth.settings.login_form = GaeGoogleAccount() from gluon.contrib.gql import gae auth.define_tables() # creates all needed tables db.define_table('todos', Field('name','string'), Field(gae.ReferenceProperty(auth_user, required=True, collection_name='todos')) ) And the traceback is this: Traceback (most recent call last): File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/Users/lauer/web2py/applications/web2pytodo/models/db.py", line 76, in Field(gae.ReferenceProperty(auth_user, required=True, NameError: name 'auth_user' is not defined Maybe the entity class is not defined at the time of the reference? I created an user, but still isn't working. When this mini-project is finished I plan to release the source. I think that a working example of this technique woukd be interesting for reference. On Wed, Jun 30, 2010 at 10:56 PM, Carles Gonzalez wrote: > Now is working. Thanks, let's continue testing... > > On Wed, Jun 30, 2010 at 10:39 PM, mdipierro wrote: >> You are right... fixing it in trunk..1..2..3..done. Please check it. >> >> Massimo >> >> On 30 Giu, 15:25, Carles Gonzalez wrote: >>> Hi, i was trying this technique but i'm getting this traceback when >>> using gae_google_account: >>> >>> Traceback (most recent call last): >>> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >>> exec ccode in environment >>> File >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >>> line 56, in >>> File "/Users/lauer/web2py/gluon/globals.py", line 96, in >>> self._caller = lambda f: f() >>> File >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >>> line 35, in user >>> File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__ >>> return self.login() >>> File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login >>> self.log_event(log % self.user) >>> File "/Users/lauer/web2py/gluon/tools.py", line 1180, in log_event >>> origin=origin, user_id=user_id) >>> File "/Users/lauer/web2py/gluon/contrib/gql.py", line 281, in insert >>> self._last_reference = tmp >>> File "/Users/lauer/web2py/gluon/sql.py", line 1611, in __setattr__ >>> raise SyntaxError, 'Object exists and cannot be redefined: %s' % key >>> SyntaxError: Object exists and cannot be redefined: _last_reference >>> >>> >>> >>> On Mon, Jun 28, 2010 at 7:04 AM, dlypka wrote: >>> > OK I downloaded the trunk and tested this mod. >>> >>> > myParent = db.ParentTable.insert(name='Bill') >>> > myParentNativeRef = myParent._table._last_reference >>> >>> > works >>> >>> > Thanks again. >>> >>> > On Jun 27, 3:28 pm, mdipierro wrote: >>> >> > Maybe just add a new property dynamically to the row >>> >> > We could call it 'nativeRef' >>> >>> >> > Would it be something like: >>> >> > self.nativeRef = tmp # Python can add new properties >>> >> > 'on-the-fly', right? >>> >>> >> > as the new 2nd last statement of insert()? >>> >>> >> If that is useful we can do it. I just did it in trunk so you can test >>> >> it but I called self._last_reference to avoid possible naming >>> >> conflicts. >>> >>> >> Massimo >>> >>> Any thoughts? >
Re: [web2py] Re: Anvanced applications in gae
Tested and now the error is: Traceback (most recent call last): File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/Users/lauer/web2py/applications/web2pytodo/models/db.py", line 76, in Field(gae.ReferenceProperty(db.auth_user._tableobj)) File "/Users/lauer/web2py/gluon/sql.py", line 2648, in __init__ self.name = fieldname = cleanup(fieldname) File "/Users/lauer/web2py/gluon/sql.py", line 574, in cleanup if re.compile('[^0-9a-zA-Z_]').findall(text): TypeError: expected string or buffer On Thu, Jul 1, 2010 at 7:32 AM, mdipierro wrote: > I think, > > Field(gae.ReferenceProperty(auth_user,...) > > should be > > > Field(gae.ReferenceProperty(db.auth_user._tableobj,) > > > > On 30 Giu, 16:15, Carles Gonzalez wrote: >> Sorry, but I've encontured another error. >> >> The relevant part of my code is following: >> >> if request.env.web2py_runtime_gae: # if running on Google App >> Engine >> from gluon.contrib.login_methods.gae_google_account import >> GaeGoogleAccount >> auth.settings.login_form = GaeGoogleAccount() >> from gluon.contrib.gql import gae >> >> auth.define_tables() # creates all needed tables >> >> db.define_table('todos', Field('name','string'), >> Field(gae.ReferenceProperty(auth_user, >> required=True, >> collection_name='todos')) >> ) >> >> And the traceback is this: >> >> Traceback (most recent call last): >> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >> exec ccode in environment >> File "/Users/lauer/web2py/applications/web2pytodo/models/db.py", >> line 76, in >> Field(gae.ReferenceProperty(auth_user, required=True, >> NameError: name 'auth_user' is not defined >> >> Maybe the entity class is not defined at the time of the reference? I >> created an user, but still isn't working. >> >> When this mini-project is finished I plan to release the source. I >> think that a working example of this technique woukd be interesting >> for reference. >> >> On Wed, Jun 30, 2010 at 10:56 PM, Carles Gonzalez wrote: >> > Now is working. Thanks, let's continue testing... >> >> > On Wed, Jun 30, 2010 at 10:39 PM, mdipierro >> > wrote: >> >> You are right... fixing it in trunk..1..2..3..done. Please check it. >> >> >> Massimo >> >> >> On 30 Giu, 15:25, Carles Gonzalez wrote: >> >>> Hi, i was trying this technique but i'm getting this traceback when >> >>> using gae_google_account: >> >> >>> Traceback (most recent call last): >> >>> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >> >>> exec ccode in environment >> >>> File >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> >>> line 56, in >> >>> File "/Users/lauer/web2py/gluon/globals.py", line 96, in >> >>> self._caller = lambda f: f() >> >>> File >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> >>> line 35, in user >> >>> File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__ >> >>> return self.login() >> >>> File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login >> >>> self.log_event(log % self.user) >> >>> File "/Users/lauer/web2py/gluon/tools.py", line 1180, in log_event >> >>> origin=origin, user_id=user_id) >> >>> File "/Users/lauer/web2py/gluon/contrib/gql.py", line 281, in insert >> >>> self._last_reference = tmp >> >>> File "/Users/lauer/web2py/gluon/sql.py", line 1611, in __setattr__ >> >>> raise SyntaxError, 'Object exists and cannot be redefined: %s' % key >> >>> SyntaxError: Object exists and cannot be redefined: _last_reference >> >> >>> On Mon, Jun 28, 2010 at 7:04 AM, dlypka wrote: >> >>> > OK I downloaded the trunk and tested this mod. >> >> >>> > myParent = db.ParentTable.insert(name='Bill') >> >>> > myParentNativeRef = myParent._table._last_reference >> >> >>> > works >> >> >>> > Thanks again. >> >> >>> > On Jun 27, 3:28 pm, mdipierro wrote: >> >>> >> > Maybe just add a new property dynamically to the row >> >>> >> > We could call it 'nativeRef' >> >> >>> >> > Would it be something like: >> >>> >> > self.nativeRef = tmp # Python can add new properties >> >>> >> > 'on-the-fly', right? >> >> >>> >> > as the new 2nd last statement of insert()? >> >> >>> >> If that is useful we can do it. I just did it in trunk so you can test >> >>> >> it but I called self._last_reference to avoid possible naming >> >>> >> conflicts. >> >> >>> >> Massimo >> >> >>> Any thoughts?
Re: [web2py] Re: Anvanced applications in gae
Ah... Ok, that makes much more sense. On Thu, Jul 1, 2010 at 2:03 PM, mdipierro wrote: > Sorry... > > Field('fieldname',type=gae.ReferenceProperty(db.auth_user._tableobj,) > > On 1 Lug, 03:23, Carles Gonzalez wrote: >> Tested and now the error is: >> >> Traceback (most recent call last): >> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >> exec ccode in environment >> File "/Users/lauer/web2py/applications/web2pytodo/models/db.py", >> line 76, in >> Field(gae.ReferenceProperty(db.auth_user._tableobj)) >> File "/Users/lauer/web2py/gluon/sql.py", line 2648, in __init__ >> self.name = fieldname = cleanup(fieldname) >> File "/Users/lauer/web2py/gluon/sql.py", line 574, in cleanup >> if re.compile('[^0-9a-zA-Z_]').findall(text): >> TypeError: expected string or buffer >> >> On Thu, Jul 1, 2010 at 7:32 AM, mdipierro wrote: >> > I think, >> >> > Field(gae.ReferenceProperty(auth_user,...) >> >> > should be >> >> > Field(gae.ReferenceProperty(db.auth_user._tableobj,) >> >> > On 30 Giu, 16:15, Carles Gonzalez wrote: >> >> Sorry, but I've encontured another error. >> >> >> The relevant part of my code is following: >> >> >> if request.env.web2py_runtime_gae: # if running on Google App >> >> Engine >> >> from gluon.contrib.login_methods.gae_google_account import >> >> GaeGoogleAccount >> >> auth.settings.login_form = GaeGoogleAccount() >> >> from gluon.contrib.gql import gae >> >> >> auth.define_tables() # creates all needed tables >> >> >> db.define_table('todos', Field('name','string'), >> >> Field(gae.ReferenceProperty(auth_user, >> >> required=True, >> >> collection_name='todos')) >> >> ) >> >> >> And the traceback is this: >> >> >> Traceback (most recent call last): >> >> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted >> >> exec ccode in environment >> >> File "/Users/lauer/web2py/applications/web2pytodo/models/db.py", >> >> line 76, in >> >> Field(gae.ReferenceProperty(auth_user, required=True, >> >> NameError: name 'auth_user' is not defined >> >> >> Maybe the entity class is not defined at the time of the reference? I >> >> created an user, but still isn't working. >> >> >> When this mini-project is finished I plan to release the source. I >> >> think that a working example of this technique woukd be interesting >> >> for reference. >> >> >> On Wed, Jun 30, 2010 at 10:56 PM, Carles Gonzalez >> >> wrote: >> >> > Now is working. Thanks, let's continue testing... >> >> >> > On Wed, Jun 30, 2010 at 10:39 PM, mdipierro >> >> > wrote: >> >> >> You are right... fixing it in trunk..1..2..3..done. Please check it. >> >> >> >> Massimo >> >> >> >> On 30 Giu, 15:25, Carles Gonzalez wrote: >> >> >>> Hi, i was trying this technique but i'm getting this traceback when >> >> >>> using gae_google_account: >> >> >> >>> Traceback (most recent call last): >> >> >>> File "/Users/lauer/web2py/gluon/restricted.py", line 178, in >> >> >>> restricted >> >> >>> exec ccode in environment >> >> >>> File >> >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> >> >>> line 56, in >> >> >>> File "/Users/lauer/web2py/gluon/globals.py", line 96, in >> >> >>> self._caller = lambda f: f() >> >> >>> File >> >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user", >> >> >>> line 35, in user >> >> >>> File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__ >> >> >>> return self.login() >> >> >>> File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login >>
Re: [web2py] Re: appadmin fails on gae
No, it does not work either. it raises (from chromium): Error 107 (net::ERR_SSL_PROTOCOL_ERROR): Error desconegut. The app is quite simple, almost no code. Just a table, crud and webgrid. On Fri, Feb 19, 2010 at 2:07 PM, mdipierro wrote: > I do not know. I have never seen this that function is > straightforward: > >from google.appengine.api import users > users.create_login_url(request.env.path_info) > > and you get a GAE error > > > File "/base/python_lib/versions/1/google/appengine/api/users.py", line > 179, in create_login_url > > raise NotAllowedError > > NotAllowedError > > Does it work on dev_appserver? > > > On Feb 19, 7:01 am, Carles G wrote: > > Hi! > > > > I'm deploying a test aplication on GAE and almost everything woks > > fine, although I can't access appadmin. > > > > When i try to access through https the application fails and i can see > > the following error in the dashboard logs: > > > > In FILE: /base/data/home/apps/professorsecaib/1.339995859017462670/ > > applications/professors/controllers/appadmin.py > > > > Traceback (most recent call last): > > File "/base/data/home/apps/professorsecaib/1.339995859017462670/ > > gluon/restricted.py", line 173, in restricted > > exec ccode in environment > > File "/base/data/home/apps/professorsecaib/1.339995859017462670/ > > applications/professors/controllers/appadmin.py:index", line 33, in > > > > File "/base/data/home/apps/professorsecaib/1.339995859017462670/ > > gluon/fileutils.py", line 271, in check_credentials > > % users.create_login_url(request.env.path_info) > > File "/base/python_lib/versions/1/google/appengine/api/users.py", > > line 179, in create_login_url > > raise NotAllowedError > > NotAllowedError > > > > I searched the list but i couldn't find the answer. > > > > Thanks in advance and sorry for my poor english. > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to web...@googlegroups.com. > To unsubscribe from this group, send email to > web2py+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.