[web2py] Re: Ractive and Single Page Apps
ractive does just templating and data binding. nothing else. If you need a routing system, use a routing library. One of the best/worst things of javascript (node too) is that the world is littered by thousands of small little libraries that you can mix and match. There's no clear path, nor a clear opinionated "recipe" that puts together the best libraries you have to choose for yourself. That being said, if in need of client side routing I leverage crossroads.js On Tuesday, October 20, 2015 at 5:38:51 AM UTC+2, Rod Watkins wrote: > > Hello everyone, > > I am hoping some of you who have already been using ractive.js may be able > to help me. I'd like to create a single page app. The usual frameworks for > doing so, from what I've read, are angular, backbone (+ marionette) and > ember. I've studied angular and ember and each seems to be doing way more > than I want it to. Let me explain. I hate javascript. I think its an ugly, > nigh unreadable language. Python by contrast... oh the beauty. So I would > rather not use a js framework that takes over functions I rather have > web2py perform. That's why I am attracted to ractive. I understand the > value of two-way data-binding and client side views. And that's ractive's > game and no more. Besides, its dead simple to use--not at all like angular > or ember, as far as I can see. > > But that leaves me with a question. Angular/ember/backbone have routing > systems. Ractive does not. So how do you handle routing for a single page > app from web2py. How have others implemented this with ractive? I am very > new to the single page app paradigm and it just isn't clicking for me. By > the way, I have tried to study the w3 example from Massimo, but it's not > been a lot of help. I think I just need a bit of a walk through. Maybe this > could be the start of a new section for the web2py book?? > > Cheers > Rod > > -- 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: Replace 'Log in' text in auth.navbar by 'User'
Someone knows how I can do it? Il giorno martedì 13 ottobre 2015 16:27:41 UTC+2, Gael Princivalle ha scritto: > > Hello all. > > It seems that some users the first time they want to login expect that > it's just necessary click on the first level menu 'Log in'. > But it's not like that, they have to look at the dropdown menu second > level 'Log in' voice. > > How can I change the first level 'Log in' text by 'User' in auth.navbar? > > Thanks, regards. > -- 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: Insert/update user record in 2 db
Ok thank's. Il giorno martedì 13 ottobre 2015 21:18:33 UTC+2, Niphlod ha scritto: > > a legacy db just needs migrate=False. Nothing else. Just as a production > db where migrations aren't needed in THAT single request. > > tl;dr: The default for every NON "development-mylaptop-etc" environment > should be migrate=False. Let me reinstate once again: migrate=True is a > TOTAL WASTE of cpu when models aren't requiring any migration > > back to you issue: if you're comfortable with executing queries by hand in > the database, a DAL line is all you need. If you want to leverage fancy > syntax over an Abstraction (where the A in DAL comes from), you kinda > need to define the Abstraction. Which, boiled down, means defining table > models you want to interact with. > > > > On Tuesday, October 13, 2015 at 4:16:37 PM UTC+2, Gael Princivalle wrote: >> >> Hello all. >> >> In a web2py application I would like to insert/update user records in 2 >> db. >> The first one is the application db, a postgres db: >> db = DAL('postgres://user:pass@localhost:5432/my_web2py_app_db', >> check_reserved=['all'], pool_size=1, entity_quoting=True, bigint_id=True, >> migrate=True) >> >> >> The second one is used by a mailing program called php list. It's a mysql >> db. >> db_php_list = DAL('mysql://user:pass@localhost:3306/my_php_list_db', >> fake_migrate_all=False, migrate=True) >> >> I don't see any db_php_list table in database administration. >> >> Mysql port is 3306? >> For an existing db, I've to add 'fake_migrate_all=False, migrate=True', >> right? >> >> Admitting that I can connect to the mysql db, how can I handle the user >> insert/updates to both db? >> >> Thanks, regards. >> >> >> >> -- 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: Sitemap Question
Hello Joe. I use the Scheduler for that, for making every day a new updated sitemap. I use txt sitemaps because I've saw that if an XML sitemap is too long Google don't take care of it. In txt yes. Here is an example: def sitemap_txt_auto(): import os from gluon.myregex import regex_expose # Statics URLs exclusions = ['download', 'call', 'data', 'upload', 'browse', 'delete'] ctldir = os.path.join(request.folder,"controllers") ctls=os.listdir(ctldir) if 'appadmin.py' in ctls: ctls.remove('appadmin.py') if 'manage.py' in ctls: ctls.remove('manage.py') if 'default.py.1' in ctls: ctls.remove('default.py.1') sitemap='http://www.yourdomain.com' for ctl in ctls: if ctl.endswith(".bak") == False: filename = os.path.join(ctldir,ctl) data = open(filename, 'r').read() functions = regex_expose.findall(data) for f in functions: if not any(f in s for s in exclusions): # if function is not in exclustions sitemap += '\r\n' sitemap += 'http://www.yourdomain.com/%s' % (f) # Dynamic URLs # News news = db(db.news.on_line == True).select(db.news.ALL) for item in news: sitemap += '\r\n' sitemap += 'http://www.yourdomain.com/news?id=%s' % (str(item.id)) # And other dynamic urls file = open('%s/static/sitemaps/sitemap.txt' %request.folder, 'w') file.write(sitemap) file.close() #FOr being sure that the sitemap have been made. email_sent = mail.send( to = 'y...@mail.com', subject = 'Sitemap youdomain', message = 'The sitemap have been generated with success.') db.commit() from gluon.scheduler import Scheduler Scheduler(db,dict(sitemap_txt_auto=sitemap_txt_auto)) Il giorno sabato 10 ottobre 2015 03:55:13 UTC+2, Joe ha scritto: > > What is the best way to implement a sitemap for a Web2py site? Is there a > Web2py code to generate the sitemap or I should use a third party sitemap > generator? If so, should I place the XML file in the static folder? > I'd appreciate some advise on this. > Thanks very much. > Cheers, > Joe > -- 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: Running function after an auth db modification
see the manual about database callbacks. http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle wrote: > > Hello all. > > I would like to run a function everytime there is a modification in auth. > > something like: > auth.settings.onchange = lambda: myfunction() > > Or only if a specific field change: > auth.settings.myfield.onchange = lambda: myfunction() > > Is it possible? > > I need it for changing a field value in another db. > > Thanks, regards. > > -- 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] Running function after an auth db modification
Hello all. I would like to run a function everytime there is a modification in auth. something like: auth.settings.onchange = lambda: myfunction() Or only if a specific field change: auth.settings.myfield.onchange = lambda: myfunction() Is it possible? I need it for changing a field value in another db. Thanks, regards. -- 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] Re: Replace 'Log in' text in auth.navbar by 'User'
Take a look to gluon/tools.py in Auth.navbar.bare maybe is what you need. On Tue, Oct 20, 2015 at 11:10 AM, Gael Princivalle < gaelprinciva...@gmail.com> wrote: > Someone knows how I can do it? > > > Il giorno martedì 13 ottobre 2015 16:27:41 UTC+2, Gael Princivalle ha > scritto: >> >> Hello all. >> >> It seems that some users the first time they want to login expect that >> it's just necessary click on the first level menu 'Log in'. >> But it's not like that, they have to look at the dropdown menu second >> level 'Log in' voice. >> >> How can I change the first level 'Log in' text by 'User' in auth.navbar? >> >> Thanks, regards. >> > -- > 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. > -- Massimiliano -- 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: Can web2py "front-end" an API?
What if you use a model-less aplication? thats the way we handled this, we have a web2py application that consumes a lot of microservices, this application doesnt have any DB object and doesnt use the dal, it makes HTTP request to the api inside the controllers (Using the python requests library), format it and send to the views. El domingo, 18 de octubre de 2015, 0:55:50 (UTC-4:30), pbreit escribió: > > Is there an easy way to use web2py to "front-end" and API? What I mean by > that is that given a public API (for example, Stripe's API), could I write > some models that correspond to the API structure and then call the DAL as > if the API was a back-end DB? Does that make any sense? > -- 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] Fwd: aiosmtpd 1.0a1 - asyncio-based implementations of SMTP/LMTP
This is nice if you want a pure python SMTP server Begin forwarded message: > From: Barry Warsaw> Subject: aiosmtpd 1.0a1 - asyncio-based implementations of SMTP/LMTP > Date: October 20, 2015 at 8:51:29 AM CDT > To: > Reply-To: python-l...@python.org > > I'm very happy to announce the first alpha release of aiosmtpd, an > asyncio-based implementation of SMTP and LMTP. > > http://aiosmtpd.readthedocs.org/en/latest/ > https://pypi.python.org/pypi/aiosmtpd/1.0a1 > > This library can be used as a standalone server, or as a testing framework for > applications that send email. It's inspired by several previous packages > including the stdlib smtpd.py, lazr.smtptest, Benjamin Bader's aiosmtp, and > submodules in GNU Mailman. > > This is an alpha release, so it can obviously use lots of feedback, and > contributions are very much welcome. We're developing the library on GitLab; > see the RTD link above for details. > > Brought to you by the aiosmtpd hacking cabal of Andrew Kuchling, Eric Smith, > Jason Coombs, R. David Murray and myself. > > Our aim is to include aiosmtpd in the Python 3.6 stdlib as a better > alternative to smtpd.py. > > Cheers, > -Barry > -- > https://mail.python.org/mailman/listinfo/python-announce-list > >Support the Python Software Foundation: >http://www.python.org/psf/donations/ -- 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] web2py edit modify field sqlform.grid
Hi, i'd like a very simple example please (i begin) : could you tell me how to do for updating a field when i use sqlform.grid. Example: my db : db.define_table('message', Field('firstname',requires=IS_NOT_EMPTY()), Field('lastname',requires=IS_NOT_EMPTY()), Field('team',requires=IS_NOT_EMPTY()), Field('mail',requires=IS_EMAIL()), Field('title', requires=IS_IN_SET(['Mission', 'RH', 'IT']), default='RH' ), Field('your_message','text',default=VALUE), Field('timestamp', default=str(datetime.datetime.now( now in my controller i return records as : records = SQLFORM.grid(db.message,user_signature=True,maxtextlength=100,orderby=~db.message.id,deletable=False,editable=True,create=False, \ fields=[db.message.lastname,db.message.team, db.message.mail] ) The goal is to edit one record and update the field timestamp with the date of day . This field has to be readable only Thank you -- 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] Setting up database table with date.
Hi I have the following defining my DB tables:- db.define_table('school_students', Field('first_name', 'string',requires=IS_NOT_EMPTY()), Field('surname', 'string',requires=IS_NOT_EMPTY()), Field('year', 'string',requires=IS_NOT_EMPTY()), Field('form', 'string',requires=IS_NOT_EMPTY()), Field('dob', 'date', requires=IS_DATE('%d/%m/%Y'))) But when I import the data into the database from a file I get -00-00, where the date should have been imported. The date format of the imported file is dd/mm/. How do I define this to get the correct format, I have looked on google and in forums and it mention to put IS_DATE('%d/%m/%Y. As you see, I did that above but did not work. Please point me the right direction. Thanks G Smith -- 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 update db record using ajax?
For some reason I just can't seem to get my head round the ajax documentation. I have what I think is a simple goal. Using javascript / jQuery, how do I silently update db.person with the following data? {"id":3, "firstName":"John", "lastName":"Doe"} I appreciate I need to supply a function to take care of this but how to call the function from javascript / jQuery? -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 11:35:26 AM UTC-7, Anthony wrote: > > On Tuesday, October 20, 2015 at 2:19:39 PM UTC-4, Dave S wrote: >> >> >> >> On Tuesday, October 20, 2015 at 6:21:08 AM UTC-7, A3 wrote: >>> >>> Thanks for the detailed explanation. >>> >> >> And, just to play Captain Obvious, you probably don't need that much >> effort if both your functions are in the same .py file. >> > > These options assume the functions are in the same *controller* file > (gets trickier to check other controllers). How would you do it? > Source control. /dps > > Anthony > -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 2:19:39 PM UTC-4, Dave S wrote: > > > > On Tuesday, October 20, 2015 at 6:21:08 AM UTC-7, A3 wrote: >> >> Thanks for the detailed explanation. >> > > And, just to play Captain Obvious, you probably don't need that much > effort if both your functions are in the same .py file. > These options assume the functions are in the same *controller* file (gets trickier to check other controllers). How would you do it? Anthony -- 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: Running function after an auth db modification
Thanks Anthony but what does it mean the proper signature? def add_phplist_user(f,id): auth_user = db.auth_user(id) #add user db_phplist.phplist_user_user.insert( email = auth_user.email, confirmed = auth_user.newsletter) db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) I have to take the new record data from somewhere, and if I do that: db.auth_user._after_insert.append(add_phplist_user(f,id)) Of course f and id are not defined. Il giorno martedì 20 ottobre 2015 18:38:18 UTC+2, Anthony ha scritto: > > Note, if you function already has the proper signature, there is no reason > to wrap it in a lambda. Also, your callbacks do not have to return an empty > dictionary (they are not controller actions). > > Anthony > > On Tuesday, October 20, 2015 at 9:19:20 AM UTC-4, Gael Princivalle wrote: >> >> Thanks Niphlod. >> >> After insert works great: >> def add_phplist_user(f,id): >> auth_user = db.auth_user(id) >> #add user >> db_phplist.phplist_user_user.insert( >> email = auth_user.email, >> confirmed = auth_user.newsletter) >> return dict() >> >> db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) >> >> After update works well also: >> >> def update_phplist_user(s,f): >> n_rows = db_phplist(db_phplist.phplist_user_user.email == s.email). >> count() >> if n_rows > 0: >> #update confirmed >> db_phplist(db_phplist.phplist_user_user.email == s.email).update( >> confirmed = s.newsletter) >> return dict() >> >> db.auth_user._after_update.append(lambda s,f: update_phplist_user(s,f)) >> >> But the after update run also after a new insert, and the f dictionary is >> empty, so I've got a ticket. >> >> Do you know why? >> Have you got a solution? >> >> Il giorno martedì 20 ottobre 2015 11:53:42 UTC+2, Niphlod ha scritto: >>> >>> see the manual about database callbacks. >>> >>> >>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update >>> >>> On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle >>> wrote: Hello all. I would like to run a function everytime there is a modification in auth. something like: auth.settings.onchange = lambda: myfunction() Or only if a specific field change: auth.settings.myfield.onchange = lambda: myfunction() Is it possible? I need it for changing a field value in another db. Thanks, regards. -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 6:21:08 AM UTC-7, A3 wrote: > > Thanks for the detailed explanation. > And, just to play Captain Obvious, you probably don't need that much effort if both your functions are in the same .py file. /dps > > Op dinsdag 20 oktober 2015 03:11:53 UTC+2 schreef Anthony: >> >> If you have the function name, you can do: >> >> if function_name in globals(): >> >> And if you have the actual function object, you can do: >> >> if function.__name__ in globals(): >> >> Note, those will yield hits even if there is an object of that name >> defined in a model file. If that is a concern, you can diff the globals >> before and after executing the controller to get a list of objects >> specifically defined in the controller. To do that, at the top of the >> controller file (or anywhere before the first component you want to >> register): >> >> pre_controller_objects = dir() >> >> Then at the bottom of the controller (or after the last component): >> >> controller_objects = set(dir()) - set(pre_controller_objects) >> >> Then, wherever you want to test for the existence of a function: >> >> if function_name in controller_objects: >> >> Note, that will identify any objects defined in the controller, even if >> they are not functions. If that's a concern, you can further filter >> controller_objects to include only function objects. >> >> Finally, if you only want to identify specific actions that your have >> defined as components, you could use a special prefix/postfix to identify >> them, or just manually maintain a list of their names. One other option >> would be to create a decorator that registers a component name in a special >> object. In a module or model file, or at the top of the controller: >> >> class Component(object): >> def __init__(self): >> self.names = [] >> >> def __call__(self, f): >> self.names.append(f.__name__) >> return f >> >> component = Component() >> >> Then you would decorate components: >> >> @component >> def component1(): >> return dict() >> >> @component >> def component2(): >> return dict() >> >> Finally, wherever needed, check for a component as follows: >> >> if 'component1' in component.names: >> >> Anthony >> >> On Monday, October 19, 2015 at 4:19:30 PM UTC-4, A3 wrote: >>> >>> >>> I want to be able to test if a certain function exists in a controller. >>> (I am loading a component with help of another) >>> >>> controller: >>> default.py >>> def myfunction() >>> return >>> >>> def mytest() >>> if exists(myfunction()): >>>do this. >>> >> -- 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] file upload "not authorized"
Hello all, I have been trying to enable file uploading using the examples in the documentation and then using the follow approach: https://groups.google.com/forum/?fromgroups#!searchin/web2py/file$20upload/web2py/10FXxJrVR5k/6ySXshodipMJ but each time i do it i get "not authorized" response.flash I am using authentication, but i may be missing something in regards to giving permission to allow for file uploading Thank you for any help you can provide, Jason -- 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 update db record using ajax?
I usually have a controller like this: def update_or_insert_thing(): response.view ='generic.json' ret = None if request.vars: if request.vars.id: request.vars.id = int(request.vars.id) ret = db(db.thing.id == request.vars.id).validate_and_update (**request.vars) else: ret = db.thing.validate_and_insert(**request.vars) if ret and ret.errors: response.flash = T('Validation Errors') return {'id': request.vars.id or ret.id, 'errors': ret. errors} return {'id': request.vars.id or ret.id, 'errors': []} return {} Then all you need is to post to it using your dict as the data. Something like this $.ajax( { url: "{{=URL('default', 'update_or_insert_thing')}}", method: 'POST', data: {"id":3, "firstName":"John", "lastName":"Doe"} dataType: 'json' } ).done(function(data) {... // Here you should deal with validation errors -- 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: Replace 'Log in' text in auth.navbar by 'User'
You have to either use server side DOM manipulation or use navbar mode="bare" and make your own custom navbar. -- 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] Re: OS X Permissions question: echo works in ../web2py but not ../web2py/applications?
Ah, relief. You have diagnosed the issue exactly. Thank you so much. -- 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] web2py file upload returning "not authorized"
Hello all, I'm trying to upload files in my web app using the code from the manual and using the technique described here: https://groups.google.com/forum/#!searchin/web2py/upload$20file/web2py/10FXxJrVR5k/6ySXshodipMJ when i try to upload a file i'm getting a flash response of "not authorized" and no file is uploaded. Am i missing a step to authorize a user to upload files? Thank you! Jason -- 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] Re: OS X Permissions question: echo works in ../web2py but not ../web2py/applications?
Thank you, Dr. Di Pierro! I did reboot, then run Disk Utility, which is now so user friendly I couldn't see what it found. Didn't solve the problem. I will indeed use chown. Just wanted to make sure there was no change of permissions in web2py that I needed to know about. Thought maybe there was some kind of security upgrade or something that using chown might break something else down the line. On Tue, Oct 20, 2015 at 9:06 AM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > I do not know but you do seem to have permissions to write in that folder. > You can use chmod and chown to restore those permissions. This could also > be a problem with the filesystem. Some time permissions go bad in OSX and > you have to use the Disk Utils to fix permissions and then reboot. > > > On Monday, 19 October 2015 20:53:28 UTC-5, Tom Campbell wrote: >> >> In the most recent version of Mac OS X, if I'm in the web2py directory >> this works fine: >> >> echo "# todo" >> README.md >> >> Yet if I'm in web2py/applications or any of its subdirectories I get a >> "Permission denied" error. What incredibly stupid thing am I doing wrong? >> >> >> >> > -- > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/oqYxn3E8xuc/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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] Re: OS X Permissions question: echo works in ../web2py but not ../web2py/applications?
It depends now you run the web server. On Mac you probably run it with rocket under your credentials. So if they are owned by you and you have permission to write in the folder, it should work. I have had issues with borken permissions on Mac and the solution was to delete the folder and create another one. On Tuesday, 20 October 2015 12:26:51 UTC-5, Tom Campbell wrote: > > Thank you, Dr. Di Pierro! I did reboot, then run Disk Utility, which is > now so user friendly I couldn't see what it found. Didn't solve the > problem. I will indeed use chown. Just wanted to make sure there was no > change of permissions in web2py that I needed to know about. Thought maybe > there was some kind of security upgrade or something that using chown might > break something else down the line. > > On Tue, Oct 20, 2015 at 9:06 AM, Massimo Di Pierro < > massimo.dipie...@gmail.com> wrote: > >> I do not know but you do seem to have permissions to write in that >> folder. You can use chmod and chown to restore those permissions. This >> could also be a problem with the filesystem. Some time permissions go bad >> in OSX and you have to use the Disk Utils to fix permissions and then >> reboot. >> >> >> On Monday, 19 October 2015 20:53:28 UTC-5, Tom Campbell wrote: >>> >>> In the most recent version of Mac OS X, if I'm in the web2py directory >>> this works fine: >>> >>> echo "# todo" >> README.md >>> >>> Yet if I'm in web2py/applications or any of its subdirectories I get a >>> "Permission denied" error. What incredibly stupid thing am I doing wrong? >>> >>> >>> >>> >> -- >> 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 a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/oqYxn3E8xuc/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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: Running function after an auth db modification
Note, if you function already has the proper signature, there is no reason to wrap it in a lambda. Also, your callbacks do not have to return an empty dictionary (they are not controller actions). Anthony On Tuesday, October 20, 2015 at 9:19:20 AM UTC-4, Gael Princivalle wrote: > > Thanks Niphlod. > > After insert works great: > def add_phplist_user(f,id): > auth_user = db.auth_user(id) > #add user > db_phplist.phplist_user_user.insert( > email = auth_user.email, > confirmed = auth_user.newsletter) > return dict() > > db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) > > After update works well also: > > def update_phplist_user(s,f): > n_rows = db_phplist(db_phplist.phplist_user_user.email == s.email). > count() > if n_rows > 0: > #update confirmed > db_phplist(db_phplist.phplist_user_user.email == s.email).update( > confirmed = s.newsletter) > return dict() > > db.auth_user._after_update.append(lambda s,f: update_phplist_user(s,f)) > > But the after update run also after a new insert, and the f dictionary is > empty, so I've got a ticket. > > Do you know why? > Have you got a solution? > > Il giorno martedì 20 ottobre 2015 11:53:42 UTC+2, Niphlod ha scritto: >> >> see the manual about database callbacks. >> >> >> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update >> >> On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle wrote: >>> >>> Hello all. >>> >>> I would like to run a function everytime there is a modification in auth. >>> >>> something like: >>> auth.settings.onchange = lambda: myfunction() >>> >>> Or only if a specific field change: >>> auth.settings.myfield.onchange = lambda: myfunction() >>> >>> Is it possible? >>> >>> I need it for changing a field value in another db. >>> >>> Thanks, regards. >>> >>> -- 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] The shell on web2py does not execute any instruction
Good Morning users about web2py I am learning about web2py, I must to connect to Oracle data base, I want to test the conecction DAL from shell but it only shows "none", any instruction executed shows "none", someone knows why happen this?. 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: upload field type doesn't show in grid or smartgrid
Should work. Can you provide an example of code to reproduce? On Monday, 19 October 2015 23:20:05 UTC-5, 黄祥 wrote: > > hi, > > i have upload field type doesn't show in grid or smartgrid, in the older > version i believe it shown by default. is it normal in the recent version > (2.12.3) not shown the upload field type by default? > > ref: > http://web2py.com/books/default/chapter/29/03/overview#Adding-grids > > p.s. > in the book that i believe using the older version is shown by default > > 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: OS X Permissions question: echo works in ../web2py but not ../web2py/applications?
I do not know but you do seem to have permissions to write in that folder. You can use chmod and chown to restore those permissions. This could also be a problem with the filesystem. Some time permissions go bad in OSX and you have to use the Disk Utils to fix permissions and then reboot. On Monday, 19 October 2015 20:53:28 UTC-5, Tom Campbell wrote: > > In the most recent version of Mac OS X, if I'm in the web2py directory > this works fine: > > echo "# todo" >> README.md > > Yet if I'm in web2py/applications or any of its subdirectories I get a > "Permission denied" error. What incredibly stupid thing am I doing wrong? > > > > -- 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] Re: Can web2py "front-end" an API?
Hmm... Model-Less application shouldn't be regarded as a web2py application without model properly defined... Model-Less web2py application is just an application written with web2py where the models are not defined in the models/ folder of web2py to avoid cost of parsing models definition at each request... So some web2py users have developped the model-less approach that consist in the definition of the models into a modules which is then imported once... That way database models are not parsed at each request anymore... This is only required when your application need to scale up and performance start of getting an issue and you should start thinking to refactoring it to allow you app to support an raising charge related to the popularity of your web2py site a webapp. It may be worth to consider model-less approach also when you have many tables and the models files parsing start of getting an issue... Before take this path you really need to make sure what is the reason of your performance issue by profiling you application properly to find the bottle neck then start thinking on how you are going to resolve it and refactor your app. Model-Less issue come with some penality in term of web2py functionnalities, so you really want to take this path when you really need to. Further information about Model-Less : http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py Richard On Tue, Oct 20, 2015 at 6:22 AM, Luis Valladareswrote: > What if you use a model-less aplication? thats the way we handled this, we > have a web2py application that consumes a lot of microservices, this > application doesnt have any DB object and doesnt use the dal, it makes HTTP > request to the api inside the controllers (Using the python requests > library), format it and send to the views. > > > El domingo, 18 de octubre de 2015, 0:55:50 (UTC-4:30), pbreit escribió: >> >> Is there an easy way to use web2py to "front-end" and API? What I mean by >> that is that given a public API (for example, Stripe's API), could I write >> some models that correspond to the API structure and then call the DAL as >> if the API was a back-end DB? Does that make any sense? >> > -- > 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. > -- 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] The shell on web2py does not execute any instruction
shell sucks :P 2015-10-20 15:59 GMT+01:00 Vladimir Torres: > Good Morning users about web2py > > I am learning about web2py, I must to connect to Oracle data base, I want > to test the conecction DAL from shell but it only shows "none", any > instruction executed shows "none", > someone knows why happen this?. > > 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. > -- 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] Re: Can web2py "front-end" an API?
I think it's clear that by "model-less," Luis meant no db/database model definitions (at least not with regard to third party API's). In the past, the term "model-less" has also been used to describe an architecture that avoids use of files in the /models folder. The term is ambiguous because a "model" can either be a file in the /models folder or a database model (defined anywhere). On Tuesday, October 20, 2015 at 12:12:41 PM UTC-4, Richard wrote: > > Hmm... Model-Less application shouldn't be regarded as a web2py > application without model properly defined... Model-Less web2py application > is just an application written with web2py where the models are not defined > in the models/ folder of web2py to avoid cost of parsing models definition > at each request... So some web2py users have developped the model-less > approach that consist in the definition of the models into a modules which > is then imported once... That way database models are not parsed at each > request anymore... This is only required when your application need to > scale up and performance start of getting an issue and you should start > thinking to refactoring it to allow you app to support an raising charge > related to the popularity of your web2py site a webapp. It may be worth to > consider model-less approach also when you have many tables and the models > files parsing start of getting an issue... > > Before take this path you really need to make sure what is the reason of > your performance issue by profiling you application properly to find the > bottle neck then start thinking on how you are going to resolve it and > refactor your app. Model-Less issue come with some penality in term of > web2py functionnalities, so you really want to take this path when you > really need to. > > Further information about Model-Less : > > > http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications > > http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py > > Richard > > On Tue, Oct 20, 2015 at 6:22 AM, Luis Valladares < > luisvalladare...@gmail.com> wrote: > >> What if you use a model-less aplication? thats the way we handled this, >> we have a web2py application that consumes a lot of microservices, this >> application doesnt have any DB object and doesnt use the dal, it makes HTTP >> request to the api inside the controllers (Using the python requests >> library), format it and send to the views. >> >> >> El domingo, 18 de octubre de 2015, 0:55:50 (UTC-4:30), pbreit escribió: >>> >>> Is there an easy way to use web2py to "front-end" and API? What I mean >>> by that is that given a public API (for example, Stripe's API), could I >>> write some models that correspond to the API structure and then call the >>> DAL as if the API was a back-end DB? Does that make any sense? >>> >> -- >> 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. >> > > -- 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: Replace 'Log in' text in auth.navbar by 'User'
for what it's worth, my users also find it a little confusing, so there might be some value for web2py to change it. but this is an extremely unimportant and minor enhancement Alex Glaros -- 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] The shell on web2py does not execute any instruction
El martes, 20 de octubre de 2015, 18:06:36 (UTC+2), Ramos escribió: > > shell sucks :P > But the python shell rocks! python2 web2py.py -S your_app -M -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 1:24:50 PM UTC-7, Anthony wrote: > > Not sure I follow. If the 2 functions are in the same [controller] .py, then it is often just a matter of source control to ensure that they both exist at the same time. Introspection has its value, but also its costs. /dps -- 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: upload field type doesn't show in grid or smartgrid
yes, you are right, my bad, there is readable = False, set for the upload field type in the middle of somewhere (i couldn't found in the first place, but now target spoted and silenced :) ). 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: Ractive and Single Page Apps
A few months ago I decided to turn my existing, rather big and complex multi-page web2py app into a single page app. The plan is to load all the existing pages using web2py_component into the div#main_region, so that I get a working application as soon as possible, but then start to move view logic to the client, eventually calling web2py only for json data, and building the client pages using some kind of library of framework. I was already using jquery and bootstrap a lot (plus handsontable, ckeditor, jqplot...), so I had to use a library/framework compatible with that, and I didn't even consider angular and ember, since they seem to have their own way for doing everything. I did consider backbone+marionette, but I felt I was back to the Java days, writing a lot of code and getting nothing in return. I also felt like I had to duplicate work that was already done in web2py. Ractive definitely seems a better match fo web2py+jquery, to my limited experience, if you find a good way to organize your code. I found the following tutorial extremely helpful (it has 6 parts, I recommend you read at least the first 4 parts): http://paquitosoftware.com/ractive-js-tutorial-setting-up-your-environment/ It shows how to use ractive, webpack, page.js for routing, and proposes a nice folder structure for your code. It also shows you how to take advantage of webpack to compile ES6 into javascript real time, and you could use a similar trick for coffescript or something you like better than plain old javascript. -- 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: Running function after an auth db modification
perhaps an example can make it clear e.g. def __after_insert_auth_user(f, id): db.profile.insert(username = f.username, first_name = f.first_name, last_name = f.last_name, email = f.email) def __after_update_auth_user(s, f): auth_user = s.select().first() db(db.profile.auth_user == auth_user.id).update(username = auth_user.username, first_name = auth_user.first_name, last_name = auth_user.last_name, email = auth_user.email) # check condition if install controller (can't face bulk_insert in install controller with insert callback) if 'install' not in request.controller : db.auth_user._after_insert.append(__after_insert_auth_user) db.auth_user._after_update.append(__after_update_auth_user) 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: how to test if a controller function exists
Not sure I follow. -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 4:45:10 PM UTC-4, Dave S wrote: > > > > On Tuesday, October 20, 2015 at 1:24:50 PM UTC-7, Anthony wrote: >> >> Not sure I follow. > > > If the 2 functions are in the same [controller] .py, then it is often just > a matter of source control to ensure that they both exist at the same > time. Introspection has its value, but also its costs. > I assumed the requirement was to determine at runtime whether a particular requested function exists. Anthony -- 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] The shell on web2py does not execute any instruction
yes. the web shell sucks. The problem is that it cannot reliably remember the state across http requests. It really is only to explore the API. The python web2py shell on the other side... On Tuesday, 20 October 2015 16:09:01 UTC-5, p a wrote: > > El martes, 20 de octubre de 2015, 18:06:36 (UTC+2), Ramos escribió: >> >> shell sucks :P >> > > But the python shell rocks! > > python2 web2py.py -S your_app -M > > > -- 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: Running function after an auth db modification
On Tuesday, October 20, 2015 at 10:51:28 AM UTC-7, Gael Princivalle wrote: > > Thanks Anthony but what does it mean the proper signature? > I think in this case, he's referring to Python ... the def line of the function specifies its parameters (or arguments, if you prefer). Code that calls the function has to fill in the correct parameters. That's the function's signature. In this case, the caller defines the signature (because it is a call-back function) and the implementer has to make the def line fit. Above, you used a lambda function to munch around the parameters, but since no-one else calls the named function, you can just make the named function fit. /dps > > def add_phplist_user(f,id): > auth_user = db.auth_user(id) > #add user > db_phplist.phplist_user_user.insert( > email = auth_user.email, > confirmed = auth_user.newsletter) > > db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) > > I have to take the new record data from somewhere, and if I do that: > db.auth_user._after_insert.append(add_phplist_user(f,id)) > > Of course f and id are not defined. > > Il giorno martedì 20 ottobre 2015 18:38:18 UTC+2, Anthony ha scritto: >> >> Note, if you function already has the proper signature, there is no >> reason to wrap it in a lambda. Also, your callbacks do not have to return >> an empty dictionary (they are not controller actions). >> >> Anthony >> >> On Tuesday, October 20, 2015 at 9:19:20 AM UTC-4, Gael Princivalle wrote: >>> >>> Thanks Niphlod. >>> >>> After insert works great: >>> def add_phplist_user(f,id): >>> auth_user = db.auth_user(id) >>> #add user >>> db_phplist.phplist_user_user.insert( >>> email = auth_user.email, >>> confirmed = auth_user.newsletter) >>> return dict() >>> >>> db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) >>> >>> After update works well also: >>> >>> def update_phplist_user(s,f): >>> n_rows = db_phplist(db_phplist.phplist_user_user.email == s.email). >>> count() >>> if n_rows > 0: >>> #update confirmed >>> db_phplist(db_phplist.phplist_user_user.email == s.email).update >>> ( >>> confirmed = s.newsletter) >>> return dict() >>> >>> db.auth_user._after_update.append(lambda s,f: update_phplist_user(s,f)) >>> >>> But the after update run also after a new insert, and the f dictionary >>> is empty, so I've got a ticket. >>> >>> Do you know why? >>> Have you got a solution? >>> >>> Il giorno martedì 20 ottobre 2015 11:53:42 UTC+2, Niphlod ha scritto: see the manual about database callbacks. http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle wrote: > > Hello all. > > I would like to run a function everytime there is a modification in > auth. > > something like: > auth.settings.onchange = lambda: myfunction() > > Or only if a specific field change: > auth.settings.myfield.onchange = lambda: myfunction() > > Is it possible? > > I need it for changing a field value in another db. > > Thanks, regards. > > -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 3:31:43 PM UTC-7, Anthony wrote: > > On Tuesday, October 20, 2015 at 4:45:10 PM UTC-4, Dave S wrote: >> >> >> >> On Tuesday, October 20, 2015 at 1:24:50 PM UTC-7, Anthony wrote: >>> >>> Not sure I follow. >> >> >> If the 2 functions are in the same [controller] .py, then it is often >> just a matter of source control to ensure that they both exist at the same >> time. Introspection has its value, but also its costs. >> > > I assumed the requirement was to determine at runtime whether a particular > requested function exists. > Determining at runtime that a particular function exists seems expensive if you have control over the source file that defines the target and the function that needs to know. I imagine there is Python code that generates functions on the fly, and introspection would be needed to handle that properly, but I think that's a special case. Of course, I don't know for sure the OP's use case, so I may not be addressing those needs at all, but I like simple and cheap. /dps -- 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 test if a controller function exists
On Tuesday, October 20, 2015 at 4:25:00 PM UTC-7, Anthony wrote: > > Determining at runtime that a particular function exists seems expensive >> if you have control over the source file that defines the target and the >> function that needs to know. >> > > I don't see why it would be particularly expensive -- just a dictionary > lookup. We already have code like "if something in globals():" in some > places in the scaffolding app. > > Anyway, in the non-dynamic case, I'm not sure what role source control > would play. If you're making a fixed function call, you should simply know > what functions are available in your codebase (of course, there are various > IDE tools that can help identify all the available functions if you don't > have proper documentation or want to browse the source code). > Source control is just making sure that the rev of the file is the one with the definition and the usage. Overly verbose version: Many of us use source control in a pretty monotonic fashion ... just archiving the changes as we go along ... and I wouldn't expect most people to have an issue adding functions along the way, but some people have to support multiple versions, or to backdate something to analyze when and how a bug was introduced, and source control will make sure the new function's definition and its usage are in sync across those versions. /dps -- 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 test if a controller function exists
> > Determining at runtime that a particular function exists seems expensive > if you have control over the source file that defines the target and the > function that needs to know. > I don't see why it would be particularly expensive -- just a dictionary lookup. We already have code like "if something in globals():" in some places in the scaffolding app. Anyway, in the non-dynamic case, I'm not sure what role source control would play. If you're making a fixed function call, you should simply know what functions are available in your codebase (of course, there are various IDE tools that can help identify all the available functions if you don't have proper documentation or want to browse the source code). Anthony -- 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: Ractive and Single Page Apps
Hi p a, What you have described is basically where I am at. I have a large multi-page app. My plan is to start as you did and "component-ize" it and convert the bulk of the views to components I can then load with ajax. To convert it to a full-fledged SPA, I'd then start using ractive to move the view logic to the client side. I guess at this point, I'm trying to decide if going that further step is really worth it. (Besides the value of learning how to do it. That's always something I can do in another project). Ember, angular and backbone all seems to be overkill and involve a steep learning curve. That's why I was attracted to ractive--it's easy to learn. But even then, I am not sure how much is gained. As Niphold likes to point out, if it is about efficiency, the bottlneck in my app is db access and not generation of the views--that won't change no matter how much the view logic is pushed client side. So let me ask, was the conversion to a client side SPA worth it? Also, can I use just ractive and let web2py do the routing and some of the templating (I guess that sort of how Massimo did it in the estore project)? Thanks for the help!! Rod P.S. Thanks Niphold, crossroads.js looks simple enough. If I go the whole SPA route, I'll likely either use that or pages.js. On Tuesday, October 20, 2015 at 2:44:26 PM UTC-7, p a wrote: > > A few months ago I decided to turn my existing, rather big and complex > multi-page web2py app into a single page app. The plan is to load all the > existing pages using web2py_component into the div#main_region, so that I > get a working application as soon as possible, but then start to move view > logic to the client, eventually calling web2py only for json data, and > building the client pages using some kind of library of framework. > > I was already using jquery and bootstrap a lot (plus handsontable, > ckeditor, jqplot...), so I had to use a library/framework compatible with > that, and I didn't even consider angular and ember, since they seem to have > their own way for doing everything. > > I did consider backbone+marionette, but I felt I was back to the Java > days, writing a lot of code and getting nothing in return. I also felt like > I had to duplicate work that was already done in web2py. Ractive definitely > seems a better match fo web2py+jquery, to my limited experience, if you > find a good way to organize your code. > > I found the following tutorial extremely helpful (it has 6 parts, I > recommend you read at least the first 4 parts): > > http://paquitosoftware.com/ractive-js-tutorial-setting-up-your-environment/ > > It shows how to use ractive, webpack, page.js for routing, and proposes a > nice folder structure for your code. It also shows you how to take > advantage of webpack to compile ES6 into javascript real time, and you > could use a similar trick for coffescript or something you like better than > plain old javascript. > -- 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: Storing the Original Filename in the official web2py book
i think it's dillema in here if request.vars.image != None: # this work when the image is there, can't work if the image is empty (leave blank), it return an error traceback said : AttributeError: 'str' object has no attribute 'filename' if request.vars.image: # this work when the image is blank, but when you upload the file in image, the image_filename is empty / None tested in web2py recent version def create(table, fields, redirect): form = SQLFORM(table, fields = fields) #if current.request.vars.attachment: if current.request.vars.attachment != None: form.vars.attachment_filename = current.request.vars.attachment.filename if form.process().accepted: current.response.flash = 'Form accepted' #redirect(URL(redirect) ) elif form.errors: current.response.flash = 'Form has errors' else: current.response.flash = 'Please fill out the form' return dict(form = form) -- 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: Running function after an auth db modification
Thanks Niphlod. After insert works great: def add_phplist_user(f,id): auth_user = db.auth_user(id) #add user db_phplist.phplist_user_user.insert( email = auth_user.email, confirmed = auth_user.newsletter) return dict() db.auth_user._after_insert.append(lambda f,id: add_phplist_user(f,id)) After update works well also: def update_phplist_user(s,f): n_rows = db_phplist(db_phplist.phplist_user_user.email == s.email).count () if n_rows > 0: #update confirmed db_phplist(db_phplist.phplist_user_user.email == s.email).update( confirmed = s.newsletter) return dict() db.auth_user._after_update.append(lambda s,f: update_phplist_user(s,f)) But the after update run also after a new insert, and the f dictionary is empty, so I've got a ticket. Do you know why? Have you got a solution? Il giorno martedì 20 ottobre 2015 11:53:42 UTC+2, Niphlod ha scritto: > > see the manual about database callbacks. > > > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update > > On Tuesday, October 20, 2015 at 11:49:02 AM UTC+2, Gael Princivalle wrote: >> >> Hello all. >> >> I would like to run a function everytime there is a modification in auth. >> >> something like: >> auth.settings.onchange = lambda: myfunction() >> >> Or only if a specific field change: >> auth.settings.myfield.onchange = lambda: myfunction() >> >> Is it possible? >> >> I need it for changing a field value in another db. >> >> Thanks, regards. >> >> -- 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 test if a controller function exists
Thanks for the detailed explanation. Op dinsdag 20 oktober 2015 03:11:53 UTC+2 schreef Anthony: > > If you have the function name, you can do: > > if function_name in globals(): > > And if you have the actual function object, you can do: > > if function.__name__ in globals(): > > Note, those will yield hits even if there is an object of that name > defined in a model file. If that is a concern, you can diff the globals > before and after executing the controller to get a list of objects > specifically defined in the controller. To do that, at the top of the > controller file (or anywhere before the first component you want to > register): > > pre_controller_objects = dir() > > Then at the bottom of the controller (or after the last component): > > controller_objects = set(dir()) - set(pre_controller_objects) > > Then, wherever you want to test for the existence of a function: > > if function_name in controller_objects: > > Note, that will identify any objects defined in the controller, even if > they are not functions. If that's a concern, you can further filter > controller_objects to include only function objects. > > Finally, if you only want to identify specific actions that your have > defined as components, you could use a special prefix/postfix to identify > them, or just manually maintain a list of their names. One other option > would be to create a decorator that registers a component name in a special > object. In a module or model file, or at the top of the controller: > > class Component(object): > def __init__(self): > self.names = [] > > def __call__(self, f): > self.names.append(f.__name__) > return f > > component = Component() > > Then you would decorate components: > > @component > def component1(): > return dict() > > @component > def component2(): > return dict() > > Finally, wherever needed, check for a component as follows: > > if 'component1' in component.names: > > Anthony > > On Monday, October 19, 2015 at 4:19:30 PM UTC-4, A3 wrote: >> >> >> I want to be able to test if a certain function exists in a controller. >> (I am loading a component with help of another) >> >> controller: >> default.py >> def myfunction() >> return >> >> def mytest() >> if exists(myfunction()): >>do this. >> > -- 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.