[web2py] Re: GAE Caching and Views
Thanks everyone for your excellent help! I posted an account of enabling caching with web2py on GAE in a blog post here: http://opensourcebroadcasting.blogspot.com/2011/11/web2py-caching-and-google-app-engine.html All the best, JT
[web2py] GAE Caching and Views
I am using the following decorator: @cache(request.env.path_info, time_expire=5, cache_model=cache.ram) To cache some db queries, however, when I go to deploy this on Google App Engine, I receive a "PicklingError: Can't pickle : attribute lookup __builtin__.function failed" You can see the traceback here: https://gist.github.com/1384892 I have a feeling the error has to do with caching a for loop in a view. You can see the view here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/refresh/thank_yous.html?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11&r=f8cd17ed0367521b8bd726c48ac829e920207c11 You can also see the "thank_yous" function here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/refresh.py?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11&r=f8cd17ed0367521b8bd726c48ac829e920207c11#74 I think the solution lies with creating the view within the function using return response.render() as described in the web2py book here: http://www.web2py.com/book/default/chapter/04?search=cache+view but I'm at a loss for how to do this. Does anyone have any clear examples for using response.render and an html template. Thanks!
[web2py] Updating the property of an upload field on GAE
Within my web2py app, I am using the pygooglechart module to create .png files for QRCodes to display the url to audio files like these: http://publicradioroadtrip.appspot.com/publicradioroadtrip/default/view_collection/383010 This all works great on my local computer, however, when I try to deploy this on Google App Engine, I am getting .png files with sizes of 0 bytes. I have a "story" table with a "qrcode" property (an upload field) which I update programmatically using: myset = db(db.story.id == story_id) myset.update(qrcode = db.story.qrcode.store(opener, filename)) You can see the full code here: http://code.google.com/p/publicradioroadtrip/source/browse/controllers/default.py?r=f8f86339376c671ef77501abf7d9e0ffbc04c07e#83 I realize that you cannot write to the filesystem using GAE, but I was under the impression that there were ways of getting around this restriction by storing the data into an upload field. Does anyone have any ideas on why I would be generating image files with sizes of 0 bytes on GAE and how I might resolve this issue?
[web2py] Re: extending web2py's generic.rss view
Got it! :) stories = {} collection_id=request.args(0) collection = db.collection[collection_id] or redirect(error_page) stories=db(db.story.collection.contains(collection_id)).select(orderby=db.story.title) length=len(stories); scheme = request.env.get('WSGI_URL_SCHEME', 'http').lower() rss = rss2.RSS2(title=collection.title, link = scheme + '://' + request.env.http_host + request.env.path_info, description = collection.description, lastBuildDate = collection.modified_on, items = [ rss2.RSSItem(title = story.title, link = story.url, enclosure = rss2.Enclosure(story.audio_url, 0, 'audio/ mpeg'), description = story.description, comments = 'test', pubDate = story.date) for story in stories]) response.headers['Content-Type']='application/rss+xml' return rss2.dumps(rss)
[web2py] Re: extending web2py's generic.rss view
Rather than use use gluon.serializers.rss, I am using gluon.contrib.rss2 to attempt to add an enclosure to an rss feed: http://code.google.com/p/publicradioroadtrip/source/browse/controllers/default.py?spec=svnd020b7842a1c0a9ba880fb5f94146bbb5ab55524&r=d020b7842a1c0a9ba880fb5f94146bbb5ab55524#590 for story in stories: x = {} enclosure = {'url': story.audio_url, 'length': '0', 'type': 'audio/mpeg'} title = story.title link = story.url # enclosure = story.audio_url description = story.description comments = 'test' created_on = request.now x.update(title=title, link=link, enclosure=enclosure, description=description, comments=comments, created_on=created_on) entries.append(x) rss = rss2.RSS2(title=collection.title, link = scheme + '://' + request.env.http_host + request.env.path_info, description = collection.description, lastBuildDate = request.now, items = [ rss2.RSSItem(title = entry['title'], link = entry['link'], description = entry['description'], comments = entry['comments'], # enclosure = entry['enclosure'], pubDate = request.now) for entry in entries]) response.headers['Content-Type']='application/rss+xml' return rss2.dumps(rss) However, i am running into an issue where I am recieving the error: AttributeError: 'dict' object has no attribute 'publish' http://pastie.textmate.org/1796751 I copied some additional information here. http://pastie.textmate.org/1796758 In looking line 310 in contrib.rss2, it appears that enclosure should contain a dictionary, but I could be wrong: def publish(self, handler): _element(handler, 'enclosure', None, {'url': self.url, 'length': str(self.length), 'type': self.type}) Any suggestions you might have about getting this to work are most appreciated.
[web2py] Re: extending web2py's generic.rss view
No errors. The feed displays, but the enclosure and the comments tags to do not appear. If I call the function without the .rss at the end here is what I get: http://pastie.textmate.org/1782979 Note that the enclosure and discussions fields are present. If I call the same function using the .rss, like this ../default/ view_collection_feed.rss/1 I get this: http://pastie.textmate.org/1782998 Note the lack of enclosure or discussions tags. Thanks for your help! JT On Apr 11, 5:40 am, pbreit wrote: > Enclosures are for including media (audio, video, etc) in a blog post and > should be optional. In general, the built-in gluon RSS stuff should work > without modoficationhttp://pastie.textmate.org/1782979. > > Are you getting an error message? Or does your feed not work in a reader? > From a quick look at your code, it seems OK.
[web2py] extending web2py's generic.rss view
I am trying to include an enclosure using web2py's generic.rss view here is the function I am using in my controller: http://pastie.textmate.org/1781075 however, when I go to http://localhost:8000/myapp/default/view_collection_feed.rss/1 the enclosure (or the simple comment that I am using as a test) do not display. I looked at http://www.web2py.com/book/default/chapter/09?search=rss#RSS and this seems to be in line with the example. I also looked at gluon.contrib.rss2.py and I see that in the RSSItem function, on line 509, there appears to be some anticipation of including an enclosure as part of an item in the feed. Tell me, does anyone have any suggestions on how I might make this work? Am I looking in the wrong place, should I be looking in gluon.serializers.rss? Wait... I think I just answered my question... so I guess now the question is, what is the best way to customize gluon.serializers.rss or how to use gluon.contrib.rss2.py instead.
[web2py] Re: Web2py & GAE integration
Thank you for your comments Jonathan. I have updated the tutorial here: http://opensourcebroadcasting.blogspot.com/2010/04/setting-up-web2py-for-use-with-google.html and here: http://www.web2pyslices.com/main/slices/take_slice/126 to include changing the references to the welcome app, as well as mentioning the benefit of app versioning. On Mar 27, 4:50 pm, Jonathan Lundell wrote: > On Mar 27, 2011, at 3:21 AM, johntynan wrote: > > > > > I had written a tutorial about Setting up web2py for use with Google > > App Engine here: > > >http://opensourcebroadcasting.blogspot.com/2010/04/setting-up-web2py-... > > > Please feel free to have a look and let me know if this helps you. > > > Also, please feel free to let me know if anything has gone out of > > date. > > It looks to me like the instructions will work OK for OS X, with some minor > alterations. /home/joesmith becomes /Users/joesmith. I ended up doing a > parallel installation of Python 2.5 and connecting theGAEapps to that; I'm > not sure if that's necessary, but it was an easy way to shut up one > ofGAE'scomplaints. > > However, OS X (and Windows) users are probably going to use the very > handyGAEGUI application for testing and deployment. > > Finally, it might be worth noting that there might be some other changes > required to app.yaml. The example is set up to deploy the web2py welcome app, > and it tries to keep the upload fairly lightweight, skipping some of the > less-often-used contrib files and the like. > > You might also mention the use ofGAE'sapp versioning, which can be handy for > uploading newer versions for test purposes without making them the default.
[web2py] Re: Web2py & GAE integration
Ahmed, I had written a tutorial about Setting up web2py for use with Google App Engine here: http://opensourcebroadcasting.blogspot.com/2010/04/setting-up-web2py-for-use-with-google.html Please feel free to have a look and let me know if this helps you. Also, please feel free to let me know if anything has gone out of date. On Mar 27, 11:08 am, Mariusz Zieliński wrote: > More details would be useful. I'm no expert on deploying on GAE, > though I succesfully managed to deploy my first app on GAE > yesterday :) I got some problems with app.yaml file as with some rules > from example file in skip_files section there were errors, that it > couldn't find contrib modules. Other than that deployment went without > problems. Also remember to run app on Python 2.5 just like Luther > wrote as that's version which GAE uses currently. > > On 27 Mar, 01:10, Shark wrote: > > > We have troubles in GAE and web2py integration in our graduation > > project > > We tried many tutorials in the web and we fails so I hope you can help > > us with step by step advice > > > Ahmed Sharkawy > > > 4th year engineering faculty > >
[web2py] Re: web2py fabric, pip, virtualenv, virtualenvwrappers deployment scripts
I just rebuilt my current work with web2py on a new laptop (running ubuntu 10.10). Since google app engine's dev server requires python 2.5, I used the following command to install python2.5 within my virtualenv: virtualenv --python=python2.5 --no-site-packages python25_virtualenv However, I am running into issues installing PIL for python25 as well as an issue where I am getting an error with gaehandler.py where it is not finding the pickle module: ImportError: No module named pickle I would be interested in getting familiar with using fabric to automate my installs. I have pasted a copy of the steps that I've taken here: http://pastie.textmate.org/1713385 Any assistance with helping to resolve the issue with PIL or the pickle module, or with getting started with fabric would be great. If I could test and build on the work that everyone has started here, that would be great.
[web2py] Re: Suggestion for the Web2py book regarding importing and exporting data
Hi Kenneth. Would it be possible to share the code you use to export and import as a csv file only the data that belongs to a particular user. Thanks kindly, JT On Jan 17, 12:47 pm, Kenneth Lundström wrote: > Appadmin already has the ability to expoert and import CSV-files. So no > need putting them there. > > In one of my application users has the right to export data as CSV and > even import it back. They don t get all data, only data that belongs to > the user. > > Kenneth > > > > > > > > > In reading the chapter on CSV and Remote Database Syncronization in > > the web2py book, specifically in these sections: > > > 2. Create a controller action to export the database: > > > 3. Create a controller action to import a saved copy of the other > > database and sync records > > > Would it be advisable to mention that these controller actions would > > best be placed within the appadmin as opposed to the app in general? > > This way, a casual user would not be able to export the data.
[web2py] Re: "undefined record" error in appadmin on GAE
Wikus, I enabled the remote api in app.yaml as you suggested. Then, after changing the path slightly in the following command: python appcfg.py create_bulkloader_config --filename=config.yaml -e $em...@gmail.com --url=https://$APP.appspot.com/_ah/remote_api your suggestion for creating a config file worked great! I then set the connector_options for all the types, by replacing the following string in the config.yaml file: # TODO: Choose a connector here: csv, simplexml, etc... with csv I then ran the command: python appcfg.py download_data --filename=$TYPE.csv --kind=$TYPE -- config_file=config.yaml -e $em...@gmail.com --url=https:// $APP.appspot.com/_ah/remote_api I was receiving an error with two similar blocks of the config file, so for the moment, I deleted both properties: # Warning: This property is a duplicate, but with a different type. # TODO: Edit this transform so only one property with this name remains. - property: description external_name: description # Type: Text Stats: 16 properties of this type in this kind. import_transform: db.Text # Warning: This property is a duplicate, but with a different type. # TODO: Edit this transform so only one property with this name remains. - property: description external_name: description # Type: Text Stats: 3 properties of this type in this kind. import_transform: db.Text Off the top of your head, do you have any suggestions about what this warning might mean and how to go about resolving this? After deleting these two sections of the config file, I then was able to successfully run the command. I then modified this command for another table in my app, and it ran fine as well. python appcfg.py download_data --filename=$TYPE.csv --kind=$TYPE -- config_file=config.yaml -e $em...@gmail.com --url=https:// $APP.appspot.com/_ah/remote_api So the idea is to run this command, changing the type for each of the models in my app? Thank you for sharing the script to upload this data, I have not tried to upload the data back to google app engine, but I will give this a try and will write back if I have any questions ;) By the way, this command did not appear to work properly with the latest release of GAE: python appcfg.py download_data -e $em...@gmail.com --application=$APP --url=https://$APP.appspot.com/_ah/remote_api --filename=dump.csv It turns out that the file downloaded, not in csv format, but in squlite 3. Also, the tables did not seem to export as one would expect. There were only two tables in the database, a “bulkloader_database_signature” and a “result” table. At this point, one question comes to mind. If I am able to successfully download and upload data back to my app using the bulkloader, does this mean that I do not have to change my data models to include a uuid and and last_modified date. I think a web2py tutorial about this would be useful. I would be willing to contribute all notes from my experience to document this process. I also have one slightly related comment about the web2py book regarding backing up data from a web2py app hosted on google app engine. Only in the exporting data as csv section does it mention the idea of including a uuid or last_modified date. I think this should be mentioned prominently in the section on google app engine. The idea being that we do not want to say that web2py deploys easily on GAE in one breath, but then not let people know that if their models are not set up correctly, that they run the risk of not being able to easily backup and restore their data. It also may be that the bulkloader is a better alternative to the csv export within web2py’s appadmin, and so adding a uuid to ones models may not necessarily apply... or maybe it should just be good practice to do this. Either way, if there is a way where we could give others a heads up about this issue ahead of time, that would be great. On Jan 12, 12:21 am, Wikus van de Merwe wrote: > To get your data as CSV from a GAE app you need to: > 1) enable remote api in app.yaml > 2) create bulkloader config file:> $GAE_DIR/appcfg.py > create_bulkloader_config --filename=config.yaml -e > > $EMAIL --url=https://$APP.appspot.com/remote_api> rm bulkloader* > > 3) edit config.yaml as needed (mainly export_transform functions for your > fields) > 4) dump specific entity kinds to CSV: > KINDS="abc efgh ijk" > for KIND in $KINDS: > do > rm $KIND.csv > $GAE_DIR/appcfg.py download_data --filename=$KIND.csv --kind=$KIND \ > --config_file=config.yaml -e $EMAIL > --url=https://$APP.appspot.com/remote_api > done > rm bulkloader* > > If you have large entities and the get error messages from the csv module: > 1) put the following into a file e.g. csv_limits.py: > import csv > csv.field_size_limit(1048576) > 2) import the file in config.yaml using: > - import: csv_limit > > You can also try the following to dump everything (not sure if this still > works with new releases): >
[web2py] Schema migration to GAE / Creating a Test Suite
I have a web2py app that has been running very well on Google App Engine (which also contains actual client's data). However, when I first deployed this app, I did not realize that in order to backup and synchronize the data, I needed to include a modified_on and uuid field on all my models. I just changed the data model (on my development server) to include these fields and have tested this on both web2py with sqlite, GAE's dev server and a test app (which is nearly identical to the production app) which is also running on GAE. Additionally, I also exported all the tables from the production app as individual csv files by way of web2py's appadmin. I also see that the web2py book includes an example for a script to export the entire database as one file: http://www.web2py.com/book/default/chapter/06#CSV-and-Remote-Database-Synchronization. I have included these functions in the appadmin for my development apps, and found I am able to export the data for the new models just fine. I would now like to migrate the legacy data into the new model but I am unsure as to the procedure I should follow. Does anyone have any suggestions for how I should best proceed? Massimo, do you know if there are any seasoned programmers who would be willing to field my questions as I work through this process... and would this be a question for the experts4solutions group?
[web2py] Suggestion for the Web2py book regarding importing and exporting data
In reading the chapter on CSV and Remote Database Syncronization in the web2py book, specifically in these sections: 2. Create a controller action to export the database: 3. Create a controller action to import a saved copy of the other database and sync records Would it be advisable to mention that these controller actions would best be placed within the appadmin as opposed to the app in general? This way, a casual user would not be able to export the data.
[web2py] Re: non-string (type list) error in appadmin on GAE
Thanks Jonathan! I just tested this, and yes, you are right. This has been fixed in trunk. On Jan 14, 7:01 am, Jonathan Lundell wrote: > On Jan 13, 2011, at 9:45 PM, johntynan wrote: > > > > > I recently updated my web2py app to version 1.91.6 (along with > > updating GAE to version 1.4.1) and am now able to export csv files > > from the appadmin as I had intended. > > > However, now, if I try to view _any_ of the rows within the tables by > > way of the appadmin, I receive a "TypeError: __str__ returned non- > > string (type list)" message. > > >http://pastie.textmate.org/1458977 > > > Please let me know if there is anything I can do to help further > > identify and resolve this issue. > > This may be fixed in the trunk.
[web2py] Re: Interview with Massimo published
Wonderful! What an excellent profile of Massimo. I also like that there was credit for inspiration for parts of web2py from other frameworks and tools. It's interesting to think of web2py as a "proof of concept"... I might say it's safe to call web2py a proven, but evolving concept. I am grateful for Massimo's and all the other excellent developers who make web2py what it is. And thank you Gilson. Your English, and your choice of questions were very good. If you would like to collaborate on a monthly interview with other developers, I would be glad to help. Best regards, John T. On Jan 14, 12:15 pm, "contatogilson...@gmail.com" wrote: > Sorry if the translation was not very good. I'm studying English right? > Help are welcome:) > _ > *Gilson Filho* > *Web Developer > Blog:* gilson-filho.blogspot.com > *Twitter:* twitter.com/gilsonfilho > > 2011/1/14 Martín Mulone > > > > > > > > > "My main hobby is web2py but my doctor thinks I should get into jogging." > > :) > > > 2011/1/14 VP > > > I am very suspicious that this interview is translated by something > >> like GoogleTranslate from (maybe) Italian. It reads very rough. May > >> not be a good thing. > > >> On Jan 13, 7:36 pm, Bruno Rocha wrote: > >> >http://blog.gilsondev.com/2011/01/13/interview-creator-of-web2py/ > > > -- > > Pablo Martín Mulone (mar...@tecnodoc.com.ar) > >http://www.tecnodoc.com.ar/ > > Paraná, Entre Ríos, Argentina (CP 3100). > > > My blog:http://martin.tecnodoc.com.ar > > Expert4Solution Profile: > >http://www.experts4solutions.com/e4s/default/expert/6
[web2py] non-string (type list) error in appadmin on GAE
I recently updated my web2py app to version 1.91.6 (along with updating GAE to version 1.4.1) and am now able to export csv files from the appadmin as I had intended. However, now, if I try to view _any_ of the rows within the tables by way of the appadmin, I receive a "TypeError: __str__ returned non- string (type list)" message. http://pastie.textmate.org/1458977 Please let me know if there is anything I can do to help further identify and resolve this issue.
[web2py] Re: "undefined record" error in appadmin on GAE
Massimo, I just upgraded to 1.91.6 and yes, the checks that had been put in place did resolve this issue for me. Wikus, thank you for the detailed advice. I have more work to do with this, so your suggestion may come in handy. Thanks everyone!
[web2py] "undefined record" error in appadmin on GAE
I am running a web2py application on GAE. I would like to export different tables as CSV files from my application by way of the appadmin. (My goal is to create both a backup of the data and a test suite with actual data). However, I am receiving the following "undefined record" error when viewing different tables using the appadmin: http://pastie.textmate.org/1444589 I am using web2py Version 1.83.2 and GAE release "1.4.0" Awhile back, Massimo had helped me to understand what appears to be a similar issue "It is trying to represent a reference field with an invalid reference" as described in this thread (although this earlier error was occuring in my application and not in the appadmin): http://groups.google.com/group/web2py/browse_thread/thread/4fbc46b845d19598/e57db67349a60181?lnk=gst&q=%22undefined+record%22#e57db67349a60181 When displaying tables by way of the appadmin is there any "represention of a reference field" which could be causing this issue? I believe I know what could have led to this issue, my client deleted a row from a table. This row is referenced by data in other tables. In thinking about a solution, I could try to re-create the entry in the table by way of the appadmin (I am pretty sure I have the information for this single row in the table from a previous backup). I could also use the Datastore Viewer in GAE's admin console to create or edit the entry. I also wonder if Google's bulk loader tool would be helpful in backing up, editing and restoring the data. Have other people run into this issue and if so, what steps have you taken to arrive at a solution? Also, do you have any recommendations for ways where I could periodically test for this kind of inconsistency? Do you have any suggestions for how I might prevent this issue from happening in the future?
[web2py] Using list:reference in a model on GAE
I have a question about using list:reference in a model on Google App Engine. Here is my model: http://code.google.com/p/publicradioroadtrip/source/browse/models/db_custom.py?spec=svna7a27f086f9519cd6c133493eed55ffd64f9446c&r=a7a27f086f9519cd6c133493eed55ffd64f9446c#33 I am able to add records to the database just fine. The forms appear appropriately and the many to many relationship appears properly in the form. This all works great with web2py development server. However, afterward, when I attempt to display a record using GAE's dev server I receive the error: KeyError: 'substring' http://pastie.textmate.org/1254588 If I comment out the line stories=db(db.story.roadtrip[roadtrip_id]).select(orderby=db.story.title) in my controller here: http://code.google.com/p/publicradioroadtrip/source/browse/controllers/default.py?spec=svn031e8b25da62640a0f1150cd0e43e1dd86b6c975&r=031e8b25da62640a0f1150cd0e43e1dd86b6c975#122 The error seems to go away. Thank you for any advice or suggestions.
[web2py] Re: app engine file paths
Chris, I am troubleshooting this same issue. Try adding this to your model: import sys import os.path site_packages_path = os.path.join(request.env.web2py_path,'site- packages') if sys.path[0] != site_packages_path: sys.path.insert(0, site_packages_path) # print site_packages_path I also added this to my controller: test = str(site_packages_path) return dict(test=test) Let me know if this helps you to troubleshoot this issue. If I find a resolution, I'll write here as well. On Oct 13, 1:11 am, ChrisM wrote: > Hi I am experimening with pyaiml with web2py and app engine. > What is the correct way in web2py to call a file in the site-packages/ > aiml folder I can't get > app engine to find my bot.brn data file which resides here and needs > to be loaded > by pyaiml.? > help appreciated > chrism
[web2py] Re: please help us test new web site
Great work with the new web2py site! I like how well the top and right hand navigation is used and I was glad to discover some resources about web2py that I didn't realize were available. I have one question. Do you think the twitter link should direct people to the twitter search for web2py, as opposed to the web2py twitter account? http://twitter.com/search/web2py Excellent work!
[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'
Thank you for the suggestions, Massimo. I've tried to update the model here: http://code.google.com/p/publicradioroadtrip/source/browse/models/db_custom.py based on your suggestions, and the example app here: http://www.web2py.com/book/default/chapter/03#A-Wiki However, if I use the line: Field('created_by', db.auth_user, default=auth.user_id, writable=False, readable=False), I receive the error: KeyError: 'auth_user' http://pastie.textmate.org/1188236 Tell me, is the issue with the user table related to the issue of making a many-to-many relationship between stories and roadtrips? Best regards, John T. On Sep 29, 6:42 am, mdipierro wrote: > just use > > auth.user_id > > is the same > > created_by should be type=db.auth_user > > On Sep 28, 10:31 pm, johntynan wrote: > > > > > if auth.is_logged_in(): > > me=auth.user.id > > else: > > me=None > > > On Sep 29, 5:19 am, mdipierro wrote: > > > > what is me? Do you use auth? why the type of created_by is a string? > > > > On Sep 28, 10:01 pm, johntynan wrote: > > > > > I would like to create a many-to-many relationship in the following > > > > model, where many "stories" can appear in many different > > > > "roadtrips" (think songs to mixtapes). > > > > > db.define_table( > > > > 'roadtrip', > > > > Field('name'), > > > > Field('description', 'text'), > > > > Field('created_by',default=me,writable=False,readable=False), > > > > > Field('created_on','datetime',default=request.now,writable=False,readable=F > > > > alse) > > > > ) > > > > > db.define_table( > > > > 'story', > > > > Field('user_id', db.users,readable=False,writable=False), > > > > Field('roadtrip_id', db.roadtrip), > > > > Field('story_id', 'integer'), > > > > Field('title'), > > > > Field('latitude'), > > > > Field('longitude'), > > > > Field('comment', 'text'), > > > > Field('created_by',default=me,writable=False,readable=False), > > > > > Field('created_on','datetime',default=request.now,writable=False,readable=F > > > > alse) > > > > ) > > > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road > > > > trip.id','% > > > > (name)s') > > > > > I am able to create a multiple-select element on the CRUD form by > > > > simply adding "multiple=True" to this > > > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road > > > > trip.id','% > > > > (name)s', multiple=True) > > > > > However, I am receiving the error: > > > > > TypeError: int() argument must be a string or a number, not 'list' > > > > > I posted the traceback here:http://pastie.textmate.org/1187996 > > > > > (as an aside, is there a better way to post a traceback that is more > > > > readable, should I just copy/paste from the html error page, as > > > > opposed to the logged file under errors?)
[web2py] Re: Many to Many TypeError: int() argument must be a string or a number, not 'list'
if auth.is_logged_in(): me=auth.user.id else: me=None On Sep 29, 5:19 am, mdipierro wrote: > what is me? Do you use auth? why the type of created_by is a string? > > On Sep 28, 10:01 pm, johntynan wrote: > > > > > I would like to create a many-to-many relationship in the following > > model, where many "stories" can appear in many different > > "roadtrips" (think songs to mixtapes). > > > db.define_table( > > 'roadtrip', > > Field('name'), > > Field('description', 'text'), > > Field('created_by',default=me,writable=False,readable=False), > > > Field('created_on','datetime',default=request.now,writable=False,readable=F > > alse) > > ) > > > db.define_table( > > 'story', > > Field('user_id', db.users,readable=False,writable=False), > > Field('roadtrip_id', db.roadtrip), > > Field('story_id', 'integer'), > > Field('title'), > > Field('latitude'), > > Field('longitude'), > > Field('comment', 'text'), > > Field('created_by',default=me,writable=False,readable=False), > > > Field('created_on','datetime',default=request.now,writable=False,readable=F > > alse) > > ) > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road > > trip.id','% > > (name)s') > > > I am able to create a multiple-select element on the CRUD form by > > simply adding "multiple=True" to this > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road > > trip.id','% > > (name)s', multiple=True) > > > However, I am receiving the error: > > > TypeError: int() argument must be a string or a number, not 'list' > > > I posted the traceback here:http://pastie.textmate.org/1187996 > > > (as an aside, is there a better way to post a traceback that is more > > readable, should I just copy/paste from the html error page, as > > opposed to the logged file under errors?)
[web2py] Many to Many TypeError: int() argument must be a string or a number, not 'list'
I would like to create a many-to-many relationship in the following model, where many "stories" can appear in many different "roadtrips" (think songs to mixtapes). db.define_table( 'roadtrip', Field('name'), Field('description', 'text'), Field('created_by',default=me,writable=False,readable=False), Field('created_on','datetime',default=request.now,writable=False,readable=False) ) db.define_table( 'story', Field('user_id', db.users,readable=False,writable=False), Field('roadtrip_id', db.roadtrip), Field('story_id', 'integer'), Field('title'), Field('latitude'), Field('longitude'), Field('comment', 'text'), Field('created_by',default=me,writable=False,readable=False), Field('created_on','datetime',default=request.now,writable=False,readable=False) ) db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'roadtrip.id','% (name)s') I am able to create a multiple-select element on the CRUD form by simply adding "multiple=True" to this db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'roadtrip.id','% (name)s', multiple=True) However, I am receiving the error: TypeError: int() argument must be a string or a number, not 'list' I posted the traceback here: http://pastie.textmate.org/1187996 (as an aside, is there a better way to post a traceback that is more readable, should I just copy/paste from the html error page, as opposed to the logged file under errors?)
[web2py] Re: Why Django Sucks (slides)
Nice mention of web2py about the application object. I've run into a snag with web2py by not knowing I should have have UUID primary keys... Is this something that could be handled at the web2py level and not within the app/model itself? Would this be similar to what the author means by late binding FKs? On Sep 9, 1:13 pm, Adi wrote: > http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fi... > > It would be interesting to head community's thoughts on some of the > problems there. :)
[web2py] Re: Exporting data from GAE BigTable
Bruno, Have you tried using web2py's appadmin for your particular app: https://yourgaeappname.appspot.com/yourweb2pyappname/appadmin I am working towards backing up my app running on GAE, in the process, one of the developers I am working with pointed out the following: "The created_by fields in your database do not reference the auth.user table; they should have as their type auth.user (they do default to the current auth.user.id but this is not sufficient).. Setting up these references is important for the sake of backing up and restoring to the App Engine via web2py. Without these references in place, the appengine will re-generate the userids, should you download and upload a full backup using the method recommended by Massimo (see the web2py book for details)." With that in mind, I am making sure to read "Exporting and Importing Data" here: http://web2py.com/book/default/chapter/06#Exporting-and-Importing-Data As I work this out, I'd be glad to share my experiences here. On Aug 2, 4:55 am, Bruno Rocha wrote: > Hello, I'm writing a lot of text using cube2py running on GoogleAppEngine. > All content written in cube2py is stored in the database, and I need to do a > backup. > > Is there a way to use DAL to export records in a given table? > I know it may be possible to do this by creating action.json or action.xml, > table by table. > But is there any easier way, someone already did? > > {{=thanks}} > -- > > http://rochacbruno.com.br
[web2py] Re: python web console
You can also try the following from the command line: # in linux python web2py.py -S yourappname -M # in windows web2py.exe -S yourappname -M On Jun 6, 4:15 pm, Tomas Pelka wrote: > Hi all, > if I'm correct web2py had a web (java script) python console. I can't > find it now, is it still included? > > Thanks > > -- > Tomas Pelka
[web2py] Re: "undefined record" error on GAE
In case it helps, I am using web2py Version 1.77.3 and GAE release: "1.3.3" On Apr 26, 12:45 am, johntynan wrote: > I am receiving the following "undefined record" error in web2py > running on GAE (and not in development): > > http://pastie.textmate.org/934992 > > I tried removing the "orderby" grouping here: > > http://bit.ly/dxeRPo > > But the error persists. Does anyone have any suggestions for > troubleshooting this issue? > -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] "undefined record" error on GAE
I am receiving the following "undefined record" error in web2py running on GAE (and not in development): http://pastie.textmate.org/934992 I tried removing the "orderby" grouping here: http://bit.ly/dxeRPo But the error persists. Does anyone have any suggestions for troubleshooting this issue? -- Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en
[web2py] Setting up web2py for use with Google App Engine
I just wrote a blog post about setting up web2py for use with Google App Engine: http://opensourcebroadcasting.blogspot.com/2010/04/setting-up-web2py-for-use-with-google.html I hope you find this useful. Any comments or feedback are welcome. -- To unsubscribe, reply using "remove me" as the subject.
[web2py] Paid/Preferred Users and Google App Engine
Thankfully, I have received a decent amount of interest in the web2py app that I've launched on Google App Engine here: http://opensourcebroadcasting.appspot.com/pledgedrives Now, my question is what is the best way to distinguish between Paid/ Preferred users from people who are casually checking out the app. As it stands, all users can incur an unlimited of page views / bandwidth / computing time (short of the billing threshold I've set up within the app engine billing console). Would one approach be to have a session variable count the number of page views per day across the entire app, and limit its use for unpaid users? Could something like this be done without modifying the table_user table? What are the best, proven approaches, that people have used to differentiate casual users from people who have paid for a service using web2py? Thanks kindly, JT -- 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.
[web2py] Re: web2py beautification
While I admire and would welcome having the option of using 960 grid templates, Massimo's suggestion of incorporating jquery's themeroller into the welcome app sounds equally interesting. I'm not much of a designer, but I value the ideal of a tableless design. I'd be willing to try to free up some time to help implement these ideas over the coming weeks. On Mar 14, 4:10 am, mdipierro wrote: > Ideally if we could make the welcome app use or at leat friendly > withhttp://jqueryui.com/themeroller/it would be nice. > > On Mar 13, 9:35 pm, villas wrote:> On Mar 13, 4:05 pm, > Mengu wrote: > > > > i still recommend oocss as css framework. a lot easier, a lot better. > > > @Aure. > > Sencss. Good styles, but I don't think it helps with the tableless > > layout? > > BlueTrip. Great looking framework, but like Blueprint, it's a > > comprehensive grid-based which is probably best used as a plug-in. > > > @Mengu. oocss.org > > I haven't had much time to research every option, but I am inclined > > to agree. It seems excellent and I like the fluidity of the formats > > that I looked at. I don't know whether it would be simple enough to > > include with Web2py; it would be a good case if we find it gives > > access to templates. This is probably the kind of thing I would > > personally go for, but is it right everyone else? Who knows! Those > > with a little time and enough interest might wish to also give it a > > quick look and make a brief comment. In any case, I also think it is > > nice to be aware of this project even if it is not right for Web2py. > > Best wishes, D -- 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.
[web2py] Re: web2py rocks!
mikech, You are right, the default orange is a great color; especially when playing off the brown (#3E3735) I especially like that it did not take a lot of changes in the stylesheet: http://bit.ly/cKDPZf Thanks! On Feb 3, 10:10 am, mikech wrote: > Orange is such a nice color :) > > On Feb 2, 8:08 pm, johntynan wrote: > > > > > Thanks! Here is some additional information: > > >http://opensourcebroadcasting.blogspot.com/2010/02/introducing-pledge... > > > Also, between us here on the web2py group, here is the link to create > > an account and set up your own pledge drive: > > >http://opensourcebroadcasting.appspot.com/pledgedrives > > > Please note: For some reason, GAE boots you off after you submit each > > of the first three forms. After that, you're all set. > > > I will have some questions in the near future on how to ensure that > > people who use the app are paid clients and that we don't drive up the > > cpu / bandwidth costs (by verifying users before they can make > > extensive use of the app?). As well as some additional questions and > > goals for the project which should be beneficial to other web2py > > users. > > > But here it is, in its current state. > > > Look forward to hearing your input! > > > On Feb 2, 4:48 pm, mdipierro wrote: > > > > Congratulations! any link we can look at? > > > > On Feb 2, 11:29 am, johntynan wrote: > > > > > We just had a successful launch of my first web2py app on Google App > > > > Engine! > > > > > KUNC, a public radio station in Greeley, Colorado, was the first > > > > client to use the app, and they offered a lot of suggestions and > > > > refinements on the work. > > > > > Using, GAE, it only cost us $8.50 to pound away at the app for five > > > > days. > > > > > I could not be happier with web2py. In particular, I the DAL is > > > > great! There were many fine tunings to the data model right up until > > > > launch, and web2py's DAL managed these these migration issues easily. > > > > > I will have more questions for the group about web2py, and more ways > > > > that I hope to give back to the web2py community in the future, but > > > > for right now, I want thank everyone who helped answer my questions > > > > over the previous three months and to everyone whose work makes web2py > > > > the excellent web application framework that it is! -- 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.
[web2py] Re: web2py rocks!
Thanks! Here is some additional information: http://opensourcebroadcasting.blogspot.com/2010/02/introducing-pledge-drive-tracker.html Also, between us here on the web2py group, here is the link to create an account and set up your own pledge drive: http://opensourcebroadcasting.appspot.com/pledgedrives Please note: For some reason, GAE boots you off after you submit each of the first three forms. After that, you're all set. I will have some questions in the near future on how to ensure that people who use the app are paid clients and that we don't drive up the cpu / bandwidth costs (by verifying users before they can make extensive use of the app?). As well as some additional questions and goals for the project which should be beneficial to other web2py users. But here it is, in its current state. Look forward to hearing your input! On Feb 2, 4:48 pm, mdipierro wrote: > Congratulations! any link we can look at? > > On Feb 2, 11:29 am, johntynan wrote: > > > > > We just had a successful launch of my first web2py app on Google App > > Engine! > > > KUNC, a public radio station in Greeley, Colorado, was the first > > client to use the app, and they offered a lot of suggestions and > > refinements on the work. > > > Using, GAE, it only cost us $8.50 to pound away at the app for five > > days. > > > I could not be happier with web2py. In particular, I the DAL is > > great! There were many fine tunings to the data model right up until > > launch, and web2py's DAL managed these these migration issues easily. > > > I will have more questions for the group about web2py, and more ways > > that I hope to give back to the web2py community in the future, but > > for right now, I want thank everyone who helped answer my questions > > over the previous three months and to everyone whose work makes web2py > > the excellent web application framework that it is! -- 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.
[web2py] web2py rocks!
We just had a successful launch of my first web2py app on Google App Engine! KUNC, a public radio station in Greeley, Colorado, was the first client to use the app, and they offered a lot of suggestions and refinements on the work. Using, GAE, it only cost us $8.50 to pound away at the app for five days. I could not be happier with web2py. In particular, I the DAL is great! There were many fine tunings to the data model right up until launch, and web2py's DAL managed these these migration issues easily. I will have more questions for the group about web2py, and more ways that I hope to give back to the web2py community in the future, but for right now, I want thank everyone who helped answer my questions over the previous three months and to everyone whose work makes web2py the excellent web application framework that it is! -- 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.
[web2py] Limiting the Contents of a Select Tag
I have a class called create_challenge here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/default.py?spec=svn74b5784e200a53af235d6ea9abc83359e0ce3196&r=74b5784e200a53af235d6ea9abc83359e0ce3196#415 This model for the challenge has a foreign key to the person table. In the resulting form to create a challenge, I would like the contents of the select tag to only contain a list of people who were created by the current user. I believe the query for this selection might look like this: persons=db(db.person.created_by==auth.user.id).select (orderby=db.person.name) However, I'm unsure how to work this into the form. Or, would I define this in the model instead? Any suggestions that you have would be appreciated. -- 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.
[web2py] Re: GAE AttributeError
Thanks Massimo! This works perfectly. I have one quick follow up question. When using the following code: form=SQLFORM(db.table) if FORM.accepts(form,request.vars): session.form_vars=form.vars as you had suggested here: http://groups.google.com/group/web2py/browse_thread/thread/b3508f4a9b16d279/408bf5afdad3d92b?lnk=gst&q=johntynan#408bf5afdad3d92b I am able to add the form variables to a session. However, I would like to now save the form.vars in a session variable as a list of dictionaries as well. Just for grins I tried session.form_vars=list(dict(form.vars)) do you have any suggestions for how I might get this this to work? On Jan 5, 7:44 am, mdipierro wrote: > The problem is here: > > organization = db > (db.organization.id==session.organization_id).select() > session.organization = organization > > you are storing a Rows object in the session and that should not be > done. > we manage to make it work (partially) without GAE but the retrieved > object is not the same as the original. > it does not work on GAE because marshal.dumps does not exist on GAE. > If you really need to do this try: > > organization = db > (db.organization.id==session.organization_id).select() > session.organization = organization.as_list() > > it will store the Rows as a list of normal dictionaries. > > On Jan 5, 4:57 am,johntynan wrote: > > > I have a web2py app that runs well under web2py, as well as within the > > GAE development server, however, after updating the app, and then > > testing this on the production server here: > > >http://opensourcebroadcasting.appspot.com/pledgedrives/ > > > When submitting one specific "session_organization_id_form" > > > I receive the following: > > > AttributeError: 'module' object has no attribute 'dumps' > > > For the full traceback, see: > > >http://pastie.textmate.org/767257.txt > > > The code for the form itself can be found here: > > >http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive... > > > Any suggestions on what exactly is failing and how this could be > > resolved is appreciated. > > > Thanks! > > -- 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.
[web2py:38338] GAE AttributeError
I have a web2py app that runs well under web2py, as well as within the GAE development server, however, after updating the app, and then testing this on the production server here: http://opensourcebroadcasting.appspot.com/pledgedrives/ When submitting one specific "session_organization_id_form" I receive the following: AttributeError: 'module' object has no attribute 'dumps' For the full traceback, see: http://pastie.textmate.org/767257.txt The code for the form itself can be found here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/default.py#84\ Any suggestions on what exactly is failing and how this could be resolved is appreciated. Thanks! -- 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.
[web2py:37092] Re: Saving Session Variables via a Form
Thank you for your suggestions. At this point, I am not trying to create a record in the database at the same time that I am setting a session variable. What I would like to do is set session.organization_id (and possibly session.organization_name) by way of a selection list. I am able to get this form to *almost* work, see session_organization_id_form here: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/default.py?spec=svna6553088a4eaf244a425c4b0a367ffd46edf8b54&r=a6553088a4eaf244a425c4b0a367ffd46edf8b54#78 and http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/default/session_organization_id_form.html?spec=svna6553088a4eaf244a425c4b0a367ffd46edf8b54&r=a6553088a4eaf244a425c4b0a367ffd46edf8b54 However, what I would like to render is: {{=organization.name}} For each row in the organization table. And what I am getting is a dictionary for each row in the organization table. Do you have any suggestions for the syntax I would use to define the value and text for each select tag in the form? On Nov 27, 6:37 pm, mdipierro wrote: > ERRATA: > > Do not use crud.form > > use instead > > form=SQLFORM(db.table) > if FORM.accepts(form,request.vars): > session.form_vars=form.vars > > On Nov 27, 7:36 pm, mdipierro wrote: > > > Do not use crud.form > > > use instead > > > form=SQLFORM(db.table) > > if FORM.accepts(form,request.vars): > > session.form_vars=request.vars > > > On Nov 27, 6:30 pm,johntynan wrote: > > > > I have a question about saving the values from a crud form as session > > > variables (as opposed to updating a record in the database). > > > > Do you know where there might be a good example for doing this? > > > > To get started, I riffed off of the thread here: > > > >http://groups.google.com/group/web2py/browse_thread/thread/5343d94b45... > > > > And then modified the class set_cookies() that I had started in > > > controllers/default.py > > > > here: > > > >http://code.google.com/p/django-pledgedrive/source/browse/trunk/pledg... > > > > and in the simple session_form.html here: > > > >http://code.google.com/p/django-pledgedrive/source/browse/trunk/pledg... > > > > Thanks for any suggestions you might have! > > > > John T. > > -- 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.
[web2py:36909] Re: testing web2py's jsonrpc service using the python interactive shell
Perfect! This worked beautifully: s = jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/ call/jsonrpc",verbose=1) On Dec 8, 12:48 pm, omicron wrote: > Two things to verifiy : > 1/ Try this : s = jsonrpclib.ServerProxy("http://localhost:8000/ > pledgedrives/default/call/jsonrpc",verbose=1) > 2/ The "call" function is defined ? > def call(): > session.forget() > return service() > > On 8 déc, 19:58, johntynan wrote: > > > I am looking in the admin and do not see any tickets for the error. > > So, web2py is not getting the request. > > > On Dec 8, 11:19 am, mdipierro wrote: > > > > check the tickets in admin and see if web2py is getting the request > > > and what is the error > > > > On Dec 8, 10:10 am, johntynan wrote: > > > > > One note. I also receive the same error when using this url: > > > > > s = jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/ > > > > service/",verbose=1) > > > > > On Dec 8, 9:07 am, johntynan wrote: > > > > > > I have a question about testing web2py's jsonrpc service using the > > > > > python interactive shell. > > > > > > In looking at the web2py pyjamas todo application as a starting point, > > > > > and noticed the following code in the tests folder: > > > > > > import jsonrpclib > > > > > > s = jsonrpclib.ServerProxy("http://localhost:8000/todo/default/ > > > > > service", > > > > > verbose=1) > > > > > reply = s.getTasks() > > > > > print reply > > > > > > I found that I needed to download Matt Harrison's jsonrpclib > > > > > fromhttp://lkcl.net/jsonrpclib.tgzandplacethejsonrpclib.pyfile > > > > > somewhere within my python path > > > > > > After that, I decorated a class in my web2py app with > > > > > @service.jsonrpc: > > > > > >http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive... > > > > > > Then, I tried to connect to the web2py jsonrpc service from within the > > > > > python shell using this script: > > > > > > >>> s = > > > > > >>> jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/call/",verbose=1) > > > > > >>> reply = s.service_pledgedrive_pledges('1') > > > > > > Only I receive the following error: > > > > > > connect: (localhost, 8000) > > > > > send: 'POST /pledgedrives/default/call/ HTTP/1.0\r\nHost: localhost: > > > > > 8000\r\nUser-Agent: jsonlib.py/0.0.1 (by matt harrison)\r\nContent- > > > > > Type: text/xml\r\nContent-Length: 67\r\n\r\n' > > > > > send: '{"params": ["1"], "method": "service_pledgedrive_pledges", > > > > > "id": 6}' > > > > > reply: 'HTTP/1.1 400 BAD REQUEST\r\n' > > > > > header: Set-Cookie: > > > > > session_id_pledgedrives=127-0-0-1-1bb105e6-9359-4a9e- > > > > > a776-6915963c26ed; Path=/ > > > > > header: Content-Length: 534 > > > > > header: Content-Type: text/html; charset=UTF-8 > > > > > header: Date: Tue, 08 Dec 2009 14:54:13 GMT > > > > > header: Server: CherryPy/3.2.0beta WSGI Server > > > > > Traceback (most recent call last): > > > > > File "", line 1, in > > > > > File "jsonrpclib.py", line 136, in __call__ > > > > > return self.__send(self.__name, args) > > > > > File "jsonrpclib.py", line 382, in __request > > > > > verbose=self.__verbose > > > > > File "jsonrpclib.py", line 179, in request > > > > > response > > > > > jsonrpclib.ProtocolError: > > > > pledgedrives/default/call/: 400 BAD REQUEST> > > > > > > Is it possible to tell if I am using the wrong syntax when calling > > > > > jsonrpclib.ServerProxy or else where in my script? > > -- 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.
[web2py:36802] Re: testing web2py's jsonrpc service using the python interactive shell
I am looking in the admin and do not see any tickets for the error. So, web2py is not getting the request. On Dec 8, 11:19 am, mdipierro wrote: > check the tickets in admin and see if web2py is getting the request > and what is the error > > On Dec 8, 10:10 am, johntynan wrote: > > > One note. I also receive the same error when using this url: > > > s = jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/ > > service/",verbose=1) > > > On Dec 8, 9:07 am, johntynan wrote: > > > > I have a question about testing web2py's jsonrpc service using the > > > python interactive shell. > > > > In looking at the web2py pyjamas todo application as a starting point, > > > and noticed the following code in the tests folder: > > > > import jsonrpclib > > > > s = jsonrpclib.ServerProxy("http://localhost:8000/todo/default/ > > > service", > > > verbose=1) > > > reply = s.getTasks() > > > print reply > > > > I found that I needed to download Matt Harrison's jsonrpclib > > > fromhttp://lkcl.net/jsonrpclib.tgzandplacethe jsonrpclib.py file > > > somewhere within my python path > > > > After that, I decorated a class in my web2py app with > > > @service.jsonrpc: > > > >http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive... > > > > Then, I tried to connect to the web2py jsonrpc service from within the > > > python shell using this script: > > > > >>> s = > > > >>> jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/call/",verbose=1) > > > >>> reply = s.service_pledgedrive_pledges('1') > > > > Only I receive the following error: > > > > connect: (localhost, 8000) > > > send: 'POST /pledgedrives/default/call/ HTTP/1.0\r\nHost: localhost: > > > 8000\r\nUser-Agent: jsonlib.py/0.0.1 (by matt harrison)\r\nContent- > > > Type: text/xml\r\nContent-Length: 67\r\n\r\n' > > > send: '{"params": ["1"], "method": "service_pledgedrive_pledges", > > > "id": 6}' > > > reply: 'HTTP/1.1 400 BAD REQUEST\r\n' > > > header: Set-Cookie: > > > session_id_pledgedrives=127-0-0-1-1bb105e6-9359-4a9e- > > > a776-6915963c26ed; Path=/ > > > header: Content-Length: 534 > > > header: Content-Type: text/html; charset=UTF-8 > > > header: Date: Tue, 08 Dec 2009 14:54:13 GMT > > > header: Server: CherryPy/3.2.0beta WSGI Server > > > Traceback (most recent call last): > > > File "", line 1, in > > > File "jsonrpclib.py", line 136, in __call__ > > > return self.__send(self.__name, args) > > > File "jsonrpclib.py", line 382, in __request > > > verbose=self.__verbose > > > File "jsonrpclib.py", line 179, in request > > > response > > > jsonrpclib.ProtocolError: > > pledgedrives/default/call/: 400 BAD REQUEST> > > > > Is it possible to tell if I am using the wrong syntax when calling > > > jsonrpclib.ServerProxy or else where in my script? > > -- 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.
[web2py:36788] Re: testing web2py's jsonrpc service using the python interactive shell
One note. I also receive the same error when using this url: s = jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/ service/",verbose=1) On Dec 8, 9:07 am, johntynan wrote: > I have a question about testing web2py's jsonrpc service using the > python interactive shell. > > In looking at the web2py pyjamas todo application as a starting point, > and noticed the following code in the tests folder: > > import jsonrpclib > > s = jsonrpclib.ServerProxy("http://localhost:8000/todo/default/ > service", > verbose=1) > reply = s.getTasks() > print reply > > I found that I needed to download Matt Harrison's jsonrpclib > fromhttp://lkcl.net/jsonrpclib.tgzand place the jsonrpclib.py file > somewhere within my python path > > After that, I decorated a class in my web2py app with > @service.jsonrpc: > > http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive... > > Then, I tried to connect to the web2py jsonrpc service from within the > python shell using this script: > > >>> s = > >>> jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/call/",verbose=1) > >>> reply = s.service_pledgedrive_pledges('1') > > Only I receive the following error: > > connect: (localhost, 8000) > send: 'POST /pledgedrives/default/call/ HTTP/1.0\r\nHost: localhost: > 8000\r\nUser-Agent: jsonlib.py/0.0.1 (by matt harrison)\r\nContent- > Type: text/xml\r\nContent-Length: 67\r\n\r\n' > send: '{"params": ["1"], "method": "service_pledgedrive_pledges", > "id": 6}' > reply: 'HTTP/1.1 400 BAD REQUEST\r\n' > header: Set-Cookie: > session_id_pledgedrives=127-0-0-1-1bb105e6-9359-4a9e- > a776-6915963c26ed; Path=/ > header: Content-Length: 534 > header: Content-Type: text/html; charset=UTF-8 > header: Date: Tue, 08 Dec 2009 14:54:13 GMT > header: Server: CherryPy/3.2.0beta WSGI Server > Traceback (most recent call last): > File "", line 1, in > File "jsonrpclib.py", line 136, in __call__ > return self.__send(self.__name, args) > File "jsonrpclib.py", line 382, in __request > verbose=self.__verbose > File "jsonrpclib.py", line 179, in request > response > jsonrpclib.ProtocolError: pledgedrives/default/call/: 400 BAD REQUEST> > > Is it possible to tell if I am using the wrong syntax when calling > jsonrpclib.ServerProxy or else where in my script? -- 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.
[web2py:36786] testing web2py's jsonrpc service using the python interactive shell
I have a question about testing web2py's jsonrpc service using the python interactive shell. In looking at the web2py pyjamas todo application as a starting point, and noticed the following code in the tests folder: import jsonrpclib s = jsonrpclib.ServerProxy("http://localhost:8000/todo/default/ service", verbose=1) reply = s.getTasks() print reply I found that I needed to download Matt Harrison's jsonrpclib from http://lkcl.net/jsonrpclib.tgz and place the jsonrpclib.py file somewhere within my python path After that, I decorated a class in my web2py app with @service.jsonrpc: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/default.py?spec=svnd55364624d719fd03a6b7dfb01997fe88253c3d2&r=d55364624d719fd03a6b7dfb01997fe88253c3d2#451 Then, I tried to connect to the web2py jsonrpc service from within the python shell using this script: >>> s = >>> jsonrpclib.ServerProxy("http://localhost:8000/pledgedrives/default/call/",verbose=1) >>> reply = s.service_pledgedrive_pledges('1') Only I receive the following error: connect: (localhost, 8000) send: 'POST /pledgedrives/default/call/ HTTP/1.0\r\nHost: localhost: 8000\r\nUser-Agent: jsonlib.py/0.0.1 (by matt harrison)\r\nContent- Type: text/xml\r\nContent-Length: 67\r\n\r\n' send: '{"params": ["1"], "method": "service_pledgedrive_pledges", "id": 6}' reply: 'HTTP/1.1 400 BAD REQUEST\r\n' header: Set-Cookie: session_id_pledgedrives=127-0-0-1-1bb105e6-9359-4a9e- a776-6915963c26ed; Path=/ header: Content-Length: 534 header: Content-Type: text/html; charset=UTF-8 header: Date: Tue, 08 Dec 2009 14:54:13 GMT header: Server: CherryPy/3.2.0beta WSGI Server Traceback (most recent call last): File "", line 1, in File "jsonrpclib.py", line 136, in __call__ return self.__send(self.__name, args) File "jsonrpclib.py", line 382, in __request verbose=self.__verbose File "jsonrpclib.py", line 179, in request response jsonrpclib.ProtocolError: Is it possible to tell if I am using the wrong syntax when calling jsonrpclib.ServerProxy or else where in my script? -- 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.
[web2py:36635] Re: Finding the Sum for a Specific Field in a Query
Thanks everyone. This does get me the results that I was looking for. Seeing as I'd like to deploy this on GAE, I wondered if it might be advisable to take this as an opportunity to learn how to use pyjamas and pass along some of the work to javascript in the browser? With that in mind, I was able to add a class to give me all the pledges for a single pledge drive as a list of dictionaries: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/default.py#451 I was able to test this in the python interactive shell using: import xmlrpclib s = xmlrpclib.ServerProxy('http://localhost:8000/pledgedrives/default/ call/xmlrpc/') s.service_pledgedrive_pledges('1') Do you know off-hand if pyjamas support xmlrpc, or will I have to do this using jsonrpc? Do you think this approach is a good tact to take or, from your experience, do you think that I am heading down a blind alley? Thanks! JT On Dec 4, 10:12 am, mdipierro wrote: > I think this should do it: > > r = db(db.pledge.pledgedrive==pledgedrive_id).select > (db.pledge.amount.sum()) > total=r[0]._extra[db.pledge.amount.sum()] > > It will not work on GAE. > > On Dec 4, 10:58 am, johntynan wrote: > > > I have a question about finding the sum of a specific field across the > > results of an entire query > > > While this statement will return the total number (len) of records > > returned in a query: > > pledgedrive_total_pledges = len(db > > (db.pledge.pledgedrive==pledgedrive_id).select()) > > > I would like to get the total dollars (sum) of the "amount" field that > > each of these records contains. > > > Thank you for your help. > > > JT > > > P.S. As an extra bonus, I am most pleased to discover the jquery ajax/ > > load script. I may be saying goodbye to framesets for good: > > >http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive... > > -- 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.
[web2py:36506] Finding the Sum for a Specific Field in a Query
I have a question about finding the sum of a specific field across the results of an entire query While this statement will return the total number (len) of records returned in a query: pledgedrive_total_pledges = len(db (db.pledge.pledgedrive==pledgedrive_id).select()) I would like to get the total dollars (sum) of the "amount" field that each of these records contains. Thank you for your help. JT P.S. As an extra bonus, I am most pleased to discover the jquery ajax/ load script. I may be saying goodbye to framesets for good: http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/default/report_mini_pledgedrive_goal.html?r=7a806e6a8ea0151f9c0977eb7599365f9ca9d48a -- 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.
[web2py:36101] Saving Session Variables via a Form
I have a question about saving the values from a crud form as session variables (as opposed to updating a record in the database). Do you know where there might be a good example for doing this? To get started, I riffed off of the thread here: http://groups.google.com/group/web2py/browse_thread/thread/5343d94b45a602db/3197cc54e027f5bd?lnk=gst&q=session+variable#3197cc54e027f5bd And then modified the class set_cookies() that I had started in controllers/default.py here: http://code.google.com/p/django-pledgedrive/source/browse/trunk/pledgedrives/controllers/default.py?spec=svn38&r=38#81 and in the simple session_form.html here: http://code.google.com/p/django-pledgedrive/source/browse/trunk/pledgedrives/views/default/session_form.html?r=38 Thanks for any suggestions you might have! John T. -- 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.