[web2py] Re: how to create an album and view photos belonging to that album
Thanks! Dave, been using web2py since 2010 :) however not been active in coding from last few months.. (kinda lost touch) I'll get over it quickly though. Rahul On Sunday, June 22, 2014 12:09:10 AM UTC+5:30, Dave S wrote: > > > > On Friday, June 20, 2014 1:14:59 AM UTC-7, Rahul wrote: >> >> Hi Dave, All, >> I found a solution - It was easy - >> wrote a new function that takes a parameter, called it in the view and it >> redirects to the required page. >> > > Glad you got it going. You're moving ahead faster than I am :-) > > /dps > > >> >> query = (db.fotoz.album_name == "%s" % request.args(0)) >> >> >> >> and have this >> View Album >> >> >> in view. >> >> That sends the argument to this function and displays the album. The only >> issue is with spaces in album names that dont work. But I would find a >> workaround over it. >> >> We can consider this thread closed. Thanks Everyone. >> >> Cheers, Rahul >> >> A few threads that helped... - >> https://groups.google.com/forum/#!topic/web2py/WJtJ-QDemTM >> >> http://stackoverflow.com/questions/9328126/web2py-connecting-to-the-correct-controller >> https://groups.google.com/forum/#!topic/web2py/ICo5-yFgxmc >> >> >> >> >> On Friday, June 20, 2014 10:24:42 AM UTC+5:30, Rahul wrote: >>> >>> Thanks! for replying Dave. While I am open to suggestions, I plan to >>> redirect the request such that as soon as the user clicks on any album >>> thumbnail - he gets redirected to a page (perhaps viewalbum.html) where all >>> images belonging to a particular album are listed. >>> >>> Thanks, Rahul. >>> >>> On Friday, June 20, 2014 12:31:14 AM UTC+5:30, Dave S wrote: On Wednesday, June 18, 2014 1:50:09 AM UTC-7, Rahul wrote: > > > Hi All, > I am writing an image gallery in my app. I am stuck up here - > I want to display images that belong to a particular album when I > select that album in the view. Although I am able to display albums in > the > view, but cannot proceed further to display images belonging to that > particular albums after clicking the album (from the view). > > here are the table in *db.py* - > db.define_table('photoalbum', > Field('reguser_id'), > Field('album_name'), > Field('short_description'), > ) > > db.define_table(photos', > Field('reguser_id'), > Field('caption'), > Field('category', requires=IS_IN_SET(pix_cat)), > Field('description', 'text'), > Field('upload_photo', 'upload' , uploadfolder=request.folder + ' > static/uploads', default=0, autodelete=True,), > Field('album_name', requires=IS_IN_SET(albums)), > ) > > I would think you want the last line to be a reference, like > Field('album_name', > 'reference photoalbum'); > > Controller - *default.py * > > def myalbums(): > > ## selects all albums > allalbums = db(db.photoalbum.reguser_id == session. > logged_in_user_id). select(db.photoalbum.album_name) > > # selects descriptions for all albums > alldescriptions = db(db.photoalbum.reguser_id == session. > logged_in_user_id). select(db.photoalbum.short_description) > > ## selects photos > allimages = db(db.photos.reguser_id == session.logged_in_user_id). > select(db.photos.upload_photo, db.photos.caption, db.photos. > description, cache=(cache.ram,20)) > > return dict(allalbums=allalbums, alldescriptions=alldescriptions, > allimages=allimages) > > > Code in the view *myalbum.html* > > > {{for i in range(len(allalbums)):}} > > > > > > > > {{=(A(IMG(_src=URL(r=request,c='static\images',f='vimage.jpg' > )),_href=URL (r=request,c='default', f='myalbums', args=[allalbums[i]. > album_name]) ))}} > > > > {{=allalbums[i].album_name}} > {{=alldescriptions[i].short_description}} > > > > > > > >{{pass}} >{{pass}} > > > Here I can get the album names in the view but when I click on it, it > should query all the photos belonging to that particular (as specified in > args) albumname and show all images in another page or a carousel that I > would create. > > Do you want a redirect, or to have multiple pages open at a time? In either case, don't you need a link (to another controller) or an action (from a form) that would query for somethng like db(photos.album_name == var.album_name).select() ? I'm not a dab hand at this; I'm still bouncing back and forth in the manual
[web2py] Re: Hypermedia API and Collection+JSON in web2py
Let me add that Collection+JSON is a standard but that does not make it perfect. I find many limitations. I managed to overcome some but utilizing extensions. https://github.com/mamund/collection-json/tree/master/extensions I also made some of my own extensions. Extensions are allowed and compatible. Yet it needs more extensions. I did not push this too much because I did not want to depart too much much from the standard. Collection+JSON is also very verbose. I made a Collection(compact=True) option that makes it much less verbose but will break the specs. On Monday, 23 June 2014 00:01:27 UTC-5, Massimo Di Pierro wrote: > > This is a automatic in Colleciton+JSON. For example: > > # assume a model that described things and their attributes > db.define_table('thing',Field('name')) > db.define_table('attr',Field('thing','reference thing'),Field('name')) > > and you expose both: > > def api(): > from gluon.contrib.hypermedia import Collection > rules = { > 'thing': { > 'GET':{'query':None,'fields':['id', 'name']}, > 'POST':{'query':None,'fields':['name']}, > 'PUT':{'query':None,'fields':['name']}, > 'DELETE':{'query':None}, > }, > 'attr': { > 'GET':{'query':None,'fields':['id', 'name', 'thing']}, > 'POST':{'query':None,'fields':['name', 'thing']}, > 'PUT':{'query':None,'fields':['name', 'thing']}, > 'DELETE':{'query':None}, > }, > } > return Collection(db).process(request,response,rules) > > $ curl http://127.0.0.1:8000/super/collections/api/thing/1 > {"collection": {"version": "1.0", "href": "/super/collections/api/thing", > "items": [{"href": " > http://127.0.0.1:8000/super/collections/api/thing/1/chair";, "data": > [{"prompt": "Id", "name": "id", "value": 1}, {"prompt": "Name", "name": > "name", "value": "Chair"}], "links": [{"href": " > http://127.0.0.1:8000/super/collections/api/attr?thing=1";,. > > The links field tells you how to get the attributes of the thing Chair. > > For many2many and links to images you have to do a little bit more > programming. For example: > > Given: > db.define_table('thing',Field('name'),Field('image','upload')) > > You can define: > rules = {'thing':{'GET':{'query':None, 'fields':None, > 'links':{'picture':lambda row: > URL('download',args=row.image,scheme=True) > > Problem is that collection+JSON does not say anything about image uploads > (POST) and does not say anything about many2many relations. > > Massimo > > > > > On Sunday, 22 June 2014 18:20:36 UTC-5, samuel bonill wrote: >> >> it's good, I use db.parse_as_rest for generate the representation of >> resources, Collection+JSON help much. >> >> other thing, I would like generate a resource with relationship for >> example >> >> >> patterns = [ ("posts/{post.id}", {"coments": {"author": "auth_user"}}] >> # My implementation >> >> parser = db.parse_as_rest(patterns, args, kwargs) >> >> GET: http://example.com/default/index/posts/1.json >> >> { >> "content": [{ >> "id": "1", >> "title": "web2py", >> "text": "testing ...", >> "picture": "http://web2py.s3.amazonaws.com/post/my_s3_file.jpg";, >> "coments": [{ >> "id": 1, >> "text": "my coment", >> "author": {"id":3685, "name": "Lebron james" ...}, >>}, ... ] >> }] >> } >> >> the problem with the traditional RESTful apps on web2py is that for get the >> information >> of our restful example planted before, you need do three request to the api, >> like this case. >> >> patterns = [ "post/{post.id}", >> "post/{post.id}/coments[coments]/{coments.id}", >> >> "post/{post.id}/coments[coments]/{coments.id}/author[auth_user]" >>] >> >> parser = db.parse_as_rest(patterns, args, kwargs) >> >> #1 GET: http://example.com/default/index/post/1.json >> >> #2 GET: http://example.com/default/index/post/1/coments/1.json >> #3 GET: http://example.com/default/index/post/1/coments/1/author.json >> >> sorry my english... regards >> >> >> >> El domingo, 22 de junio de 2014 15:45:06 UTC-5, Massimo Di Pierro >> escribió: >>> >>> I added Hypermedia API support to web2py using Collection+JSON. >>> Experimental. >>> Collection+JSON is a standard for self documenting RESTful API. >>> Read more: http://amundsen.com/media-types/collection/ >>> >>> Example >>> = >>> >>> Let's say you have a model: >>> >>> db.define_table('thing',Field('name')) >>> >>> and in controller default.py you add >>> >>> def api(): >>> from gluon.contrib.hypermedia import Collection >>> rules = { >>> 'thing': { >>> 'GET':{'query':None,'fields':['id', 'name']}, >>> 'POST':{'query':None,'fields':['name']}, >>> 'PUT':{'query':None,'fields':['name']}, >>> 'DELETE':{'query
[web2py] Re: web2py password encryption/decryption
I did kind of investigation by myself. I can see CB uses new Joomla "Portable PHP password hashing framework" functionality to crypt password. I noticed CB run on joomla 3.2.1, while my other site is on Joomla 2 Anyway at the end of pasword cryption chain there is a function hashPassword and verifyPassword in libraries/joomla/user/helper.php abstract class JUserHelper public static function hashPassword($password) { // Use PHPass's portable hashes with a cost of 10. $phpass = new PasswordHash(10, true); return $phpass->HashPassword($password); } public static function verifyPassword($password, $hash, $user_id = 0) { $rehash = false; $match = false; // If we are using phpass if (strpos($hash, '$P$') === 0) { // Use PHPass's portable hashes with a cost of 10. $phpass = new PasswordHash(10, true); $match = $phpass->CheckPassword($password, $hash); $rehash = false; } Indeed all my passwords starts with "$P$" Whole algorithm to crypt CB/Joomla3.2.1 password is in file libraries/phpass/PasswordHash.php Question now is how to transform it to web2py CUSTOMER validator. I'll need your help > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: how to install facebookpython sdk in web2py
Same thing. I cannot find any piece of documentation on how to get needed facebook module. Thank you in advance On Saturday, June 21, 2014 1:19:31 PM UTC+3, greed wrote: > > can please any one tell me how to install the facebook python sdk in > web2py. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Hypermedia API and Collection+JSON in web2py
This is a automatic in Colleciton+JSON. For example: # assume a model that described things and their attributes db.define_table('thing',Field('name')) db.define_table('attr',Field('thing','reference thing'),Field('name')) and you expose both: def api(): from gluon.contrib.hypermedia import Collection rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }, 'attr': { 'GET':{'query':None,'fields':['id', 'name', 'thing']}, 'POST':{'query':None,'fields':['name', 'thing']}, 'PUT':{'query':None,'fields':['name', 'thing']}, 'DELETE':{'query':None}, }, } return Collection(db).process(request,response,rules) $ curl http://127.0.0.1:8000/super/collections/api/thing/1 {"collection": {"version": "1.0", "href": "/super/collections/api/thing", "items": [{"href": "http://127.0.0.1:8000/super/collections/api/thing/1/chair";, "data": [{"prompt": "Id", "name": "id", "value": 1}, {"prompt": "Name", "name": "name", "value": "Chair"}], "links": [{"href": "http://127.0.0.1:8000/super/collections/api/attr?thing=1";,. The links field tells you how to get the attributes of the thing Chair. For many2many and links to images you have to do a little bit more programming. For example: Given: db.define_table('thing',Field('name'),Field('image','upload')) You can define: rules = {'thing':{'GET':{'query':None, 'fields':None, 'links':{'picture':lambda row: URL('download',args=row.image,scheme=True) Problem is that collection+JSON does not say anything about image uploads (POST) and does not say anything about many2many relations. Massimo On Sunday, 22 June 2014 18:20:36 UTC-5, samuel bonill wrote: > > it's good, I use db.parse_as_rest for generate the representation of > resources, Collection+JSON help much. > > other thing, I would like generate a resource with relationship for > example > > > patterns = [ ("posts/{post.id}", {"coments": {"author": "auth_user"}}] # > My implementation > > parser = db.parse_as_rest(patterns, args, kwargs) > > GET: http://example.com/default/index/posts/1.json > > { > "content": [{ > "id": "1", > "title": "web2py", > "text": "testing ...", > "picture": "http://web2py.s3.amazonaws.com/post/my_s3_file.jpg";, > "coments": [{ > "id": 1, > "text": "my coment", > "author": {"id":3685, "name": "Lebron james" ...}, >}, ... ] > }] > } > > the problem with the traditional RESTful apps on web2py is that for get the > information > of our restful example planted before, you need do three request to the api, > like this case. > > patterns = [ "post/{post.id}", > "post/{post.id}/coments[coments]/{coments.id}", > "post/{post.id}/coments[coments]/{coments.id}/author[auth_user]" >] > > parser = db.parse_as_rest(patterns, args, kwargs) > > #1 GET: http://example.com/default/index/post/1.json > > #2 GET: http://example.com/default/index/post/1/coments/1.json > #3 GET: http://example.com/default/index/post/1/coments/1/author.json > > sorry my english... regards > > > > El domingo, 22 de junio de 2014 15:45:06 UTC-5, Massimo Di Pierro escribió: >> >> I added Hypermedia API support to web2py using Collection+JSON. >> Experimental. >> Collection+JSON is a standard for self documenting RESTful API. >> Read more: http://amundsen.com/media-types/collection/ >> >> Example >> = >> >> Let's say you have a model: >> >> db.define_table('thing',Field('name')) >> >> and in controller default.py you add >> >> def api(): >> from gluon.contrib.hypermedia import Collection >> rules = { >> 'thing': { >> 'GET':{'query':None,'fields':['id', 'name']}, >> 'POST':{'query':None,'fields':['name']}, >> 'PUT':{'query':None,'fields':['name']}, >> 'DELETE':{'query':None}, >>}} >> return Collection(db).process(request,response,rules) >> >> And now by magic your table "thing" is fully exposed using the >> Collection+JSON API. The API is self documenting and supports GET, POST, >> PUT, DELETE, etc. >> >> For example you can do things like: >> >> curl http://127.0.0.1:8000/app/default/api/thing >> curl http://127.0.0.1:8000/app/default/api/thing/1 >> curl http://127.0.0.1:8000/app/default/api/thing?id=1 >> curl >> http://127.0.0.1:8000/app/default/api/thing?name=Box&id.gt=10&_offest=10&_limit=30 >> curl -X POST -d name="Box" http://127.0.0.1:8000/app/default/api/thing >> curl -X PUT -d name="Chair" http://127.0.0.1:8000/app/default/api/thing >> ?name=Box >> curl -X DELETE >> http://127.0.0.1:8000/super/collections/conform/thing?name=Chair >> >>
[web2py] Readonly elements (select and date field) respond to clicks, allow for changes and can be submitted?
Why readonly elements (select and date field) of a form respond to clicks and allow for changes and can be submitted? They look grayed out as if readonly but when I click on date field the date picker appears and works as it shoud also the select option is grayed out but it offers a list to choose an option and the form can be submitted with these changed values even though this is not intended. #this is the model db.define_table('owner', Field('own_cust_fk','reference customer',label='Customer'), Field('own_veh_fk','reference vehicle',label='Vehicle'), Field('own_plate','string',label='Plate'), Field('own_comment','string',label='Comment'), Field('own_start_date','date',default=now,label='Start date'), Field('own_end_date','date',default=None,label='Terminated'), migrate='owner.table',format='%(own_plate)s %(own_cust_fk)s', plural='Owner' ) def index(): ... ... form = SQLFORM.smartgrid(db.owner, fields=fields, headers=headers, paginate=all, details=True, editable=True, deletable=False, create=False, showbuttontext=False, maxtextlength=40, maxtextlengths=maxtextlengths, buttons_placement = 'left', ) ... ... if ((len(request.args)>1) and (request.args(1)=='edit')): form.element('select',_name='own_cust_fk')['_readonly']='True' form.element('input',_name='own_end_date')['_readonly']='True' ... ... return dict(form=form) Any help would be appreciated! Thanks -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: tip of the day. The power of routes
Can you post the complete correct script? thanks. On Sunday, 17 October 2010 21:03:25 UTC-5, mdipierro wrote: > > Replace your web2py/routes.py with this: > > - begin routes.py--- > try: config=open('routes.conf','r').read() > except: config='' > def auto_in(apps): > routes=[ > ('/robots.txt','/welcome/static/robots.txt'), > ('/favicon.ico','/welcome/static/favicon.ico'), > ('/admin$a','/admin$a'), > ] > for a,b in [x.strip().split() for x in apps.split('\n') \ > if x.strip() and not x.strip().startswith('#')]: > if not b.startswith('/'): b='/'+b > if b.endswith('/'): b=b[:-1] > app = b.split('/')[1] > routes+=[ > ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b), > ('.*:https?://(.*\.)?%s:$method /static/$a' % a,'%s/static/ > $a' % app), > ('.*:https?://(.*\.)?%s:$method /appadmin/$a' % a,'%s/ > appadmin/$a' % app), > ('.*:https?://(.*\.)?%s:$method /$a' % a,'%s/$a' % b), > ] > return routes > > def auto_out(apps): > routes=[] > for a,b in [x.strip().split() for x in apps.split('\n') \ > if x.strip() and not x.strip().startswith('#')]: > if not b.startswith('/'): b='/'+b > if b.endswith('/'): b=b[:-1] > app = b.split('/')[1] > routes+=[ > ('%s/static/$a' % app,'static/$a'), > ('%s/appadmin/$a' % app, '/appadmin/$a'), > ('%s/$a' % b, '/$a'), > ] > return routes > > routes_in=auto_in(config) > routes_out=auto_out(config) > --- END --- > > what does it do? It writes routes for you based on a simpler routing > configuration file called routes.conf. here is an example: > > - BEGIN routes.conf--- > 127.0.0.1 /examples/default > domain1.com /app1/default > domain2.com /app2/default > domain3.com /app3/default > - END -- > > It maps a domain (the left had side) into an app and it shortens the > URLs for the app, by removing the listed path prefix. That means > > http://domain1.com/index will be mapped into /app1/default/index > http://domain2.com/index will be mapped into /app2/default/index > > It is safe in that it preserves admin, appadmin, static files, > favicon.ico and robots.txt. > > http://domain1.com/favicon.ico > http://domain1.com/robots.txt > http://domain1.com/admin/... /admin/... > http://domain1.com/appadmin/... /app1/appadmin/... > http://domain1.com/static/... /app1/static/... > > and vice-versa. > > It does assume one app per domain. > > I think something like this should be default since lots of people > find routes.py hard to work with. > Comments? Suggestions? > > Massimo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: tip of the day. The power of routes
Hi Massimo, I think there is error in your script : CURRENT line 69 : ('.*:https?://(.*\.)?%s:$method /$anything' % domain, '%s/$anything' % path) should be : ('.*:https?://(.*\.)?%s:$method /%s/$anything' % (domain, app), '/%s/$anything' % app) Regards, Tuan On Monday, October 25, 2010 11:04:57 AM UTC+7, mdipierro wrote: > > Aha! My mistake. $a should have been $anything everywhere in the > code. > > I fixed is and re-posted in trunk now under scripts/autoroutes.py > > Massimo > > > On Oct 24, 10:51 pm, VP wrote: > > Update: > > > > if the function has no arguments, it works. I.e. > http://domain.com/app/default/f > > gets mapped correctly tohttp://domain.com/f > > > > But if the function has arguments, it did not work for me. I.ehttp:// > domain.com/app/default/g/a/bdoes not get mapped tohttp://domain.com/g/a/b > > > > PS: > > I got the script from here: > http://web2py.googlecode.com/hg/scripts/autoroutes.py > > as far as I can tell, it's the same as the one in this this thread. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Trying to use the LOAD helper, if a button is clicked
Tomeu, At the moment I'm just letting datatables.net enhance a plain html table for me. One of these days I'll probably get around to giving it a json datasource but so far it hasn't been a priority for my usage. As a bonus, here's some of how to update the datatables.net display after using the edit dialog. (So just the edited record's row in the datatable gets updated rather than a full page refresh) In controller #after you'd done the necessary DB updates... #tell browser to close the jqueryui dialog response.js =XML( '$("#edit_dialog").dialog("close");') #prepare for display update edit_icon = IMG(_src=URL(c="static",f="images/page_white_edit.png"), _alt="Click to edit") #prep javascript code for datatables.net to update the existing row's display #basically just a json list of td values row_update = simplejson.dumps([updated_record.table.first_name, updated_record.table.last_name, updated_record.table2.name, str(A(edit_icon, _href=URL(r=request,f='edit_loader', args=[ updated_record.table.record_id, mode]), _class="updateDialog")), updated_record.table.email, updated_record.table.someother_id]) #using the tr#id method to update table is unreliable (the TR won't have an id if it was added dynamically #instead use the row index provided by datatables.net itself (we passed it in via ajax vars) #essentially fnUpdate(new td values, which row) response.js += '$("#your_table_selector").dataTable().fnUpdate( '+row_update +', '+request.vars['datatable_row_index']+',0, false );' #also using jGrowl to give an acknowledgement message = T("%s updated") % (updated_record.table.first_name) response.js += '$.jGrowl("'+message+'");' And as the second bonus, how to insert a brand new row in the datatable. (Below my datatable.net is another always visible LOAD()ed form for creating a new record. Upon submission the new record is inserted into the existing datatable via javascript returned in web2py's response) In controller: #do the database insert then #prepare for display update edit_icon = IMG(_src=URL(c="static",f="images/page_white_edit.png"), _alt="Click to edit") table_update = simplejson.dumps([new_record.table.first_name, new_record. table.last_name, new_record.table2.name, str(A(edit_icon, _href=URL(r=request,f= 'edit_loader', args=[new_record.table.record_id, form.vars.mode]), _class= "updateDialog")), new_record.table.email, new_record.table.foreign_id]) #issue command for adding new row to datatable response.js = 'vol_table.fnAddData('+table_update+');' Good luck ~Brian On Sunday, June 22, 2014 4:44:33 PM UTC-5, Tomeu Roig wrote: > > Thanks Brian, nice think to get a full href for pass to the > $web2py.component. > > I see that you use datatables.net. Do you use some plugin o directly you > pass json from controller? > > I want use in a new project but i have doubts have to implement. Can you > give me some idea? > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: upgraded and lost + - in string:list
Issue resolved. Copied the web2py.js from the welcome app which had all the right lines. Very very weird! Thank you so much for your help, Niphlod. I didn't even think to check the git branch. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: upgraded and lost + - in string:list
We're currently running 2.9.5 with Python 2.6 and our JS is only 209 lines. very odd. On Sunday, June 22, 2014 8:44:20 PM UTC-4, LoveWeb2py wrote: > > Well... first of all my web2py.js only has 209 lines not 721.I am afraid > to upgrade again because we had trouble with our last upgrade. In fact, I > don't see any reference to the w2p_list in web2py.js Guess I should just > try adding the code? > > On Saturday, June 21, 2014 2:51:31 PM UTC-4, Niphlod wrote: >> >> let's start from scratch. >> listwidget now just creates a ul with a class w2p_list for the >> listwidget. all the other bits are taken care by >> https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py.js#L84 >> . >> If you don't notice the "plus signs" around the listwidget, then there's >> something going on in your template (or in your js) that prevents that bit >> to apply. >> >> On Friday, June 20, 2014 4:05:26 PM UTC+2, LoveWeb2py wrote: >>> >>> any other recommendations? This is a big deal for our users >>> >>> On Friday, June 20, 2014 9:38:38 AM UTC-4, LoveWeb2py wrote: yes. It is a completely new version. Should I revert back the web2py.js ? On Friday, June 20, 2014 9:28:08 AM UTC-4, Niphlod wrote: > > did you update web2py.js too ? > > On Friday, June 20, 2014 3:13:32 PM UTC+2, LoveWeb2py wrote: >> >> I upgraded to the latest version of web2py and lost the + - in the >> SQLFORM which allowed users to add additional records. Any idea why? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: upgraded and lost + - in string:list
Well... first of all my web2py.js only has 209 lines not 721.I am afraid to upgrade again because we had trouble with our last upgrade. In fact, I don't see any reference to the w2p_list in web2py.js Guess I should just try adding the code? On Saturday, June 21, 2014 2:51:31 PM UTC-4, Niphlod wrote: > > let's start from scratch. > listwidget now just creates a ul with a class w2p_list for the listwidget. > all the other bits are taken care by > https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py.js#L84 > . > If you don't notice the "plus signs" around the listwidget, then there's > something going on in your template (or in your js) that prevents that bit > to apply. > > On Friday, June 20, 2014 4:05:26 PM UTC+2, LoveWeb2py wrote: >> >> any other recommendations? This is a big deal for our users >> >> On Friday, June 20, 2014 9:38:38 AM UTC-4, LoveWeb2py wrote: >>> >>> yes. It is a completely new version. Should I revert back the web2py.js ? >>> >>> On Friday, June 20, 2014 9:28:08 AM UTC-4, Niphlod wrote: did you update web2py.js too ? On Friday, June 20, 2014 3:13:32 PM UTC+2, LoveWeb2py wrote: > > I upgraded to the latest version of web2py and lost the + - in the > SQLFORM which allowed users to add additional records. Any idea why? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Hypermedia API and Collection+JSON in web2py
it's good, I use db.parse_as_rest for generate the representation of resources, Collection+JSON help much. other thing, I would like generate a resource with relationship for example patterns = [ ("posts/{post.id}", {"coments": {"author": "auth_user"}}] # My implementation parser = db.parse_as_rest(patterns, args, kwargs) GET: http://example.com/default/index/posts/1.json { "content": [{ "id": "1", "title": "web2py", "text": "testing ...", "picture": "http://web2py.s3.amazonaws.com/post/my_s3_file.jpg";, "coments": [{ "id": 1, "text": "my coment", "author": {"id":3685, "name": "Lebron james" ...}, }, ... ] }] } the problem with the traditional RESTful apps on web2py is that for get the information of our restful example planted before, you need do three request to the api, like this case. patterns = [ "post/{post.id}", "post/{post.id}/coments[coments]/{coments.id}", "post/{post.id}/coments[coments]/{coments.id}/author[auth_user]" ] parser = db.parse_as_rest(patterns, args, kwargs) #1 GET: http://example.com/default/index/post/1.json #2 GET: http://example.com/default/index/post/1/coments/1.json #3 GET: http://example.com/default/index/post/1/coments/1/author.json sorry my english... regards El domingo, 22 de junio de 2014 15:45:06 UTC-5, Massimo Di Pierro escribió: > > I added Hypermedia API support to web2py using Collection+JSON. > Experimental. > Collection+JSON is a standard for self documenting RESTful API. > Read more: http://amundsen.com/media-types/collection/ > > Example > = > > Let's say you have a model: > > db.define_table('thing',Field('name')) > > and in controller default.py you add > > def api(): > from gluon.contrib.hypermedia import Collection > rules = { > 'thing': { > 'GET':{'query':None,'fields':['id', 'name']}, > 'POST':{'query':None,'fields':['name']}, > 'PUT':{'query':None,'fields':['name']}, > 'DELETE':{'query':None}, >}} > return Collection(db).process(request,response,rules) > > And now by magic your table "thing" is fully exposed using the > Collection+JSON API. The API is self documenting and supports GET, POST, > PUT, DELETE, etc. > > For example you can do things like: > > curl http://127.0.0.1:8000/app/default/api/thing > curl http://127.0.0.1:8000/app/default/api/thing/1 > curl http://127.0.0.1:8000/app/default/api/thing?id=1 > curl > http://127.0.0.1:8000/app/default/api/thing?name=Box&id.gt=10&_offest=10&_limit=30 > curl -X POST -d name="Box" http://127.0.0.1:8000/app/default/api/thing > curl -X PUT -d name="Chair" http://127.0.0.1:8000/app/default/api/thing > ?name=Box > curl -X DELETE > http://127.0.0.1:8000/super/collections/conform/thing?name=Chair > > The API are completely self documenting as explained here > http://amundsen.com/media-types/collection/ > > It is customizable > == > >rules = { > 'thing': { > 'GET':{'query':None,'fields':['id', 'name']}, > 'POST':{'query':None,'fields':['name']}, > 'PUT':{'query':None,'fields':['name']}, > 'DELETE':{'query':None}, >}} > > Let you specify which tables are exposed, which methods are available and > which fields are exposed for each method. The query property lets you > specify optional filters for example { > 'query':db.thing.name.startswith('A'),} will only exposed things > starting with letter A. Fields can be conditional and different for > different users or for the same user in different stages of a workflow (the > communication is stateless, but the server is not). > > Supports complex queries > = > http:/./{table} > http:/./{table}/{id} > http:/./{table}?{field}=value > http:/./{table}?{field}.gt=value # field>value > http:/./{table}?{field}.le=value # field<=value > ... > http:/./{table}?_orderby={field} > http:/./{table}?_limitby=value > http:/./{table}?_offset=value > ... > and combinations there of. They are mapped directly into DAL queries. More > examples are in the API response itself. > > The bigger picture > === > > This API provide enough information to generate forms and tables and grid > completely client side. Recently we stumbled against the problem of moving > from Bootstrap 2 to Bootstrap 3 because so much of the form and grid logic > is server side. My plan is to move most of the logic in the JS library and > allow users to customize them for different CSS frameworks. > > Eventually (in dreams) I would like to have a very slim framework based on > bottle+dal+validators+auth+collection and have client side only templates > (based on jquery, sugar, and ractive.js
[web2py] Re: Trying to use the LOAD helper, if a button is clicked
Thanks Brian, nice think to get a full href for pass to the $web2py.component. I see that you use datatables.net. Do you use some plugin o directly you pass json from controller? I want use in a new project but i have doubts have to implement. Can you give me some idea? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Brainstorming
Have you looked at breezejs? A "JavaScript library that helps you manage data in rich client applications". Breeze dynamically builds a mirror of the server-side db model on the client and then binds to UI controls so the UI updates when the data model changes. Each object knows when it has changed and what has changed. Essentially it builds a client-side cache of the db. On the surface it's focused on .NET (with it's own .NET components), but if you look underneath you see that web2py could easily provide the back-end. Nice overview here: http://www.breezejs.com/documentation/introduction MIT license. On Saturday, June 21, 2014 9:33:04 PM UTC+12, Massimo Di Pierro wrote: > > web2py is mostly serverside and that is not going to change. I think what > we are discussing is the future... > > In the future I envision a new framework that has more client-side logic. > In order to do that we have make some choices of client-side frameworks. I > also agree that communication between client and server needs to rely on > standards. One possible standard are using hypermedia API for self > documenting json services. Yet I find it to be insufficient. I am spending > lot of time thinking about a generic way for client and server to > communicate. The problem is that they need to communicate more than data, > but also templates, and workflow information. > > > On Friday, 20 June 2014 16:26:44 UTC-5, Phyo Arkar wrote: >> >> >> On Sat, Jun 21, 2014 at 3:31 AM, Michele Comitini > > wrote: >> >>> My POV is that web2py should have a rather agnostic attitude toward a >>> wide range of frameworks, by having some kind of layer that would allow to >>> keep server side code mostly untouched when changing js framework, easily >>> add support for a new js framework. >>> In practice web2py should use a well defined protocol between client and >>> server, to pass actions, messages and events back and forth. >>> >> >> >My POV is that web2py should have a rather agnostic attitude toward a >> wide range of frameworks, by having some kind of layer that would allow to >> keep server side code mostly untouched when changing js >framework, easily >> add support for a new js framework. >> >In practice web2py should use a well defined protocol between client and >> server, to pass actions, messages and events back and forth. >> >> >> + 100! >> >> Exactly my toughts too. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Hypermedia API and Collection+JSON in web2py
I added Hypermedia API support to web2py using Collection+JSON. Experimental. Collection+JSON is a standard for self documenting RESTful API. Read more: http://amundsen.com/media-types/collection/ Example = Let's say you have a model: db.define_table('thing',Field('name')) and in controller default.py you add def api(): from gluon.contrib.hypermedia import Collection rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} return Collection(db).process(request,response,rules) And now by magic your table "thing" is fully exposed using the Collection+JSON API. The API is self documenting and supports GET, POST, PUT, DELETE, etc. For example you can do things like: curl http://127.0.0.1:8000/app/default/api/thing curl http://127.0.0.1:8000/app/default/api/thing/1 curl http://127.0.0.1:8000/app/default/api/thing?id=1 curl http://127.0.0.1:8000/app/default/api/thing?name=Box&id.gt=10&_offest=10&_limit=30 curl -X POST -d name="Box" http://127.0.0.1:8000/app/default/api/thing curl -X PUT -d name="Chair" http://127.0.0.1:8000/app/default/api/thing ?name=Box curl -X DELETE http://127.0.0.1:8000/super/collections/conform/thing?name=Chair The API are completely self documenting as explained here http://amundsen.com/media-types/collection/ It is customizable == rules = { 'thing': { 'GET':{'query':None,'fields':['id', 'name']}, 'POST':{'query':None,'fields':['name']}, 'PUT':{'query':None,'fields':['name']}, 'DELETE':{'query':None}, }} Let you specify which tables are exposed, which methods are available and which fields are exposed for each method. The query property lets you specify optional filters for example { 'query':db.thing.name.startswith('A'),} will only exposed things starting with letter A. Fields can be conditional and different for different users or for the same user in different stages of a workflow (the communication is stateless, but the server is not). Supports complex queries = http:/./{table} http:/./{table}/{id} http:/./{table}?{field}=value http:/./{table}?{field}.gt=value # field>value http:/./{table}?{field}.le=value # field<=value ... http:/./{table}?_orderby={field} http:/./{table}?_limitby=value http:/./{table}?_offset=value ... and combinations there of. They are mapped directly into DAL queries. More examples are in the API response itself. The bigger picture === This API provide enough information to generate forms and tables and grid completely client side. Recently we stumbled against the problem of moving from Bootstrap 2 to Bootstrap 3 because so much of the form and grid logic is server side. My plan is to move most of the logic in the JS library and allow users to customize them for different CSS frameworks. Eventually (in dreams) I would like to have a very slim framework based on bottle+dal+validators+auth+collection and have client side only templates (based on jquery, sugar, and ractive.js) that can generate forms and grids based the collection API. This framework could ship with web2py and allow you to program using same web interface that we all love. There are many design decisions to make to get there. Your suggestions are welcome. How can you help? === 1) test it. 2) there are many existing client side tools for Collection+JSON. Try them with web2py. 3) blog about it and suggest improvements. I said, it is experimental === Collection+JSON has limits: - it is very verbose JSON. This is my my implementation has compact=True option that breaks the protocol but makes much smaller JSON messages. - it does not convey field type information and constraints. This is why I extended to do so but more work is needed because DAL types do not map into HTML5 input types (this of list:string or list:reference). More extensions of the protocol are required. Extensions are allowed. Yet they may change the API in the near future. Massimo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py password encryption/decryption
I'm so sorry for late answer. I was out of office/home for a while. Busy time this 2014 I can see :). Anyway, Massimo is absolutely right. I have two joomla sites. One "Joomla _user original" and indeed passwords are according to standard described in link. Example (c563e965be1369f9030863daca32a544:fwQkHlQqimvzfDBisPZkruuYCTvTsxSU) Second one is with "Community Builder" module installed. And this is root cause why password handling is different. I sheel write how to integrate then "Community Builder" and web2py :( -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: sqlform.grid add new - populate some fields(with values from another db) based on other fields
sorry, didn't read this sentence > > I want these to be reflected even before i click 'submit' button > > if you want to achieve it before click 'submit' button, i think you can achieve it using ajax callback for that. best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: sqlform.grid add new - populate some fields(with values from another db) based on other fields
> > 1. when i select itemcode from dropdown, the form to fill itemname and > sellingprice from the stockitems table > i think you can achieve it using form.validate(), use query for stockitems table and then insert itemname and sellingprice base on the row of stockitems > 2. when i enter qty, the amount to be calculated as qty*sellingprice > this one you can do it, either with compute on dal side or you can calculate it during form.validate on above method. e.g. for compute db.sales.compute = lambda r: r['sellingprice']*r['qty'] ref: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Computed-fields another way, i think you can learn much from the web2py appliances PosOnlineStore ref: https://github.com/mdipierro/web2py-appliances/tree/master/PosOnlineStore https://github.com/mdipierro/web2py-appliances/tree/master/EStore best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] sqlform.grid add new - populate some fields(with values from another db) based on other fields
Hi. Im new to web2py. I have gone through most of the ducumentation and videos but im still stuck. Here is the scenario: db : stockitems fields(itemcode, itemName, sellingPrice) db : sales fields(date,itemcode,itemname, sellingprice,qty,amount) I have a sqlform.grid from db.sales to show : date, itemcode(dropdown), itemname, sellingprice,qty, amount On 'add' on sqlform.grid i want 1. when i select itemcode from dropdown, the form to fill itemname and sellingprice from the stockitems table 2. when i enter qty, the amount to be calculated as qty*sellingprice I want these to be reflected even before i click 'submit' button Kindly assist -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] how to install facebookpython sdk in web2py
can please any one tell me how to install the facebook python sdk in web2py. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.