[google-appengine] Re: Let's defend GAE!
I read that article, and I'm looking into it more.. finding most of those things are true. Can someone help point out why these things are wrong? I'm only finding the same limitations he just revealed to me.. On Nov 21, 7:02 pm, "Vanni.T" wrote: > Hey guys, > this post ("Goodbye, Google App Engine") is #1 (201 points in 5 hours) > on Hacker News: > > http://www.carlosble.com/?p=719 > > http://news.ycombinator.com/item?id=1927903 > It is a horrible, uninformed anti-GAE article. Too many "you're right, > GAE sucks" comments out there for my taste. Nothing to say? -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Re: PHP style 'include' and 'require' in GAE?
Robert, very nice! I didn't know you could do that.. For others that may view this thread, here is a solution I used while waiting for something 'cleaner' mainpage_get.py def MainPage_Get(): return xxx,'/somewhere' main.py from mainpage_get import MainPage_Get class MainPage(webapp.RequestHandler): def get(self): xxx,redirect = MainPage_Get() if redirect: self.redirect(redirect) Perhaps that helps someone else, but I like Robert's solution for this specific purpose. Robert, could you provide a very simple example of what you meant in your last paragraph? I follow, but can't visualize 'how' to accomplish what you mean.. Thanks! On Dec 9, 8:37 pm, Robert Kluin wrote: > In your MailPage_Get code it does not look like "self" will reference the > request handler. Try something like: > > main.py > from mainpage_get import MainPage_Get > class MainPage(webapp.RequestHandler): > def get(self): > MainPage_Get(self) > > mainpage_get.py > def MainPage_Get(handler): > handler.redirect('/') > > Just something you may want to consider for organizing your code, I have a > couple "standard" base class that inherit from RequestHandler and define > things like error handling, template setup, "continue" handlers (redirecting > to the next page in a workflow), and so on. I usually subclass one of my > "standard" handler classes to build an end user facing class. > > Robert > > > > On Wed, Dec 9, 2009 at 10:29 PM, PatHaugen wrote: > > I've been playing around with modularizing my code, and so far just > > one question re: self.redirect > > > For example, changing this: > > > main.py > > from mainpage_get import MainPage_Get > > class MainPage(webapp.RequestHandler): > > def get(self): > > MainPage_Get() > > > mainpage_get.py > > def MainPage_Get(): > > self.redirect('/') > > > So the self.redirect is not going to work in any instance within > > another file, is there another option? This is a simple example, my > > MainPage_Get is of course very large with various checks via if/else > > redirecting the user to various locations.. > > > Wondering what others do in cases such as these. > > > On Dec 9, 1:10 am, G wrote: > > > Use templates to modularize your output, research {% extends %} {% > > > block %} and {{ block.super }}. The block.super trick will enable > > > DRYness. > > >http://code.google.com/appengine/docs/python/gettingstarted/templates... > > > > Use import to modularize your code, research 'from foo import bar as > > > _baz'. The leading underscore trick will keep library namespaces > > > clean (not a typical use case but when namespace polution is an issue > > > a leading underscore is the solution). > > >http://docs.python.org/tutorial/modules.htmlhttp://docs.python.org/re... > > > > -- > > > G > > > > On Dec 8, 11:25 pm, PatHaugen wrote: > > > > > Sorry if this seems simple, but all Google searches for 'Google App > > > > Engine include require PHP' or any of the variants went to websites > > > > complaining about lack of PHP support in GAE. > > > > > Here is my question: > > > > > In PHP, I use include/require to break apart code into separate files > > > > for simplicity and multiple developer situations. I'm at that point in > > > > GAE, and was wondering if there is something I could use. > > > > > As an example, if GAE were PHP I'd do something like: > > > > > > > > > > main.py > > > > include header.py > > > > include datastore.py > > > > class MainPage(webapp.RequestHandler): > > > > def get(self): > > > > include mainpage.py > > > > def post(self): > > > > include post.py > > > > include footer.py > > > > > footer.py > > > > application = webapp.WSGIApplication(... > > > > etc.. > > > > def main(): run_wsgi_app(application) > > > > if __name__ == "__main__": main() > > > > > header.py > > > > import xxx > > > > from xxx > > > > etc.. > > > > > datastore.py > > > > class xxx(db.Model).. > > > > etc.. > > > > > > > > > > Just a quick example. > > > > > Thoughts? > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to google-appeng...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine+unsubscr...@googlegroups.com > e...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Re: PHP style 'include' and 'require' in GAE?
I've been playing around with modularizing my code, and so far just one question re: self.redirect For example, changing this: main.py from mainpage_get import MainPage_Get class MainPage(webapp.RequestHandler): def get(self): MainPage_Get() mainpage_get.py def MainPage_Get(): self.redirect('/') So the self.redirect is not going to work in any instance within another file, is there another option? This is a simple example, my MainPage_Get is of course very large with various checks via if/else redirecting the user to various locations.. Wondering what others do in cases such as these. On Dec 9, 1:10 am, G wrote: > Use templates to modularize your output, research {% extends %} {% > block %} and {{ block.super }}. The block.super trick will enable > DRYness. > > http://code.google.com/appengine/docs/python/gettingstarted/templates...http://www.djangoproject.com/documentation/0.96/templates/http://www.djangobook.com/en/1.0/chapter04/http://c2.com/cgi/wiki?DontRepeatYourself > > Use import to modularize your code, research 'from foo import bar as > _baz'. The leading underscore trick will keep library namespaces > clean (not a typical use case but when namespace polution is an issue > a leading underscore is the solution). > > http://docs.python.org/tutorial/modules.htmlhttp://docs.python.org/reference/simple_stmts.html#the-import-statementhttp://wiki.python.org/moin/PythonSpeed/PerformanceTips#ImportStateme...http://stackoverflow.com/search?q=python+import > > -- > G > > On Dec 8, 11:25 pm, PatHaugen wrote: > > > > > Sorry if this seems simple, but all Google searches for 'Google App > > Engine include require PHP' or any of the variants went to websites > > complaining about lack of PHP support in GAE. > > > Here is my question: > > > In PHP, I use include/require to break apart code into separate files > > for simplicity and multiple developer situations. I'm at that point in > > GAE, and was wondering if there is something I could use. > > > As an example, if GAE were PHP I'd do something like: > > > > > > main.py > > include header.py > > include datastore.py > > class MainPage(webapp.RequestHandler): > > def get(self): > > include mainpage.py > > def post(self): > > include post.py > > include footer.py > > > footer.py > > application = webapp.WSGIApplication(... > > etc.. > > def main(): run_wsgi_app(application) > > if __name__ == "__main__": main() > > > header.py > > import xxx > > from xxx > > etc.. > > > datastore.py > > class xxx(db.Model).. > > etc.. > > > > > > Just a quick example. > > > Thoughts? -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Re: PHP style 'include' and 'require' in GAE?
Brilliant! Playing with your tips right now :D On Dec 9, 12:52 am, Robert Kluin wrote: > I think you are wanting the "import" command. Do not include the > ".py" on the file name. For example, if the file is named myhandler.py > then use: > > import myhandler > myobj = myhandler.ObjectName() > > Or, > from myhandler import TheObject > myobj = TheObject() > > If you have code in directories by sure to include an "__init__.py" > file in each one, it can be blank. Then to use: > > from dir1.subdir2.filename import AnObject > > anobj = AnObject() > > Search for python modules. I think there is a section in the dive into > python book about it. > > Robert > > On Dec 9, 2009, at 2:25, PatHaugen wrote: > > > > > Sorry if this seems simple, but all Google searches for 'Google App > > Engine include require PHP' or any of the variants went to websites > > complaining about lack of PHP support in GAE. > > > Here is my question: > > > In PHP, I use include/require to break apart code into separate files > > for simplicity and multiple developer situations. I'm at that point in > > GAE, and was wondering if there is something I could use. > > > As an example, if GAE were PHP I'd do something like: > > > > > > main.py > > include header.py > > include datastore.py > > class MainPage(webapp.RequestHandler): > > def get(self): > > include mainpage.py > > def post(self): > > include post.py > > include footer.py > > > footer.py > > application = webapp.WSGIApplication(... > > etc.. > > def main(): run_wsgi_app(application) > > if __name__ == "__main__": main() > > > header.py > > import xxx > > from xxx > > etc.. > > > datastore.py > > class xxx(db.Model).. > > etc.. > > > > > > Just a quick example. > > > Thoughts? > > > -- > > > You received this message because you are subscribed to the Google > > Groups "Google App Engine" group. > > To post to this group, send email to google- > > appeng...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine+unsubscr...@googlegroups.com > > . > > For more options, visit this group > > athttp://groups.google.com/group/google-appengine?hl=en > > . -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] PHP style 'include' and 'require' in GAE?
Sorry if this seems simple, but all Google searches for 'Google App Engine include require PHP' or any of the variants went to websites complaining about lack of PHP support in GAE. Here is my question: In PHP, I use include/require to break apart code into separate files for simplicity and multiple developer situations. I'm at that point in GAE, and was wondering if there is something I could use. As an example, if GAE were PHP I'd do something like: main.py include header.py include datastore.py class MainPage(webapp.RequestHandler): def get(self): include mainpage.py def post(self): include post.py include footer.py footer.py application = webapp.WSGIApplication(... etc.. def main(): run_wsgi_app(application) if __name__ == "__main__": main() header.py import xxx from xxx etc.. datastore.py class xxx(db.Model).. etc.. Just a quick example. Thoughts? -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
[google-appengine] Multiple Forms
Experimenting with GAE, I had a simple question I couldn't find the answer to in the doc pages, googling 'multiple forms' or same query on this group... My question is with multiple forms on one page, let's say 'MainPage' class MainPage(webapp.RequestHandler): def get(self): # Display a form # Display a second form def post(self): # Handle form data Using this method both forms go to execute the same code. I'm wondering if there is a way to do something like: def post(myvariable): Then somehow link each form to a separate 'def post()' are? In PHP for example I'd code in via the submit button: Then have a code block: if (isset($_POST['adduser-submit'])) {} What is the way for having multiple forms in GAE? As a side note, are there other options for 'def get(self)' and 'def post(self)'? I currently don't touch them because I haven't found documentation or examples of otherwise.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: Load Django Template from database
I tried your example a few different ways, still get an error: AttributeError: 'str' object has no attribute 'render' bar = # pulled template from DB self.response.out.write(bar.render(template.Context(template_values))) Tried again using what you did on 'bar' before: foo = # pulled template from DB bar = template.Template(foo) self.response.out.write(bar.render(template.Context(template_values))) Not sure if 'template.Template()' takes a str and makes it into a 'template' able to be rendered, does this code work on your side? I even tried scrapping the way I pull the template and using your method: foo = db.get(templatekey).templatetext Before that, I had to do another DB query to pull the key value of the template I wanted, regardless it still failed... On Sep 15, 11:09 am, Wooble wrote: > On Sep 15, 2:08 pm, Wooble wrote: > > > self.response.out.write(bar.render(template_values)) > > correction: you'll need to wrap template_values in template.Context(); > template.render() does this for you automagically. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: 'ReferenceProperty' query filtering?
Thanks for the response, works nice, however coming from PHP/MySQL this seems strange to me. We have two 'tables' and are trying to perform a query to link them, however this solution causes two queries on the 'database' to be performed, which are logged against you for your quotas. I'm used to joins: http://dev.mysql.com/doc/refman/5.0/en/join.html One query linking two or more tables for the data you need. Is Google App Engine's 'query' function not able to do anything like this? Is GQL better than GAE's 'Query'? On Sep 15, 12:41 pm, Arun Shanker Prasad wrote: > Hi, > > I am sorry I replied to the thread when I was not at my dev machine, > did not test the code. I am not sure if putting the query inside the > query.filter() will break it. > > owner = PetOwner.all().filter('name =', 'johndoe'),get() > query.filter('owner = ', owner) > > This should work. > > Thanks, > Arun Shanker Prasad. > > On Sep 16, 12:20 am, PatHaugen wrote: > > > I tested the filter you provided: > > query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe')) > > > However it didn't work. > > > I visited the doc you referenced, but the page does not mention > > anything about the style of query filters or any information on > > construction of queries with ReferenceProperty that I could find. > > > Does the query filter you wrote work on your side? > > > I broke our your query: > > PetOwner.all().filter('name =', 'johndoe') > > > Which worked fine, however it was in placing it inside the > > query.filter that I get an error. > > > Do you not get an error structured like this? > > > On Sep 15, 4:36 am, Arun Shanker Prasad > > wrote: > > > > Hi, > > > > I think you are trying to filter the ReferenceProperty as a string, > > > this won't work. You need to; > > > > query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe')) > > > > Doc on the Datastore ReferenceProperty; > > > >http://code.google.com/appengine/docs/python/datastore/entitiesandmod... > > > > Thanks, > > > Arun Shanker Prasad. > > > > On Sep 15, 8:54 am, PatHaugen wrote: > > > > > Jumping into GAE, I found the ReferenceProperty interesting but still > > > > don't fully understand it. > > > > > My question can expand on the example > > > > from:http://code.google.com/appengine/docs/python/datastore/creatinggettin... > > > > > class PetOwner(db.Model): > > > > name = db.StringProperty() > > > > class Pet(db.Model): > > > > name = db.StringProperty() > > > > type = db.StringProperty() # cat, dog, etc. > > > > owner = db.ReferenceProperty(PetOwner) > > > > > Let's do a query to select all cats with a specific owner. > > > > > query = db.Query(Pet) > > > > query = Pet.all() > > > > query.filter('type = ', 'Cat') > > > > results = query.fetch(limit=10) > > > > for result in results: > > > > output = result.name > > > > return output > > > > > What can I add to this to filter only those where 'owner' is > > > > 'johndoe'? > > > > > I tried: > > > > query.filter('owner = ', 'johndoe') > > > > > However it fails to return me a result, and I know you can pull the > > > > owner name via 'pet.owner.name' however trying: > > > > query.filter('owner.name = ', 'johndoe') > > > > > Also fails, though it made sense for what should work. Does anyone > > > > know the proper method? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: 'ReferenceProperty' query filtering?
I tested the filter you provided: query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe')) However it didn't work. I visited the doc you referenced, but the page does not mention anything about the style of query filters or any information on construction of queries with ReferenceProperty that I could find. Does the query filter you wrote work on your side? I broke our your query: PetOwner.all().filter('name =', 'johndoe') Which worked fine, however it was in placing it inside the query.filter that I get an error. Do you not get an error structured like this? On Sep 15, 4:36 am, Arun Shanker Prasad wrote: > Hi, > > I think you are trying to filter the ReferenceProperty as a string, > this won't work. You need to; > > query.filter('owner = ', PetOwner.all().filter('name =', 'johndoe')) > > Doc on the Datastore ReferenceProperty; > > http://code.google.com/appengine/docs/python/datastore/entitiesandmod... > > Thanks, > Arun Shanker Prasad. > > On Sep 15, 8:54 am, PatHaugen wrote: > > > Jumping into GAE, I found the ReferenceProperty interesting but still > > don't fully understand it. > > > My question can expand on the example > > from:http://code.google.com/appengine/docs/python/datastore/creatinggettin... > > > class PetOwner(db.Model): > > name = db.StringProperty() > > class Pet(db.Model): > > name = db.StringProperty() > > type = db.StringProperty() # cat, dog, etc. > > owner = db.ReferenceProperty(PetOwner) > > > Let's do a query to select all cats with a specific owner. > > > query = db.Query(Pet) > > query = Pet.all() > > query.filter('type = ', 'Cat') > > results = query.fetch(limit=10) > > for result in results: > > output = result.name > > return output > > > What can I add to this to filter only those where 'owner' is > > 'johndoe'? > > > I tried: > > query.filter('owner = ', 'johndoe') > > > However it fails to return me a result, and I know you can pull the > > owner name via 'pet.owner.name' however trying: > > query.filter('owner.name = ', 'johndoe') > > > Also fails, though it made sense for what should work. Does anyone > > know the proper method? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] 'ReferenceProperty' query filtering?
Jumping into GAE, I found the ReferenceProperty interesting but still don't fully understand it. My question can expand on the example from: http://code.google.com/appengine/docs/python/datastore/creatinggettinganddeletingdata.html class PetOwner(db.Model): name = db.StringProperty() class Pet(db.Model): name = db.StringProperty() type = db.StringProperty() # cat, dog, etc. owner = db.ReferenceProperty(PetOwner) Let's do a query to select all cats with a specific owner. query = db.Query(Pet) query = Pet.all() query.filter('type = ', 'Cat') results = query.fetch(limit=10) for result in results: output = result.name return output What can I add to this to filter only those where 'owner' is 'johndoe'? I tried: query.filter('owner = ', 'johndoe') However it fails to return me a result, and I know you can pull the owner name via 'pet.owner.name' however trying: query.filter('owner.name = ', 'johndoe') Also fails, though it made sense for what should work. Does anyone know the proper method? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Load Django Template from database
I usually store my custom templates in the database for web editing and version tracking. I was interested in Django with GAE, however with the inability to write out files to the disk, web editing wasn't possible since I found I couldn't call Django templates from the database: templatepage = 'templates?template=templatename' path = os.path.join(os.path.dirname(__file__), templatepage) self.response.out.write(template.render(path, template_values)) However I get "TemplateDoesNotExist" Is there an alternative way that enables Django loading of the file from the database anyone can think of? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: City, County, State lookup by 'PostalAddressProperty'
Are there any simple ways to do location lookups in GAE using the PostalAddressProperty? I manually made arrays with all the cities in a few states using US Census data for cities with parent counties, found it insane, there has to be a better way right? On Sep 14, 2:30 pm, Barry Hunter wrote: > It looks like really its just a text field - nothing magic > > http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress > > On 14/09/2009, PatHaugen wrote: > > > > > Currently, grouping together users by physical area has been a > > challenge I've met a few ways in various projects by having a 'city' > > field and using my own arrays with cities of all states, county arrays > > that contain multiple cities, and doing queries using these to find > > all people in a county or in a state, etc. > > > Google's 'PostalAddressProperty' got me excited and I was wondering if > > there is a way to use this to simplify lookups for cities (based on > > zips), counties, states, etc with simple queries on this special field? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: 'query.filter' and 'where' fail to work
Ah... missed that point! On Sep 14, 4:53 pm, Robert Kluin wrote: > You are trying to filter based on a TextProperty. Change Alias to a > StringProperty and it will work just fine. > > See:http://code.google.com/appengine/docs/python/datastore/typesandproper... > > Robert > > On Mon, Sep 14, 2009 at 3:30 PM, PatHaugen wrote: > > > I included the entire sample app where I recreated the problem, but > > the root of it all is that in the example provided, 'query.filter' as > > well as GQL 'SELECT * FROM ___ WHERE' is also having the same issue. > > > The sample app I provided just populates data and shows without > > filters, it works, and with filters it fails to pull anything. > > > The reason the filters fail in this sample is where I'm asking for any > > insight? > > > On Sep 14, 11:49 am, PatHaugen wrote: > > > I was coding an app and found that 'query.filter' was failing to work > > > using query and GQL equivalent 'where' was not working either. > > > > I created a simple app to check if this was true... code posted below > > > and I ask... how can this be broken? > > > > -- > > > > import cgi > > > import os > > > import re > > > from google.appengine.ext.webapp import template > > > from google.appengine.api import users > > > from google.appengine.ext import webapp > > > from google.appengine.ext.webapp.util import run_wsgi_app > > > from google.appengine.ext import db > > > class TestData(db.Model): > > > Alias = db.TextProperty() > > > Content = db.TextProperty() > > > class CreateData(webapp.RequestHandler): > > > def get(self): > > > newTestData = TestData( > > > Alias = 'test1', > > > Content = 'Test 1 loadedTest 1 loaded', > > > ) > > > newTestData.put() > > > newTestData = TestData( > > > Alias = 'test2', > > > Content = 'bluetemplate loaded{{ content }}' > > > ) > > > newTestData.put() > > > self.redirect('/') > > > class MainPage(webapp.RequestHandler): > > > def get(self): > > > query = db.Query(TestData) > > > query = TestData.all() > > > #query.filter('Alias = ', 'test1') # Uncomment this filter, and no > > > results match for 'test1' or 'test2' > > > results = query.fetch(limit=1) > > > #results = db.GqlQuery("SELECT * FROM TestData WHERE Alias = :1", > > > 'test1') # Uncomment this to see GQL also fails... > > > for result in results: > > > output = result.Content > > > self.response.out.write(output) > > > application = webapp.WSGIApplication( > > > [ > > > ('/createdata', CreateData), > > > ('/.*', MainPage), > > > ], > > > debug=True > > > ) > > > def main(): > > > run_wsgi_app(application) > > > if __name__ == "__main__": > > > main() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] City, County, State lookup by 'PostalAddressProperty'
Currently, grouping together users by physical area has been a challenge I've met a few ways in various projects by having a 'city' field and using my own arrays with cities of all states, county arrays that contain multiple cities, and doing queries using these to find all people in a county or in a state, etc. Google's 'PostalAddressProperty' got me excited and I was wondering if there is a way to use this to simplify lookups for cities (based on zips), counties, states, etc with simple queries on this special field? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: Best way to reuse 'error page' code?
I'm with you, I prefer in scripting languages to have a single file to hold most of my project so I can backup and work on it anywhere easily. I used to store page output to a variable in PHP and add to it as the code executed, sending to the user only at the end of file and just trashing that variable if there was an error. Sounds similar to what you're hinting at. On Sep 14, 1:44 pm, OvermindDL1 wrote: > On Mon, Sep 14, 2009 at 2:40 PM, PatHaugen wrote: > > > OvermindDL1, > > > The way you describe it, "anything they have sent to the page > > previously is erased and only the error stuff is returned" sounds like > > you're not stopping at the exact point of error, but continuing to > > draw the rest of the page as the code continues and only after that > > erases what was generated and return only the error page? > > No, I do stop at the point of error, but in my design, page output and > code is intertwined (keeping down on file count), so by the time, say, > a database access may fail then stuff may have already been sent to > the sender, I wipe that clean. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: Best way to reuse 'error page' code?
OvermindDL1, The way you describe it, "anything they have sent to the page previously is erased and only the error stuff is returned" sounds like you're not stopping at the exact point of error, but continuing to draw the rest of the page as the code continues and only after that erases what was generated and return only the error page? Currently the only reason I use the redirect is to act as a break/die/ stop to not continue wasting time with the remaining code once an error is found. True, flags can be used so you can store all errors and report each individual error back (stopping at first error would leave out other errors found from being reported). However I'm just trying to find the best way to do this, or a detailed documentation page showing the methods already talked about. On Sep 14, 1:26 pm, PatHaugen wrote: > Hi Nick, > > Is there a resource page I can view that goes into this in more depth? > It was one area I didn't find any examples or documentation for and > would rather not re-invent the wheel if this has been standardized > with the usual method you outlined. > > I was reviewing a few status > codes:http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html > > This led me to wonder if in Python we can pull the status code > returned for the current page to display during development, and if > there was some way to alter the status code on pages served like we > would alter MIME: > self.response.headers['Content-Type'] = "application/xml" > > Then I could use the proper status code depending on error page? > > On Sep 14, 1:01 pm, "Nick Johnson (Google)" > wrote: > > > Hi Pat, > > > Sending a redirect in case of error is generally a bad idea, for several > > reasons: > > - It disguises the error as a redirect for clients (Eg, 302 instead of 500) > > - By redirecting the user to the error page, they can no longer simply hit > > refresh to try again for transient errors, nor can they copy the URL that's > > problematic. > > > Instead, the usual approach is something like this: > > > - Define a common base class that subclasses webapp.RequestHandler. > > - Override the error(code) method to generate and return an error page. > > - Make all your app's handlers inherit from your base handler. > > - Call self.error(code) and return whenever you need to. > > > -Nick > > > On Mon, Sep 14, 2009 at 8:28 PM, PatHaugen wrote: > > > > Currently the simplest way I've handled errors is by making a page > > > like others: > > > > class ErrorPage(webapp.RequestHandler): > > > ... > > > application = webapp.WSGIApplication( > > > ... > > > ('/errorpage', ErrorPage), > > > > Then, I use: > > > self.redirect('/errorpage') > > > > In any and all if/else branches where there should be an error and I > > > want to stop running the remaining code. > > > > However, I was wondering if there was a better way than just using the > > > 'self.redirect' to handle errors and perform stops on running code? > > > -- > > Nick Johnson, Developer Programs Engineer, App Engine --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: Best way to reuse 'error page' code?
Hi Nick, Is there a resource page I can view that goes into this in more depth? It was one area I didn't find any examples or documentation for and would rather not re-invent the wheel if this has been standardized with the usual method you outlined. I was reviewing a few status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html This led me to wonder if in Python we can pull the status code returned for the current page to display during development, and if there was some way to alter the status code on pages served like we would alter MIME: self.response.headers['Content-Type'] = "application/xml" Then I could use the proper status code depending on error page? On Sep 14, 1:01 pm, "Nick Johnson (Google)" wrote: > Hi Pat, > > Sending a redirect in case of error is generally a bad idea, for several > reasons: > - It disguises the error as a redirect for clients (Eg, 302 instead of 500) > - By redirecting the user to the error page, they can no longer simply hit > refresh to try again for transient errors, nor can they copy the URL that's > problematic. > > Instead, the usual approach is something like this: > > - Define a common base class that subclasses webapp.RequestHandler. > - Override the error(code) method to generate and return an error page. > - Make all your app's handlers inherit from your base handler. > - Call self.error(code) and return whenever you need to. > > -Nick > > > > On Mon, Sep 14, 2009 at 8:28 PM, PatHaugen wrote: > > > Currently the simplest way I've handled errors is by making a page > > like others: > > > class ErrorPage(webapp.RequestHandler): > > ... > > application = webapp.WSGIApplication( > > ... > > ('/errorpage', ErrorPage), > > > Then, I use: > > self.redirect('/errorpage') > > > In any and all if/else branches where there should be an error and I > > want to stop running the remaining code. > > > However, I was wondering if there was a better way than just using the > > 'self.redirect' to handle errors and perform stops on running code? > > -- > Nick Johnson, Developer Programs Engineer, App Engine --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Re: 'query.filter' and 'where' fail to work
I included the entire sample app where I recreated the problem, but the root of it all is that in the example provided, 'query.filter' as well as GQL 'SELECT * FROM ___ WHERE' is also having the same issue. The sample app I provided just populates data and shows without filters, it works, and with filters it fails to pull anything. The reason the filters fail in this sample is where I'm asking for any insight? On Sep 14, 11:49 am, PatHaugen wrote: > I was coding an app and found that 'query.filter' was failing to work > using query and GQL equivalent 'where' was not working either. > > I created a simple app to check if this was true... code posted below > and I ask... how can this be broken? > > -- > > import cgi > import os > import re > from google.appengine.ext.webapp import template > from google.appengine.api import users > from google.appengine.ext import webapp > from google.appengine.ext.webapp.util import run_wsgi_app > from google.appengine.ext import db > class TestData(db.Model): > Alias = db.TextProperty() > Content = db.TextProperty() > class CreateData(webapp.RequestHandler): > def get(self): > newTestData = TestData( > Alias = 'test1', > Content = 'Test 1 loadedTest 1 loaded', > ) > newTestData.put() > newTestData = TestData( > Alias = 'test2', > Content = 'bluetemplate loaded{{ content }}' > ) > newTestData.put() > self.redirect('/') > class MainPage(webapp.RequestHandler): > def get(self): > query = db.Query(TestData) > query = TestData.all() > #query.filter('Alias = ', 'test1') # Uncomment this filter, and no > results match for 'test1' or 'test2' > results = query.fetch(limit=1) > #results = db.GqlQuery("SELECT * FROM TestData WHERE Alias = :1", > 'test1') # Uncomment this to see GQL also fails... > for result in results: > output = result.Content > self.response.out.write(output) > application = webapp.WSGIApplication( > [ > ('/createdata', CreateData), > ('/.*', MainPage), > ], > debug=True > ) > def main(): > run_wsgi_app(application) > if __name__ == "__main__": > main() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Best way to reuse 'error page' code?
Currently the simplest way I've handled errors is by making a page like others: class ErrorPage(webapp.RequestHandler): ... application = webapp.WSGIApplication( ... ('/errorpage', ErrorPage), Then, I use: self.redirect('/errorpage') In any and all if/else branches where there should be an error and I want to stop running the remaining code. However, I was wondering if there was a better way than just using the 'self.redirect' to handle errors and perform stops on running code? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] 'query.filter' and 'where' fail to work
I was coding an app and found that 'query.filter' was failing to work using query and GQL equivalent 'where' was not working either. I created a simple app to check if this was true... code posted below and I ask... how can this be broken? -- import cgi import os import re from google.appengine.ext.webapp import template from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.ext import db class TestData(db.Model): Alias = db.TextProperty() Content = db.TextProperty() class CreateData(webapp.RequestHandler): def get(self): newTestData = TestData( Alias = 'test1', Content = 'Test 1 loadedTest 1 loaded', ) newTestData.put() newTestData = TestData( Alias = 'test2', Content = 'bluetemplate loaded{{ content }}' ) newTestData.put() self.redirect('/') class MainPage(webapp.RequestHandler): def get(self): query = db.Query(TestData) query = TestData.all() #query.filter('Alias = ', 'test1') # Uncomment this filter, and no results match for 'test1' or 'test2' results = query.fetch(limit=1) #results = db.GqlQuery("SELECT * FROM TestData WHERE Alias = :1", 'test1') # Uncomment this to see GQL also fails... for result in results: output = result.Content self.response.out.write(output) application = webapp.WSGIApplication( [ ('/createdata', CreateData), ('/.*', MainPage), ], debug=True ) def main(): run_wsgi_app(application) if __name__ == "__main__": main() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Issue with GAE caching which gives undesirable results
I have multiple domains pointed to Python code merely reporting the domain name as a test within a H1 tag in a Django template: {{ domain }} Python code: class GetDomain(): domain = os.environ['SERVER_NAME'] ... domain = GetDomain.domain template_values = { 'domain': domain, } path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values)) The issue I'm having is possibly with GAE caching output and not processing each time the page is hit. Example domains: www.domain1.com www.domain2.com www.domain3.com When I visit any domain the first time, I get the expected result: www.domain3.com However for the next 5 or so minutes, going to www.domain1.com or www.domain2.com shows the SAME output: www.domain3.com GAE is caching the output possibly? What is going on causing this unexpected result in code that works properly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] OSX Leopard "NotImplementedError: Unable to find the Python PIL library."
Installed the Google App Engine SDK: 1.1.7 11/21/08 http://code.google.com/appengine/downloads.html Worked perfect. Wanted to go into images, and test locally: http://code.google.com/appengine/docs/images/installingPIL.html#mac Installed this: http://pythonmac.org/packages/py25-fat/dmg/PIL-1.1.6-py2.5-macosx10.4-2007-05-18.dmg Error on install: requires system python 2.5 Installed what was requested (although python is bundled with Leopard and things were already working): http://pythonmac.org/packages/py25-fat/dmg/python-2.5-macosx.dmg Installed Python, then ran the PIL install, worked this time. Things seemed good, but trying to do localhost image manipulation gives: "NotImplementedError: Unable to find the Python PIL library. Please view the SDK documentation for details about installing PIL on your system." Odd, since I followed the instructions... Checked Google App Engine Preferences and saw this gem: "Python Path: __ The path to the Python installation. If left blank, the Launcer will attempt to find it. If you have installed Python Imaging Library (PIL) from pythonmac.org, try setting this to /usr/local/bin/python2.5" Searched HDD, found this path was there, so set it to: /usr/local/bin/python2.5 Same error on test. Anyone get this to cleanly work as documented by Google? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---
[google-appengine] Add Domain (New Domain Depoloyment)
I searched groups and help, but still couldn't figure something out that may be misleading... http://appengine.google.com/deployment/newdomain?app_id=XXX So it informs me: "Note: You must sign up for Google Apps to register this domain or prove that you already own it." 1. Sign up for Google Apps to register this domain 2. Prove that you already own it I would like to use option #2, to merely prove I own the domain. Not sure how or where you do this, but my domain is already setup. I'm sure many others as well, got your Windows PDC, logins, intranet, everything said and done, Exchange in place, everyone using the domain... but you got some worthless webhost in BFE displaying your little external webpage. Okay in other terms: No need at all for Google Apps, just want to have the public side of the domain for the website point to a shiny new Google App Engine application. How do you do this? I'd assume the 'proof' would be in pointing current domain registrar www to Google's server for your app or something like that? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~--~~~~--~~--~--~---