[google-appengine] Re: Location tracking with AppEngine
tips for guessing theirlocationif they don't have Gears installed? (Keep in mind, I'm looking at the neighborhood/metro level). geoip is one established way. display client location works with geoip (with a gmap (such as classifiedsmarket.appspot.com)) brCountry Code: script language=JavaScriptdocument.write(geoip_country_code());/ script brCountry Name: script language=JavaScriptdocument.write(geoip_country_name());/ script brCity: script language=JavaScriptdocument.write(geoip_city());/script brRegion: script language=JavaScriptdocument.write(geoip_region());/ script brLatitude: script language=JavaScriptdocument.write(geoip_latitude());/ script brLongitude: script language=JavaScriptdocument.write(geoip_longitude());/ script and reverse geocodes: var reversegeocoder = new GReverseGeocoder(map); GEvent.addListener(reversegeocoder, load, function(placemark) { document.getElementById(message).innerHTML = placemark.address } ); regards --~--~-~--~~~---~--~~ 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: Can I separate py file?
On Sat, Jan 31, 2009 at 9:56 PM, Pikaurd Chen chenha...@gmail.com wrote: Can I separate the handlers to other py files? like this application = webapp.WSGIApplication([('/', pyfile1.MainPage), (r'/([0-9]+).html', pyfile2.MainPage), Put your handlers in different files (ResPage1.py, ResPage2.py). At the top of MainPage.py (the one holding webapp.WSGIApplication), simply do a from ResPage1 import * from ResPAge2 import * and Python will take care of the rest. Thanks -- Faber Fedor Cloud Computing New Jersey http://cloudcomputingnj.com --~--~-~--~~~---~--~~ 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] Disappearing reference collections
Let's use a simple example of a model containing posts and comments. The comment model contains a ReferenceProperty to Post, with a comments collection name. It always works fine locally: # Let's build a query object: from model import Post p = Post.all().get() p.comments google.appengine.ext.db.Query object at 0xcb27cac # Now we can fetch a list of comment entities. Sometimes, it works correctly on production. But sometimes, this happens: # Let's build a query object: from model import Post p = Post.all().get() p.comments AttributeError: 'Post' object has no attribute 'comments' And this is for entities where I've double and triple checked the model and the existence of the reference data. This problem didn't exist for me unitl a few days ago, either. I suspect this could be an index.yaml issue, but I use the - require_indexes dev_appserver param, and I've double-checked my index. Please, please do suggest something if you know the answer. This is a nasty bug, and I have no idea where it's coming from. --~--~-~--~~~---~--~~ 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] Server for appcfg.py down or just me?
When I run appcfg.py it just hangs when trying to connect to server. Is there anything I can do to see if it is a problem on my side or with my account or what? A ping of appengine.google.com resolves to www4.l.google.com and successfully replies to the ping. --~--~-~--~~~---~--~~ 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: Design consideration
if you really need to get the list of places from just distance point of view -- you might consider to upload your data to google base -- add location to your items and use their query engine for your specific needs. it will be lot faster. and almost no performance issue. On Jan 29, 11:15 pm, arnie parvez...@rediffmail.com wrote: Hi all I have to design a wsgi app which is returning xml data to be consumed by an iphone application. The iphone app sends an http request with latitude and longitude from iphone. Based on these entries, I need to query datastore table. The datastore table itself also contains latitude and longitude values in each row. I need to apply a distance calculation formula on this based on latitude and longitude values. Then I need to sort them in ascending order of distance. My problem is that we cannot reach at the final result before completing the calculation and also I do not want to send large xml data to iphone application to consume. Earlier I think to divide the process in two phases Phase 1: Does the calculation in wsgi application and generates the entire xml and sent the same to iphone PHase 2: iphone app sort the xml into ascending order But it will result in performance issue both at iphone and wsig application end. So is there any alternative that may give us limited data and that too sorted so that iphone can ask for another slot with no performance issue --~--~-~--~~~---~--~~ 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: Disappearing reference collections
On Feb 2, 12:15 pm, James thelevybre...@gmail.com wrote: It appears as if this is occurring when I'm not importing the Comment model. This might be mentioned in the docs, but I've been developing with GAE for a while and didn't know that it was necessary to import the model of the referred entity kind. The Comment class actually creates the Post.comments attribute behind the scenes. Check the ReferenceProperty.__property_config__() method for implementation details. I agree however that this fact should have been documented. --~--~-~--~~~---~--~~ 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: is gzip content encoding served/implemented in development server for local testing?
On Fri, Jan 30, 2009 at 1:19 PM, Peter Blazejewicz peter.blazejew...@gmail.com wrote: hi all, I'm testing application locally (Development/1.0 server/Mac OS X/ Python 2.5) and want to be sure of one thing: - even if both User-Agent/Accept-Encoding headers are specified in request as in: http://code.google.com/appengine/kb/general.html#compression (and in few other places in issue list/group) following occurs: - Accept-Encoding is stripped from request.headers *(logging)* {'Content-Length': '', 'Connection': 'close', 'Accept': '*/*', 'User- Agent': 'gzip', 'Host': 'localhost:8085', 'Content-Type': 'application/ x-www-form-urlencoded'} *(sniffer)* GET / HTTP/1.1 Content-Type: application/x-www-form-urlencoded User-Agent: gzip Accept-Encoding: gzip Accept: */* Connection: close Host: localhost:8085 - no gzip is applied (string data is written to out without specyfing gzip in response headers as required by docs) Is that limitation of Development server (which is something I could understand but I cannot find a confirmation trace in documentation or web resources)? Yes, this is a limitation of the development server. It does not do any compression. --~--~-~--~~~---~--~~ 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] Please Help - SMS message not received to set up an account and I don't know how to contact Google.
Please help. I have spent the past week learning Python and reading all the App Engine documentation and viewing all of the videos, now I want to upload an app and get started, but I do not receive an Authentication Code via SMS when I enter my mobile number and specify my carrier. I am entering everything correctly. I have re-tried several times. I need an alternative way to establish an account since this isn't working. What am I doing wrong or who can I contact at Google to resolve this issue? --~--~-~--~~~---~--~~ 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: Zip Importer High CPU every request
On Jan 8, 2:46 pm, Anthony acorc...@gmail.com wrote: Yes I have a main(), but the zipimporter is not in the .py file containing the main() it is in an imported file. The zipimporter is writing out its own info into the log.. for every request - should this happen if it is cached? I'm suffering from this problem, too. I'm using the Django Google App Engine helper and it seems to be reloading the zip file for every request. I stuck in a logging call after the sys.path insertion and it seems to be running for every request. I am on SDK 1.1.8, but that doesn't seem to change anything. --~--~-~--~~~---~--~~ 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] urfetch etag and last-modified problem
im trying to make something like a feed reader. Im using feedparser.py to parse the feeds like this def fetch_feed(url, modified = None, etag = None): import feedparser headers = {} if modified: headers['If-Modified-Since'] = modified if etag: headers['If-None-Match'] = etag response = urlfetch.fetch(url, headers = headers) feed = feedparser.parse(response.content) feed.modified = response.headers['Last-Modified'] if 'Last- Modified' in response.headers else None feed.etag = response.headers['ETag'] if 'ETag' in response.headers else None feed.status = response.status_code return feed but the If-Modified-Since and If-None-Match headers dont seem to work on some feeds.. so i tried a test on http://shell.appspot.com/ from google.appengine.api import urlfetch r = urlfetch.fetch('http://www.scripting.com/rss.xml') r.headers {'Content-Length': '48035', 'Via': 'HTTP/1.1 GWA (remote cache hit)', 'Accept-Ranges': 'bytes', 'X-Google-Cache-Control': 'remote-cache- hit', 'Server': 'Apache/2.2.4 (Win32)', 'Last-Modified': 'Fri, 30 Jan 2009 03:38:05 GMT', 'ETag': '1dd8-bba3-eec4f564', 'Date': 'Sun, 01 Feb 2009 04:46:09 GMT', 'Content-Type': 'application/xml', 'Age': ' 14856'} h = r.headers r = urlfetch.fetch('http://www.scripting.com/rss.xml', headers = {'If-Modified-Since': h['Last-Modified'], 'If-None-Match': h['ETag']}) r.status_code 200L but if i do curl for the same i get a 304 http code as expected.. $ curl --head http://www.scripting.com/rss.xml HTTP/1.1 200 OK Date: Sun, 01 Feb 2009 08:58:24 GMT Server: Apache/2.2.4 (Win32) Last-Modified: Fri, 30 Jan 2009 03:38:05 GMT ETag: 1dd8-bba3-eec4f564 Accept-Ranges: bytes Content-Length: 48035 Content-Type: application/xml $ curl --head --header If-Modified-Since: Fri, 30 Jan 2009 03:38:05 GMT --header If-None-Match: \1dd8-bba3-eec4f564\ http://www.scripting.com/rss.xml HTTP/1.1 304 Not Modified Date: Sun, 01 Feb 2009 08:58:16 GMT Server: Apache/2.2.4 (Win32) ETag: 1dd8-bba3-eec4f564 Can some one help me with this.. am i doing anything wrong? --~--~-~--~~~---~--~~ 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] Python 2.5.4 or Python 2.6.1?
Hi all, I'm just starting out and wondering which Python version to download for use with the AppEngine SDK. Python 2.5.4 or Python 2.6.1? Thanks, Paul --~--~-~--~~~---~--~~ 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] memcache.add = RuntimeError: maximum recursion depth exceeded
I've got a recursion error in both my local code, and when deployed. But it doesn't make much sense. At first I thought it was to do with mixing unicode strings in dictionaries. But I've ironed that out. Hopefully this is a simple mistake? @@@ python splashes = [ { 'url': splash.url, 'title': splash.title(), 'thumbnail_url': splash.thumbnail_url() } for splash in record.url_records() ] logging.info(setting values: %s % splashes) memcache.add(cache_key, splashes, 60) @@@ and the log output when it breaks; @@@ log INFO 2009-02-01 23:32:05,256 splashto.py] setting values: [{'url': u'http://code.google.com/apis/ajaxsearch/documentation', 'thumbnail_url': u'http://images.websnapr.com/? size=Skey=69wD353Q05qNurl=http%3A%2F%2Fcode.google.com%2Fapis %2Fajaxsearch%2Fdocumentation', 'title': u'Developer#39;sGuide - Google AJAX Search API - Google Code'}, {'url': u'http:// facebook.com', 'thumbnail_url': u'http://images.websnapr.com/? size=Skey=69wD353Q05qNurl=http%3A%2F%2Ffacebook.com', 'title': u'http://facebook.com'}] ERROR2009-02-01 23:32:05,336 __init__.py] maximum recursion depth exceeded Traceback (most recent call last): File /usr/local/lib/google_appengine/google/appengine/ext/webapp/ __init__.py, line 498, in __call__ handler.get(*groups) File /home/matthew/code/splashTo/splashto.py, line 39, in get splashes = get_splashes(key) File /home/matthew/code/splashTo/splashto.py, line 66, in get_splashes memcache.add(cache_key, splashes, 60) File /usr/local/lib/google_appengine/google/appengine/api/memcache/ __init__.py, line 557, in add return self._set_with_policy(MemcacheSetRequest.ADD, key, value, time=time) File /usr/local/lib/google_appengine/google/appengine/api/memcache/ __init__.py, line 602, in _set_with_policy stored_value, flags = _validate_encode_value(value, self._do_pickle) File /usr/local/lib/google_appengine/google/appengine/api/memcache/ __init__.py, line 170, in _validate_encode_value stored_value = do_pickle(value) File /usr/local/lib/google_appengine/google/appengine/api/memcache/ __init__.py, line 274, in DoPickle self._pickler_instance.dump(value) File /usr/lib/python2.5/pickle.py, line 224, in dump self.save(obj) File /usr/lib/python2.5/pickle.py, line 286, in save f(self, obj) # Call unbound method with explicit self ... (this goes on for hundreds of lines) ... File /usr/lib/python2.5/pickle.py, line 419, in save_reduce save(state) File /usr/lib/python2.5/pickle.py, line 286, in save f(self, obj) # Call unbound method with explicit self File /usr/lib/python2.5/pickle.py, line 649, in save_dict self._batch_setitems(obj.iteritems()) File /usr/lib/python2.5/pickle.py, line 681, in _batch_setitems save(v) File /usr/lib/python2.5/pickle.py, line 286, in save f(self, obj) # Call unbound method with explicit self File /usr/lib/python2.5/pickle.py, line 725, in save_inst save(stuff) File /usr/lib/python2.5/pickle.py, line 286, in save f(self, obj) # Call unbound method with explicit self File /usr/lib/python2.5/pickle.py, line 649, in save_dict self._batch_setitems(obj.iteritems()) File /usr/lib/python2.5/pickle.py, line 681, in _batch_setitems save(v) File /usr/lib/python2.5/pickle.py, line 286, in save f(self, obj) # Call unbound method with explicit self File /usr/lib/python2.5/pickle.py, line 496, in save_unicode self.write(BINUNICODE + pack(i, n) + encoding) RuntimeError: maximum recursion depth exceeded @@@ --~--~-~--~~~---~--~~ 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: Data Privacy
Andy Freeman wrote: Some supporting evidence would be nice because only one person is raising this concern. Here's another. I agree with the original poster. We have been thinking about making the significant investment required to convert our application to run on GAE once the service moves beyond the trial phase, because as a small company we're enchanted by the prospect of eliminating all of our system administration concerns and our growth pains. However, the only barrier to adoption for us is the data privacy aspect. Because of Google's practice of extensive data- mining in other services (Gmail, for example), we're afraid that Google is planning to profit from offering a free service by treating our extremely private user access information as an advertising datamine playground. Before we start re-coding our application, we would need a stronger privacy policy that outlines exactly what Google can do with our datastore. Best regards, -Maxime Camirand On Jan 17, 2:54 pm, Andy Freeman ana...@earthlink.net wrote: dataprivacyis probably the number one barrier to commercial cloud adoption at the moment. Some supporting evidence would be nice because only one person is raising this concern. Maybe it's so huge a barrier that no one else is bothering, maybe the discussion is somewhere else, but When you put these two statements together, Google is able to reproduce, adapt and modify developer contributed code to improve your UI, and explicitly *does not* require content owner's permission. Actually, there's nothing about the UI. However, there's something important missing from this discussion, namely for the sole purpose of enabling Google to provide you with the Service in accordance with itsprivacypolicy. How about some acceptable wording from a service that provides computation and storage resources, together with a link to the whole policy? On Jan 17, 9:17 am, hawkett hawk...@gmail.com wrote: Hi Marzai, Thanks for the detailed response. It would be great to get those clarifications included in the terms of service and/orprivacy policy. I can see from my post rating that some people don't share my concern, but dataprivacyis probably the number one barrier to commercial cloud adoption at the moment. Clear legal statements are always better than implied trust, or clarifications made in forums. I don't doubt that the constraints you have outlined are correct, but I read theprivacypolicy and terms of service to say something significantly different. Theprivacypolicy explicitly lists content (including code) and says this - 'We use this information internally to deliver the best possible service to you, such as improving the Google App Engine user interface and maintaining a consistent and reliable user experience.' The terms of service say this (in section 8, which overrides any rights outlined in section 6) - 'By submitting, posting or displaying the Content on or through the Service you give Google a worldwide, royalty-free, and non-exclusive license to reproduce, adapt, modify, translate, publish, publicly perform, publicly display and distribute such Content for the sole purpose of enabling Google to provide you with the Service in accordance with itsprivacypolicy.' When you put these two statements together, Google is able to reproduce, adapt and modify developer contributed code to improve your UI, and explicitly *does not* require content owner's permission. Apparently that permission is given once the data is uploaded. I'm not trying to be difficult - that is actually what it says - and those documents are actually what business look at when making decisions. I realise that the terms of service andprivacypolicy are produced by the legal team and not the engineering team, and the legal guys have a responsibility to protect Google from liability and litigation. Perhaps the legal team isn't fully aware of the importance of data security to GAE adoption. It is probably the engineering team's responsibility to raise that awareness. It seems clear to me that Google's strategy is to market GAE applications to its Google Apps customers. Both offerings sustain each other, and the delivery of the reseller program is a hint that this ecosystem is well on its way to being opened up. If you want an abundance of vendor supplied, commercial quality applications in that ecosystem, then data security needs to be much more clearly respected in the legal documentation. Thanks, Colin On Jan 16, 5:23 pm, Marzia Niccolai ma...@google.com wrote: Hi, First let me say that everyone on the App Engine team takes data privacyvery seriously, and point you to Section 6 and 8 of the App Engine terms of service (http://code.google.com/appengine/terms.html) that deal explicitly with the issue of data ownership and copyright. Also, it is important to note that the only
[google-appengine] Project works locally but can't read the required files when its deployed.
Hello, I have been working on a App engine project. That reads local files out of a directory, concats it and exports it. I tested it locally it worked fine. Even better than I expected. When i deployed the project. The code worked, but the file that it supposed to show are no where to be found. My includes / imports: import cgi import os.path from array import array from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.api import memcache This is how i access the files: header = fileversion + '/javascript/license.txt' # if we have the file, add it to our output if os.path.isfile(header): license = open(header,'r') for required in license: output.fromstring(required), output is an array, where i add the lines in. After i have gotten all my files, i do output.tostring() and write out the result. (and add it to my memcache) But it shows nothing, http://spry-it.appspot.com/js?version=1.6.1files=SpryData As far i understood, App Engine could read files, but not write. So i see no reason why this should work. App.yaml: application: spry-it version: 1 runtime: python api_version: 1 default_expiration: 365d handlers: - url: /1.6.1/ static_dir: 1.6.1 - url: /.* script: comb.py secure: optional Deployed location: http://spry-it.appspot.com/ file location: http://spry-it.appspot.com/1.6.1/javascript/license.txt --~--~-~--~~~---~--~~ 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: Location tracking with AppEngine
There are instances when doing it using JavaScript isn't nearly as good as doing it on the server. To do it on the server, you can import a database like MaxMind, but it's a bit of a pain. Or you can vote for the issue at http://code.google.com/p/googleappengine/issues/detail?id=803 and hope :) --~--~-~--~~~---~--~~ 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] I would like to upload a word document to data store
Group, I would like to develop an Google App Engine application where the user will be asked to upload a document in word or pdf ? How do I go about it ? Thanks in advance. Shashi --~--~-~--~~~---~--~~ 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: Please Help - SMS message not received to set up an account and I don't know how to contact Google.
On Feb 2, 3:23 am, mattc mcer...@gmail.com wrote: Please help. I have spent the past week learning Python and reading all the App Engine documentation and viewing all of the videos, now I want to upload an app and get started, but I do not receive an Authentication Code via SMS when I enter my mobile number and specify my carrier. I am entering everything correctly. I have re-tried several times. I need an alternative way to establish an account since this isn't working. What am I doing wrong or who can I contact at Google to resolve this issue? Fill out the SMS issues form: http://appengine.google.com/waitlist/sms_issues --~--~-~--~~~---~--~~ 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: Disappearing reference collections
Thanks for the tip. I've been meaning for some relevant opportunities to look more into the internals. On Feb 1, 6:17 pm, Alexander Kojevnikov alexan...@kojevnikov.com wrote: On Feb 2, 12:15 pm, James thelevybre...@gmail.com wrote: It appears as if this is occurring when I'm not importing the Comment model. This might be mentioned in the docs, but I've been developing with GAE for a while and didn't know that it was necessary to import the model of the referred entity kind. The Comment class actually creates the Post.comments attribute behind the scenes. Check the ReferenceProperty.__property_config__() method for implementation details. I agree however that this fact should have been documented. --~--~-~--~~~---~--~~ 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: 网页中有汉字,就会产生错误,不 知是啥原因
happy 牛 year! 哈哈 2009/2/2 yu ping322 yuping...@gmail.com 在这里混的中国人挺多的,只是很多人的英语也很牛,说英语显摆。 2009/2/2 kang areyouloo...@gmail.com: 一直有中文的啊,新年快乐~ 2009/1/31 trydofor trydo...@gmail.com 哥们们, 总算在列表里看到中文啦 :) 兴奋啊,祝新年快乐,牛年牛B kang wrote: 在文件开始加上#coding=utf-8 2009/1/22 网页中有汉字,就会产生错误,不知是啥原因 hjma...@gmail.com mailto:hjma...@gmail.com this code right in local development environment, but error on update to server. import wsgiref.handlers from google.appengine.ext import webapp class MainPage(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/html; charset=utf-8' self.response.out.write('htmlbodypHello, have no thing,有 了汉字就不 灵了?/p/body/html') -- /\__/\___/\/\/\ _/\/\/\/\__/\__/\__/\/\/\/\_/\/\_/\__/\ __/\__/\_/\_/\__/\___/\_/\/\__/\___/\__/\/\/\__/\___/\__/\_/\__ _/\__/\__/\/\__/\/\__/\___/\__/\__/\___/\__/\__ /\/\/\/\/\/\/\_/\/\_/\/\___ _/\/\/\ _/ trydofor.com / a9text.sf.net / a9w3.sf.net / -- Stay hungry,Stay foolish. --~--~-~--~~~---~--~~ 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: How to append to BlobProperty
Thanks, it finally worked. Following your suggestion, what I did is: 1. in class body, define: content = db.BlobProperty(required=False)# notice required is set to False 2. in __init__(arg1, arg2, ...): self.content = '' Then self.content += src doesn't complain anymore. When accessing, it returns a db.Blog doesn't sound too foreign to me. For now, I just think it as a customized type caster in C++. But I am facing another problem now, I will post it in a new thread 'Different behavior in Debug run'. Regards, Will On Tue, Jan 27, 2009 at 8:31 PM, Alexander Kojevnikov alexan...@kojevnikov.com wrote: When creating an UploadStorage entity, you should initialise the content property: my_entity = UploadStorage(content='') or: my_entity = UploadStorage() my_entity.content = '' # or whatever your initial value is I know, it a bit confusing. When you define the property in the class, UploadStorage.content is an instance of db.BlobProperty. But when you access it after the entity is created, it returns the actual value of the property, which is of db.Blob type (subclass of str). On Jan 27, 10:13 pm, Will vocalster@gmail.com wrote: I rewrote it, now the error message became unsupported operand type(s) for +=: 'NoneType' and 'str' pointing at self.content += src Seems *content* was not constructed in modified __init__. If I added self.content = db.BlobProperty(required=True) into __init__ while keeping the definition in the class body, I got Property content must be convertible to a Blob instance (Blob() argument should be str instance, not BlobProperty) Seems this time* content* was constructed but in __init__() somehow it wanted to initialize it by a Blob instance, not BlobProperty?! Will On Tue, Jan 27, 2009 at 6:43 PM, Alexander Kojevnikov alexan...@kojevnikov.com wrote: Rewrite your UploadStorage class to declare the module properties in the class body, not in the __init__ method. App Engine forwards access to property definitions to the actual property values, creation of the properties in __init__ is probably not compatible with it. For example, when you access self.content in your append() method, GAE returns the value of the append property, not the property definition. Try this code: class UploadStorage(db.Model): content = db.BlobProperty(required=True) last_change = db.DateTimeProperty(required=True, auto_now=True) field_name = db.StringProperty(required=True, default=u'') .. def __init__(self, field_name, file_name, content_type, content_length, charset): if field_name: self.field_name = field_name def append(self, src): self.content += src On Jan 27, 9:25 pm, Will vocalster@gmail.com wrote: Here you go, -- class UploadStorage(db.Model): def __init__(self, field_name, file_name, content_type, content_length, charset): self.content = db.BlobProperty(required=True) self.last_change = db.DateTimeProperty(required=True, auto_now=True) self.field_name = db.StringProperty(required=True, default=u'') .. if (field_name): self.field_name = field_name def append(self, src): self.content += src - class GAEUploadedFile(UploadedFile): def __init__(self, field_name, file_name, content_type, content_length, charset): self.__storage = UploadStorage(field_name, file_name, content_type, content_length, charset) .. def write(self, content): # append self.__storage.append(content) self.size = len(self.__storage.content) Thanks, Will On Tue, Jan 27, 2009 at 7:47 AM, Alexander Kojevnikov alexan...@kojevnikov.com wrote: No, doesn't work. I got unsupported operand type(s) for +=: 'BlobProperty' and 'str' Same as before. Could you post here all related code, including the construction of a Storage entity? --~--~-~--~~~---~--~~ 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: How to append to BlobProperty
Hi TLH, I'm writing a FileUploadHandler that saves files into a Blob, hence I'm using BlobProperty. Will On Tue, Jan 27, 2009 at 8:56 PM, TLH tlhola...@gmail.com wrote: from google.appengine.ext import db class Foo(db.Model): b = db.BlobProperty() def butWhy(self, s): self.b = self.b + s f = Foo( b = Append to a Blob? ) f.butWhy( You can, but why?) print f.b # Append to a Blob? You can, but why? I suspect you should be using a Text property. On Jan 23, 11:20 am, Will vocalster@gmail.com wrote: Hi all, I'd like to append a byte string to a db.BlobProperty, but can't figure out how. For example, Any ideas? Thanks in advance. Will --~--~-~--~~~---~--~~ 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] Different behavior in Debug run
Hi all, I'm writing a very simple file upload form using Django. I use Pydev and Eclipse. When I simply run it, the posted data are received; but when I run it as Debug, it says 'form.is_valid()' returns False, and I am pretty sure it is because the required values ('title', 'uploader', etc) are missing. Any ideas? Thanks. The form is: class FileUploadForm(forms.Form): title = forms.CharField(max_length=250, required=True) uploader = forms.CharField(max_length=128, required=True) targetfile = forms.FileField(required=True) The URL handler is like this: def upload_file(request): if request.method == 'POST': form = FileUploadForm(request.POST, request.FILES) if form.is_valid(): title = form.cleaned_data['title'] uploader = form.cleaned_data['uploader'] f = request.FILES['targetfile'] return HttpResponseRedirect(reverse('myapp.views.file_uploaded', args=(urllib.quote_plus(title), urllib.quote_plus(uploader), f.size,))) else: form = FileUploadForm() return render_to_response(request, 'uploadFile.htm', { 'form': form, }) The template is: {% block title %}Upload{% endblock %} {% block content %} form enctype=multipart/form-data action=/ui/fupld/ method=POST {{ form.as_table }} input type=submit value=Upload / /form {% endblock %} --~--~-~--~~~---~--~~ 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: How to append to BlobProperty
On Feb 2, 6:02 pm, Will vocalster@gmail.com wrote: Thanks, it finally worked. Following your suggestion, what I did is: 1. in class body, define: content = db.BlobProperty(required=False) # notice required is set to False 2. in __init__(arg1, arg2, ...): self.content = '' Then self.content += src doesn't complain anymore. When accessing, it returns a db.Blog doesn't sound too foreign to me. For now, I just think it as a customized type caster in C++. You can also use the 'default' parameter instead of initialising the 'content' value in the constructor: content = db.BlobProperty(default='') --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---