Re: [web2py] Re: Partial flush of request
On Saturday, October 1, 2016 at 4:19:59 PM UTC-4, Luis Valladares wrote: > > They expire, when I generate a new token I store it in the database and > send to the user browser, each time the token is expired I generate a new > one, overwrite the token in the database (and because this the other token > is lost) and sent to the user. > I'm not sure I understand. Every HTTP request is wrapped in a database transaction, so if an error occurs during a request, any database operations that had been made prior to the error will be rolled back before returning the error response. So, how is it that your token overwriting is not being rolled back upon error? 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: modify default scaffolding (welcome app) welcome user logged in (top right)
sorry, my bad, i missed the step 5, it more simple, just modify the layout.html *views/layout.html* {{ #string_representation = "%(first_name)s" #string_representation = "%(last_name)s" #string_representation = "%(first_name)s %(last_name)s" string_representation = "%(username)s" }} {{='auth' in globals() and auth.navbar('Welcome',user_identifier=string_representation,mode='dropdown') or ''}} thanks all and 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 key error on simple table with one record
Never stop asking me to post anything Anthony! format='%(invoice_number)s - %(company)s - %(status)s - %(date)s') changed to format='%(invoice_number)s - %(company)s - %(status)s - %(issue_date)s') problem sorted! I must have looked at that table a dozen times and had, at least temporarily, moved on to other things, I never saw that until I had to 'expose' the code by posting it and forced me to check it again but perhaps more carefully! Very happy it's sorted and I'm not in the least surprised it's my own error as web2py seems extremely robust! Thanks for not losing interest in the issue! Peter -- 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 key error on simple table with one record
If there is anything stupid here Anthony, please remember I am a novice at this! db.define_table('invoice', Field( 'invoice_number' , 'integer' , writable=False), Field( 'company' , writable=False), Field( 'amount' , 'decimal(6,2)' , writable=False), Field( 'issue_date' , 'datetime' , writable=False), Field( 'status' , default='ISSUED',requires=IS_IN_SET(INVOICE_STATUS)), Field( 'payment_ref' , writable=False), Field( 'payment_amount' , 'double'), Field( 'notes' , 'text',default=None ), Field( 'created_by' , db.auth_user , default=me , readable=False , writable=False), Field( 'created_on' , 'datetime' , default=request.now , readable=False , writable=False), format='%(invoice_number)s - %(company)s - %(status)s - %(date)s') db.define_table('task', Field( 'task_type' , default='COUNSELLING' , requires=IS_IN_SET(TASK_TYPES) , comment="*" ), Field( 'task_status', default='CLIENT CONFIRMED' , requires=IS_IN_SET(TASK_STATUS) , comment="*"), Field( 'start_time' , 'datetime' , default=request.now ,requires=IS_NOT_EMPTY() , comment="*"), Field( 'duration' , default='1Hr' ), Field( 'title' , default="Session ##" , requires=IS_NOT_EMPTY() , comment="*"), Field( 'person' , 'reference person' , comment="*"), Field( 'details', 'text' ,default=None ), Field( 'charge' , 'double' , default=0.0), Field( 'charge_to' , default='COMPANY' , requires=IS_IN_SET(CHARGE_TO) , comment="* [COMPANY for Invoicing, CONTACT for Receipting]"), Field( 'payment_status' , default='BILLABLE' , requires=IS_IN_SET(PAYMENT_STATUS) , comment="* [BILLABLE for Invoicing & Receipting]"), Field( 'invoice_number' , 'integer' , default=None , writable=False ), Field( 'payment_ref', 'integer',default=None , writable=False ), Field( 'created_by' , db.auth_user , default=me , writable=False , readable=False ), Field( 'created_on' , 'datetime' , default=request.now , writable=False , readable=False ), format= '%(person)s / %(start_time)s / %(title)s / € %(charge)s') -- 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: Partial flush of request
They expire, when I generate a new token I store it in the database and send to the user browser, each time the token is expired I generate a new one, overwrite the token in the database (and because this the other token is lost) and sent to the user. But that's not really my problem (maybe I don't explain it well in the last post) what I want to do is send a partial response to the user browser and then keep processing. specifically I want to set a cookie in the browser and then I will continue data processing. Thanks for your help Anthony! El sáb., oct. 1, 2016 2:10 PM, Anthony escribió: > On Saturday, October 1, 2016 at 9:52:18 AM UTC-4, > luis.vallada...@metamaxzone.com wrote: > > Hello! > > Im creating a website with a microservices architecture, and for > authentication i'm using JWT token stored in the cookies, this tokens are > automatically renewed each 5 minutes, the basic flow of this is: > > 1 My front end makes a request to a microservice > 2 The microservice check if the token its expired > 3 If its expired check if its the same stored in our database > 4 If its the same generate a new token, and send it to the front end > 4.1 If its not the same answer a Non-authorized response to the front end > 5 My web2py front end will change the token cookie for the new one. > > My problem happens if (by any problem) i get a ticket on web2py, when this > happens the new cookie are not sended in the response, the user still > storing the old token, and the next time it makes a petition the step 3 > isnt found and close the user session > > > Are you saying the record is not in the database on the next attempt? If > not, why not? What happens to the record during the initial request? > > > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/Dx52cLv-8-Y/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: A simple request for the "so old and so good admin"
Thanks , as always... 2016-10-01 19:05 GMT+01:00 Anthony : > If you want to do it using the /appadmin/manage functionality, you can add > something like the following to a model file: > > def make_clone_link(r): > tablename = request.args(2) > index = db.tables.index(tablename) > return URL('appadmin', 'manage.load', args=['db', index, tablename, > 'new', tablename], >vars=dict(clone_id=r.id), user_signature=True, hash_vars= > False) > > auth.settings.manager_actions = dict( > db=dict(role='admin', tables=db.tables, > smartgrid_args=dict( > DEFAULT=dict(links=[lambda r: A(SPAN('Clone', > _class='buttontext > button'), > cid=request.cid, _href= > make_clone_link(r), > _class='button btn > btn-default')])) > ) > ) > > if request.controller == 'appadmin' and 'clone_id' in request.get_vars: > table = db[request.args(2)] > record = table[int(request.vars.clone_id)] > for field in table: > if field.type != 'id': > field.default = record[field.name] > > Then make sure you have the role "admin" and go to /appadmin/manage/db. > You'll be able to browse all the database tables via SQLFORM.smartgrid, and > each record will have a "Clone" button. > > Note, the /appadmin/manage UI depends somewhat on Bootstrap, so if you're > not using Bootstrap, you may have to make sure it is loaded at least for > /appadmin/manage requests. > > 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. > -- 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: modify default scaffolding (welcome app) welcome user logged in (top right)
On Friday, September 30, 2016 at 5:36:26 PM UTC-4, 黄祥 wrote: > > thank you so much marlysson for detail explaination. > i change it in gluon/tools.py > around line 2004 > if user_identifier is DEFAULT: > #user_identifier = '%(first_name)s' > #user_identifier = '%(first_name)s %(last_name)s' > user_identifier = '%(username)s' > No, don't change the framework code. Just change the call to auth.navbar() in layout.html, as instructed. You don't want to have to maintain a fork of the framework when there is an existing API to handle the change. 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: Partial flush of request
On Saturday, October 1, 2016 at 9:52:18 AM UTC-4, luis.vallada...@metamaxzone.com wrote: > > Hello! > > Im creating a website with a microservices architecture, and for > authentication i'm using JWT token stored in the cookies, this tokens are > automatically renewed each 5 minutes, the basic flow of this is: > > 1 My front end makes a request to a microservice > 2 The microservice check if the token its expired > 3 If its expired check if its the same stored in our database > 4 If its the same generate a new token, and send it to the front end > 4.1 If its not the same answer a Non-authorized response to the front end > 5 My web2py front end will change the token cookie for the new one. > > My problem happens if (by any problem) i get a ticket on web2py, when this > happens the new cookie are not sended in the response, the user still > storing the old token, and the next time it makes a petition the step 3 > isnt found and close the user session > Are you saying the record is not in the database on the next attempt? If not, why not? What happens to the record during the initial request? 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: A simple request for the "so old and so good admin"
If you want to do it using the /appadmin/manage functionality, you can add something like the following to a model file: def make_clone_link(r): tablename = request.args(2) index = db.tables.index(tablename) return URL('appadmin', 'manage.load', args=['db', index, tablename, 'new', tablename], vars=dict(clone_id=r.id), user_signature=True, hash_vars= False) auth.settings.manager_actions = dict( db=dict(role='admin', tables=db.tables, smartgrid_args=dict( DEFAULT=dict(links=[lambda r: A(SPAN('Clone', _class='buttontext button'), cid=request.cid, _href= make_clone_link(r), _class='button btn btn-default')])) ) ) if request.controller == 'appadmin' and 'clone_id' in request.get_vars: table = db[request.args(2)] record = table[int(request.vars.clone_id)] for field in table: if field.type != 'id': field.default = record[field.name] Then make sure you have the role "admin" and go to /appadmin/manage/db. You'll be able to browse all the database tables via SQLFORM.smartgrid, and each record will have a "Clone" button. Note, the /appadmin/manage UI depends somewhat on Bootstrap, so if you're not using Bootstrap, you may have to make sure it is loaded at least for /appadmin/manage requests. 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] A simple request for the "so old and so good admin"
On Saturday, October 1, 2016 at 10:18:55 AM UTC-4, Manuele wrote: > > Il 30/09/16 19:47, António Ramos ha scritto: > > Hello, i would like to suggest the ability to duplicate a record in > > admin. > > > > It would make me happy :) > what about doing it in your web2py console with something like: > db.table[0] = {k: v for k,v in db.table[id].iteritems() if k!='id'} > A little simpler: db.mytable.insert(db.mytable._filter_fields(db.mytable(id))) 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: modify default scaffolding (welcome app) welcome user logged in (top right)
So you are changing framework's default behavior , when you update latest version , likely your script inserted in tools.py will cleaned. The web2py give you ways to define it by parameters.. but.. Anyway you are welcome Em sexta-feira, 30 de setembro de 2016 18:36:26 UTC-3, 黄祥 escreveu: > > thank you so much marlysson for detail explaination. > i change it in gluon/tools.py > around line 2004 > if user_identifier is DEFAULT: > #user_identifier = '%(first_name)s' > #user_identifier = '%(first_name)s %(last_name)s' > user_identifier = '%(username)s' > > thanks and 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.
Re: [web2py] A simple request for the "so old and so good admin"
Il 30/09/16 19:47, António Ramos ha scritto: > Hello, i would like to suggest the ability to duplicate a record in > admin. > > It would make me happy :) what about doing it in your web2py console with something like: db.table[0] = {k: v for k,v in db.table[id].iteritems() if k!='id'} M. > > Regards > António -- 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] Partial flush of request
Hello! Im creating a website with a microservices architecture, and for authentication i'm using JWT token stored in the cookies, this tokens are automatically renewed each 5 minutes, the basic flow of this is: 1 My front end makes a request to a microservice 2 The microservice check if the token its expired 3 If its expired check if its the same stored in our database 4 If its the same generate a new token, and send it to the front end 4.1 If its not the same answer a Non-authorized response to the front end 5 My web2py front end will change the token cookie for the new one. My problem happens if (by any problem) i get a ticket on web2py, when this happens the new cookie are not sended in the response, the user still storing the old token, and the next time it makes a petition the step 3 isnt found and close the user session So, bottom line: What i want to do is "flush" (Php like: http://php.net/manual/es/function.flush.php) the cookie to the browser and after that still managing the response (because i want to format the response, send to a view...) Its important to say that the functionality of token renewal and request is stored in a module Thanks a lot! -- 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 key error on simple table with one record
Let's see the table definitions for db.invoice and db.task. Anthony On Friday, September 30, 2016 at 8:42:22 PM UTC-4, Peter wrote: > > > ...you should just remove the version of pydal you have in the >> dist-packages folder on your system. >> > >- renamed the system installed dal directory >- restored the table definition to the version originally causing >Traceback >- the form now opens without Traceback :-) > > > > [edit] > > *Sorry Anthony I had posted that it was resolved but actually it's not. * > The default dal version with the web2py install is Version 16.03 > and list open files confirms the dal in use is the web2py one. > > I think I can work with the adjusted line as I'm not sure it was needed as > originally defined. > Having made the recommended corrections I'm assuming that's it's something > stupid I have done > though no idea what as yet. If I find it I will post here for the record. > > Go raibh mile maith agat (*Thank you very much!*) Anthony for the support! > > Peter > > -- 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: set individual action's transaction mode
a transaction is live from the first command you execute AFTER the first commit() or rollback(). Web2py automatically commit() at the end of a request, or rollback() in case an error occurred. Everything runs separated in each thread (which means every thread runs its own transaction) and - usually - web2py maps a single thread on a single request. Even an ajax request from the same page runs in a separate transaction. Everything is consistent in the smallest "frame" http can assure: a web request/response cycle. Everything that runs in separate processes can't share the same transaction. When you queue you task in the controller, the action of queueing runs in the same transaction of the request that posted the form. When the action is executed in the scheduler, which is an external process, it runs in its own transaction, completely decoupled from the web ones. So, again, don't even think to fiddle with postgresql parameters or try to make two python processes to work in the same transaction: it's a no-go. You need to redesign your app's workflow to coincide with your mind-model of what should happen. Welcome to coder's world ^_^ On Friday, September 30, 2016 at 11:56:11 PM UTC+2, Pierre wrote: > > > what's are the situations where I can't survive a transaction ? do you > mean queueing tasks in a controller function ? > > how do I work this out in a single process action? > > > > > > > > > > > > > -- 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: Impersonate in Layers...
Still looking for a reply for this message! C'mon, it's only been...what... 2-1/2 years?? Seriously. I was just looking at this again and thought to myself, "I remember asking that on web2py-user... I wonder if I missed the response?" Turns out I didn't! -- Joe On Thursday, April 17, 2014 at 12:26:11 AM UTC-7, Joe Barnhart wrote: > > I find I need the "impersonate" feature for a website I'm building -- it > is the perfect solution to supporting users who forget how to work the > website or need help setting up their profile information. In fact, I have > a group called "support" who I am tasking with this chore and I want them > to be able impersonate any of the users. > > EXCEPT, of course, me. I have a group for the people who run and control > every aspect of the website, and only my partner and I have logons at this > level. I don't want any "support" group members to be able to impersonate > my "root" group. I may add a "manager" group at some point who should also > not be accessible to the support staff. I guess I should also prevent > support staff from impersonating each other as well. I'm no killjoy, but I > want to prevent "pranking" and epic April Fools jokes between my support > reps before they even get started. > > And I, of course, as "root" want to be able to impersonate anybody on my > site. The only difference between me and the NSA is that my employees > won't have to wonder or guess if I'm looking over their shoulder -- I'll > tell them straight up! (just kidding. NSA also has a larger budget and > cooler toys. there are actually several differences) > > I can see how I can add an "impersonate" group, and add it to either the > auth_user table or specific rows, but that doesn't give me the layers I'm > looking for. That is: > > support --> impersonate users > managers --> impersonate support, users > root --> impersonate all of the above > > Have I missed something obvious? > > -- Joe "benevolent dictator" B. > > -- 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.