[web2py] Error message customization
So I have a form with field which looks like this. I want the error message to display in red though, how do I do it? Thanks. edit_user_form= SQLFORM.factory ( Field('name', 'string', requires=IS_NOT_EMPTY(error_message='Enter your name')) ) -- 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] Streaming a file
I need to place a button which opens an online PDF and so far I have this in reg.py controller def streamable(): data = urllib2.urlopen("http://www.pdf995.com/samples/pdf.pdf";) return response.stream(data, 4096) And this in the view {{=A('open file', _class="btn btn-sm", _href=URL('reg', 'streamable'))}} Although this only gives me stream output so a bunch of characters and not actual pdf, anyone knows how to fix this? 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] Re: Streaming a file
Thank you so much! On Thursday, July 27, 2017 at 3:03:17 PM UTC+2, Leonel Câmara wrote: > > You need to set content-type to pdf. > > response.headers['Content-Type'] = 'application/pdf' > > before returning response.stream > > -- 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] Calling a controller function from the view
Hello! I need to call controller function from a jquery script in view and store the returned dict into some variable. Looks something like this: controller.py def my_function(): return dict() my_view.html jQuery(document).ready(function(){ var my_dict = ... }); Any help appreciated, thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Calling a controller function from the view
EDIT: I found something like this controller.py def my_function(): my_dict = dict() return response.render('my_view.html, my_dict) my_view.html jQuery(document).ready(function(){ ajax('{{=URL('my_function')}}',[],'f2'); }); Although this just basically put my entire page into the f2 div and inserted no dict... Where did I go wrong? On Thursday, August 3, 2017 at 11:01:00 AM UTC+2, Simona Chovancová wrote: > > Hello! > > I need to call controller function from a jquery script in view and store > the returned dict into some variable. Looks something like this: > > controller.py > > def my_function(): > return dict() > > > my_view.html > > > jQuery(document).ready(function(){ > var my_dict = ... > }); > > > Any help appreciated, thanks! > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Require field length 9 or 13
I need to set my tel_num field requirement to be of length 9 or 13, yet I only found a way how to do this from 9 to 13 or specifically just one of these.. How can I set it to 9 or 13? 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: Require field length 9 or 13
Thank you! On Wednesday, August 9, 2017 at 1:08:12 PM UTC+2, Leonel Câmara wrote: > > requires=ANY_OF([IS_LENGTH(minsize=9, maxsize=9), IS_LENGTH(minsize=13, > maxsize=13, error_message='Must be 9 or 13 characters')]) > -- 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] Change value of select
I need to change selected option in the view, I know that to change input value I do it like this: {{form.element('input', _name='field')['_value'] = "new_value"}}, but how do I do this with select? Also, this needs to be done in view, not controller so I cannot use default='some_option'. Any ideas? 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] Login 'remember me' not working
Hello, I'm trying to add remember_me option to my auth login form and so far it looks like this: controller.py def index(): auth.settings.remember_me_form=True auth.settings.long_expiration = 3600*24*30 form = auth() return dict(form=form) view.html {{=form.custom.begin}} {{=form.custom.widget.email}} {{=form.custom.widget.password}} {{=form.custom.widget.remember_me}} {{=form.custom.widget.submit}} {{=form.custom.end}} It doesn't display the remember_me option nor remembers anything, anyone knows where the problem is? -- 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: Login 'remember me' not working
Apparently some other code I had in controller was breaking functionality of this, now I reached the point when it actually displays the remember button, although upon successful login and log out it doesn't actually remember my info and nothing gets filled into the login form. On Thursday, August 24, 2017 at 5:04:02 PM UTC+2, Anthony wrote: > > > controller.py >> def index(): >> auth.settings.remember_me_form=True >> auth.settings.long_expiration = 3600*24*30 >> form = auth() >> return dict(form=form) >> >> view.html >> {{=form.custom.begin}} >> {{=form.custom.widget.email}} >> {{=form.custom.widget.password}} >> {{=form.custom.widget.remember_me}} >> {{=form.custom.widget.submit}} >> {{=form.custom.end}} >> > > I cannot reproduce the problem -- using the exact code above, I do see a > checkbox added to the form. However, you have not included any of the field > labels, so the checkbox has no label (the label is in > form.custom.label.remember_me). > > Also, there is no form.custom.widget.submit, so you probably see the word > "None" right after the checkbox instead of seeing the login button. > Instead, it should just be form.custom.submit. > > Finally, when you call auth() and there are no URL args to indicate which > auth action you want (i.e., login, register, etc.), auth will force a > redirect to the current URL with /login appended. If you don't want that > and instead just want to display a login form on the index page, then > instead of calling auth(), call auth.login(). > > 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: Login 'remember me' not working
Ah, thank you so much :) On Friday, August 25, 2017 at 1:56:33 PM UTC+2, Anthony wrote: > > That's not what the remember me option is supposed to do -- it does not > automatically fill in the login form if you are logged out. Without the > remember me option checked, a login lasts only as long as the browser > session -- if you close the browser and then open it again, you will no > longer be logged in (because login status is maintained in a session > cookie, which expires with the browser session). The remember me option > changes the cookie from a session cookie to a non-session cookie with a > longer expiration -- so even if you close the browser and come back > sometime later, you will still be logged in. > > However, even if you log in with the remember me option checked, if you > explicitly log out, you will not remain logged in -- you must log in again > to be re-authenticated. > > Anthony > > On Friday, August 25, 2017 at 2:00:55 AM UTC-4, Simona Chovancová wrote: >> >> Apparently some other code I had in controller was breaking functionality >> of this, now I reached the point when it actually displays the remember >> button, although upon successful login and log out it doesn't actually >> remember my info and nothing gets filled into the login form. >> >> On Thursday, August 24, 2017 at 5:04:02 PM UTC+2, Anthony wrote: >>> >>> >>> controller.py >>>> def index(): >>>> auth.settings.remember_me_form=True >>>> auth.settings.long_expiration = 3600*24*30 >>>> form = auth() >>>> return dict(form=form) >>>> >>>> view.html >>>> {{=form.custom.begin}} >>>> {{=form.custom.widget.email}} >>>> {{=form.custom.widget.password}} >>>> {{=form.custom.widget.remember_me}} >>>> {{=form.custom.widget.submit}} >>>> {{=form.custom.end}} >>>> >>> >>> I cannot reproduce the problem -- using the exact code above, I do see a >>> checkbox added to the form. However, you have not included any of the field >>> labels, so the checkbox has no label (the label is in >>> form.custom.label.remember_me). >>> >>> Also, there is no form.custom.widget.submit, so you probably see the >>> word "None" right after the checkbox instead of seeing the login button. >>> Instead, it should just be form.custom.submit. >>> >>> Finally, when you call auth() and there are no URL args to indicate >>> which auth action you want (i.e., login, register, etc.), auth will force a >>> redirect to the current URL with /login appended. If you don't want that >>> and instead just want to display a login form on the index page, then >>> instead of calling auth(), call auth.login(). >>> >>> 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] Changing password error message
I have a table defined like this: form_change_password = auth.change_password() form_change_password.element( 'input', _name='old_password')['_id'] = 'form-4' form_change_password.element( 'input', _name='new_password')['_id'] = 'form-5' form_change_password.element( 'input', _name='new_password2')['_id'] = 'form-6' When I leave all fields empty, the new_password has same error_message as any other password, edited using db.auth_user.password.requires = ..., but the old_password has just 'Too short' as error_message, how do I change old_password's error_message? 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] Re: Changing password error message
Because if user submits my change_password form and leaves everything empty, I do not want 'Too short' to be error message for the old password field but rather something different.. and that did not change the error_message on it On Wednesday, September 6, 2017 at 5:27:33 PM UTC+2, Anthony wrote: > > Why do you want to validate the old password? The only requirement should > be that it actually matches the old password, and therefore the only error > message you would want to report is that the password doesn't match (which > can be customized via auth.messages.invalid_password). > > Anthony > > On Wednesday, September 6, 2017 at 6:08:00 AM UTC-4, Simona Chovancová > wrote: >> >> I have a table defined like this: >> >> form_change_password = auth.change_password() >> form_change_password.element( >> 'input', _name='old_password')['_id'] = 'form-4' >> form_change_password.element( >> 'input', _name='new_password')['_id'] = 'form-5' >> form_change_password.element( >> 'input', _name='new_password2')['_id'] = 'form-6' >> >> When I leave all fields empty, the new_password has same error_message as >> any other password, edited using db.auth_user.password.requires = ..., but >> the old_password has just 'Too short' as error_message, how do I change >> old_password's error_message? >> 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] Optimization of js and css error
I am trying to use *response.optimize_js = 'concat,minify,inline' *and *response.optimize_css = 'concat,minify,inline' *in 10_db.py in order to optimize my code, but it gives me this error: Traceback (most recent call last): File "/srv/www/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/srv/www/web2py/applications/iadev/views/errors/500.html", line 56, in File "/srv/www/web2py/gluon/globals.py", line 514, in include_files time_expire) File "/srv/www/web2py/gluon/cache.py", line 253, in __call__ value = f() File "/srv/www/web2py/gluon/globals.py", line 509, in call_minify self.optimize_js) File "/srv/www/web2py/gluon/contrib/minify/minify.py", line 101, in minify contents = read_binary_file(abs_filename) File "/srv/www/web2py/gluon/contrib/minify/minify.py", line 19, in read_binary_file f = open(filename, 'rb') IOError: [Errno 2] Adresář nebo soubor neexistuje: '/srv/www/web2py/applications/iadev/static/tatic/js/jquery.min.js' Also, this 'tatic' is nowhere in my code nor directories, what am I doing wrong? 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: Optimization of js and css error
Update: My mistake, I had bad routes, solved On Monday, September 11, 2017 at 9:18:56 AM UTC+2, Simona Chovancová wrote: > > I am trying to use *response.optimize_js = 'concat,minify,inline' *and > *response.optimize_css > = 'concat,minify,inline' *in 10_db.py in order to optimize my code, but > it gives me this error: > > Traceback (most recent call last): > File "/srv/www/web2py/gluon/restricted.py", line 227, in restricted > exec ccode in environment > File "/srv/www/web2py/applications/iadev/views/errors/500.html", line 56, > in > File "/srv/www/web2py/gluon/globals.py", line 514, in include_files > time_expire) > File "/srv/www/web2py/gluon/cache.py", line 253, in __call__ > value = f() > File "/srv/www/web2py/gluon/globals.py", line 509, in call_minify > self.optimize_js) > File "/srv/www/web2py/gluon/contrib/minify/minify.py", line 101, in minify > contents = read_binary_file(abs_filename) > File "/srv/www/web2py/gluon/contrib/minify/minify.py", line 19, in > read_binary_file > f = open(filename, 'rb') > IOError: [Errno 2] Adresář nebo soubor neexistuje: > '/srv/www/web2py/applications/iadev/static/tatic/js/jquery.min.js' > > > > Also, this 'tatic' is nowhere in my code nor directories, what am I doing > wrong? 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] Select defined with variable
I need to make a select like this: *db(db.table.id == 1).select(db.table.name, db.table.date).first()* but what attributes need to be selected always change so I'd need something like this: *selects = (db.table.name, db.table.date, ..)* *db(db.table.id == 1).select(selects).first()* But this does not work, how do I determine what to select with a variable, if possible? 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] Dynamically changing requirement of field in form
Hello. I have a form in web2py that controls editing and adding new user. But some fields need different requirements based on when user is being added or edited. Can I somehow change field requirements in view? I can only detect this in view. So far I came up with something like this, but it does not work. {{userform.custom.widget.name['requires'] = IS_EMAIL(error_message='invalid email!')}} Any ideas? Thanks for help. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Dynamically changing requirement of field in form
figured out no longer needed On Wednesday, November 22, 2017 at 12:49:23 PM UTC+1, Simona Chovancová wrote: > > Hello. > > I have a form in web2py that controls editing and adding new user. But > some fields need different requirements based on when user is being added > or edited. Can I somehow change field requirements in view? I can only > detect this in view. So far I came up with something like this, but it does > not work. > > {{userform.custom.widget.name['requires'] = > IS_EMAIL(error_message='invalid email!')}} > > Any ideas? Thanks for help. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Web2py scheduler
Hello, I'm having trouble using the scheduler. I have managed to set it up to queue tasks and successfully complete them. Although, that only works if I do not use database. If I include db in function that is tasked, I get this: Traceback (most recent call last): File "/srv/www/web2py/gluon/shell.py", line 273, in run exec(python_code, _env) File "", line 1, in File "/srv/www/web2py/gluon/scheduler.py", line 735, in loop self.wrapped_report_task(task, self.async(task)) File "/srv/www/web2py/gluon/scheduler.py", line 889, in wrapped_report_task db.rollback() File "/srv/www/web2py/gluon/packages/dal/pydal/base.py", line 956, in rollback self._adapter.rollback() File "/srv/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1342, in rollback return self.connection.rollback() File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1429, in rollback self.execute(self._cursor, "rollback", None) File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1626, in execute self.handle_messages(cursor) File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1774, in handle_messages raise self.error ProgrammingError: ('ERROR', '42P05', 'prepared statement "pg8000_statement_13" already exists') Also, if I do just simple inserts like db.table.insert(something="abc"), I also include db.commit(), I get this error: Database drivers available: sqlite3, imaplib, pymysql, pg8000 starting single-scheduler for "myapp"... ERROR:web2py.scheduler.servername#3711:error storing result Can someone please point me to the right direction? 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: Web2py scheduler
solved, ran worker in different application than the task was sent from On Tuesday, February 6, 2018 at 2:34:24 PM UTC+1, Simona Chovancová wrote: > > Hello, > > I'm having trouble using the scheduler. I have managed to set it up to > queue tasks and successfully complete them. Although, that only works if I > do not use database. If I include db in function that is tasked, I get this: > > Traceback (most recent call last): > File "/srv/www/web2py/gluon/shell.py", line 273, in run > exec(python_code, _env) > File "", line 1, in > File "/srv/www/web2py/gluon/scheduler.py", line 735, in loop > self.wrapped_report_task(task, self.async(task)) > File "/srv/www/web2py/gluon/scheduler.py", line 889, in > wrapped_report_task > db.rollback() > File "/srv/www/web2py/gluon/packages/dal/pydal/base.py", line 956, in > rollback > self._adapter.rollback() > File "/srv/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line > 1342, in rollback > return self.connection.rollback() > File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1429, in > rollback > self.execute(self._cursor, "rollback", None) > File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1626, in > execute > self.handle_messages(cursor) > File "/srv/www/web2py/gluon/contrib/pg8000/core.py", line 1774, in > handle_messages > raise self.error > ProgrammingError: ('ERROR', '42P05', 'prepared statement > "pg8000_statement_13" already exists') > > Also, if I do just simple inserts like db.table.insert(something="abc"), I > also include db.commit(), I get this error: > > Database drivers available: sqlite3, imaplib, pymysql, pg8000 > starting single-scheduler for "myapp"... > ERROR:web2py.scheduler.servername#3711:error storing result > > > Can someone please point me to the right direction? > 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] Select returns non existent fields
Hello, I have a problem with select.. I have these tables defined: db.define_table( 'email', Field('recipient', 'string', notnull=True), Field('subject', 'string', length=256, notnull=False), Field('body', 'text', notnull=False), Field('html_body', 'text', notnull=False), ) self.db.define_table( 'attachment', Field('file_blob_id'), Field('email_id', db.email, notnull=False) ) When I insert something into email table and make select like db(db.email).slelect(), it returns something like this: , 'id': 27L}> Why is there the attachment field? How do I remove it to just select real fields and not relations with other tables? 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] Scheduler not creating its tables
Hello, I am trying to use scheduler for the first time in my app and I cannot get it to work. Tables for scheduler are never really created. This is my model scheduler.py: from gluon.scheduler import Scheduler from gluon import current scheduler = Scheduler( storage.mailer_db, tasks={'send_email': Sender(db).send()}, utc_time=True) current.scheduler = scheduler Now, when I get to schedule a task like this scheduler.queue_task( 'send_email', pvars={'queue_id': some_id}, start_time=datetime.datetime.utcnow(), stop_time=datetime.datetime.utcnow() + datetime.timedelta(seconds=600), application_name="app") Noting really happens, also worth nothing when I try to start workers with python web2py.py -K app I get this error: NameError: global name 'urllib' is not defined Any idea on what I might be doing wrong? 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 filename to a streamed file
Hello. I have a backend function that is supposed to stream a pdf file, but not instantly download it. It's being called like this .../function_to_create_pdf/323, where the number is some ID. I create a FPDF stream and make function return this response.headers['Content-Type'] = None return response.stream(pdf_stream, 4096, filename="iwanthisname.pdf") Soo the problem is, this works well if I set attachment=True, but since I only want to display this pdf file, the filename is not applied in any way. I get the right document and all that, but the browser tab title is basically just the argument (ID) I passed to the function and if I press the download button it is saved as 323.pdf. I want to edit its name, how can I do this? I tried changing tab name with reponse.title, but it didn't work. 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] Re: Setting filename to a streamed file
Thanks, worked On Thursday, September 13, 2018 at 5:18:25 PM UTC+2, tim.n...@conted.ox.ac.uk wrote: > > Are you setting the PDF's title before streaming it? > > pdf.set_title('Whatever you want to appear in the tab') > pdf_stream = pdf.output(dest='S') > > > > On Thursday, 6 September 2018 13:16:32 UTC+1, Simona Chovancová wrote: >> >> Hello. >> I have a backend function that is supposed to stream a pdf file, but not >> instantly download it. It's being called like this >> .../function_to_create_pdf/323, where the number is some ID. I create a >> FPDF stream and make function return this >> response.headers['Content-Type'] = None >> return response.stream(pdf_stream, 4096, filename="iwanthisname.pdf") >> >> Soo the problem is, this works well if I set attachment=True, but since I >> only want to display this pdf file, the filename is not applied in any way. >> I get the right document and all that, but the browser tab title is >> basically just the argument (ID) I passed to the function and if I press >> the download button it is saved as 323.pdf. I want to edit its name, how >> can I do this? I tried changing tab name with reponse.title, but it didn't >> work. 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.