Re: [web2py] Why am I getting "unable to import requests" in web2py even though requests is accessible directly through python

2023-05-30 Thread Leonel Câmara
I had this same problem recently, in my case I thought the issue was because I had some python modules installed using pip and other modules installed using apt. I started by removing all the modules installed by apt and installing them using pip. The issue persisted, but I solved it by pip

[web2py] Re: Remove an element from SQLFORM.grid

2023-05-18 Thread Leonel Câmara
You can do grid.elements('thead', replace=None) A quarta-feira, 17 de maio de 2023 à(s) 12:30:05 UTC+1, jeff...@gmail.com escreveu: > I use the following code to hide the thead element of a grid, but I > actually want to delete it. Is there a method to delete the target element? > TIA. > >

[web2py] Re: Failing to display details only for member groups

2023-03-29 Thread Leonel Câmara
The easiest way is to put a common filter in client_order table, do something like this in your models db.client_order._common_filter = lambda q:(db.client_order.company.belongs(db(db.business.authority==auth.user_id)._select(db.business.id))) This will AND this query to any other query you

[web2py] Re: Is it possible to change the boolean field widget from checkbox to option with yes and no?

2023-03-29 Thread Leonel Câmara
You could make a custom widget for that field, in your define_table one of the attributes a Field can receive is widget. However for such a simple case it might be worth it so simply use something like: https://github.com/gitbrent/bootstrap4-toggle/ A quarta-feira, 29 de março de 2023 à(s)

[web2py] Re: Unable to calculate values of a selected Index

2023-03-29 Thread Leonel Câmara
subtotalElement.innerHTML = subtotal.toFixed(2); > > } else { > var notAvailableSpan = > input.parentNode.previousElementSibling.querySelector("span.hidden"); > notAvailableSpan.style.display = "none"; > subtotalElement.innerHTML

[web2py] Re: Unable to calculate values of a selected Index

2023-03-28 Thread Leonel Câmara
Looks like you're trying to mix javascript and python code in a quite impossible way. Just pass qty instead of index to the function and use that as the quantity. A domingo, 26 de março de 2023 à(s) 15:04:29 UTC+1, mostwanted escreveu: > I want to be able to calculate subtotal by

[web2py] Re: MULTI_USER_MODE setup error

2023-03-28 Thread Leonel Câmara
Can't really help you without looking at some application code as I have no idea what techer/MULTI_USER_MODE is, but you can create a user directly in the database using appadmin and inserting a row in the auth_user table if needed. A terça-feira, 28 de março de 2023 à(s) 17:30:40 UTC+1, Geo

[web2py] Re: after Lost Password onaccept

2023-03-23 Thread Leonel Câmara
It's auth.settings.reset_password_onaccept However you can also simply use auth.settings.login_after_password_change = False to force the user to login again. A quinta-feira, 23 de março de 2023 à(s) 00:18:28 UTC, lucas escreveu: > hello one and all, > > ok, you know when you assign a function

[web2py] Re: json Data from the server not displaying!

2023-03-20 Thread Leonel Câmara
The problem is that you are creating the string you want to return and then putting it in a dictionary. You could just have returned the string. That said it's better to use response.json which does a few other things for you. Try this def dashboard(): call_clicks =

[web2py] Re: Validator not saving images

2023-03-20 Thread Leonel Câmara
sage = error_message self.check_tokens = ("receipt", "invoice") A sábado, 18 de março de 2023 à(s) 07:20:04 UTC, mostwanted escreveu: > Hey Leonel, thanks for your reply but the above code is still saving > empty (0byte) images > > On Friday, March 17, 2023

[web2py] Re: Validator not saving images

2023-03-17 Thread Leonel Câmara
What's happening here is that your validator is reading the file and it's not "rewinding" it afterwards so when the next step gets it the file descriptor is at the end of the file hence the ' bytes size. I would recommend rewriting it to something like this (the important part being the

Re: [web2py] Forbid uploaded image file names that have spaces in them

2023-02-28 Thread Leonel Câmara
Slugs are indeed a good idea, but if you really want to force no spaces you can use a regex with IS_FILE. Something like requires=IS_FILE(filename=re.compile('^[^\s]+$')) Note that you probably still want to use IS_SLUG because this will not prevent people from using \, /, ?, .. and other

[web2py] Re: Model function raises error when called from scheduler and not from controller

2022-12-28 Thread Leonel Câmara
There should not be any differences, are you using web2py to run the scheduler or are you running it directly? A quarta-feira, 30 de novembro de 2022 à(s) 16:50:06 UTC, Ramos escreveu: > Hello > i have tested a model function script and it works when i call it from a > controller. > Then i

[web2py] Re: Latest version of web2py and python versions

2022-12-28 Thread Leonel Câmara
You can use a higher python version it's fine. A quarta-feira, 21 de dezembro de 2022 à(s) 06:19:40 UTC, david@gmail.com escreveu: > Good morning, > > Can anyone tell me if the latest version of web2py was specifically > developed for any specific python version or range of python

[web2py] Re: wev2py 2.22.1 is out

2022-02-16 Thread Leonel Câmara
Link for the potential fix https://github.com/web2py/web2py/pull/2430 A quarta-feira, 16 de fevereiro de 2022 à(s) 21:18:48 UTC, Leonel Câmara escreveu: > @cdbaron this was a sneaky one, but I've found it. I actually think this > one is a very old bug from 2016 and I think it

[web2py] Re: wev2py 2.22.1 is out

2022-02-16 Thread Leonel Câmara
@cdbaron this was a sneaky one, but I've found it. I actually think this one is a very old bug from 2016 and I think it might be affecting my applications as well. A segunda-feira, 14 de fevereiro de 2022 à(s) 17:39:21 UTC, cdbaron escreveu: > Hi Massimo, > > Thanks for replying, this issue

[web2py] web2py 2.22.3 is out.

2022-02-15 Thread Leonel Câmara
Hey, web2py 2.22.3 is out. This is a bugfix release that includes: - Using cache disk as the cache for a select fixed (was returning empty rows due to dal changes) - mail.sent(reply_to=...) the new feature had a bug when you only gave it a string instead of a list - updated dal including

[web2py] Re: just python (no web2py) existing tables drop after define_table

2021-04-16 Thread Leonel Câmara
You need to always define the table so pydal knows it is there. That's just how pydal works. define_table only creates the table if it hasn't yet and migration is enabled. A terça-feira, 6 de abril de 2021 à(s) 00:27:41 UTC+1, james c. escreveu: > I am trying to access persistent data saved in

[web2py] Re: Conditional Fields & Validators

2020-12-04 Thread Leonel Câmara
You can change the field requires in the controller depending on whether the field should be shown doing something like this def index(): db.purchase.coupon_code.show_if = (db.purchase.have_coupon==True) if request.vars.have_coupon: db.purchase.coupon_code.requires =

[web2py] Re: warning: new pydal

2020-01-07 Thread Leonel Câmara
Found it, the adapter was only setting the parser after the first connection. For some reason the parser was being changed back to the one registered in parsers at a later moment. I've fixed all my json issues here: https://github.com/web2py/pydal/pull/606 -- Resources: - http://web2py.com -

[web2py] Re: warning: new pydal

2020-01-07 Thread Leonel Câmara
I'm still investigating but in the middle of the request the parser in the postgres adapter seems to be changing: This is the cause. Now I need to investigate why it happens. Because this doesn't happen if I'm using the shell in my app and everything seems to be fine in the shell. --

[web2py] Re: warning: new pydal

2020-01-07 Thread Leonel Câmara
Kevin, you need to be using jsonb fields, so yes in postgres. First I needed to fix the jsonb parser: https://github.com/web2py/pydal/pull/606/files Buf after I did that I'm getting a lot of errors like this: File "C:\Users\Leonel\Desktop\web2py\gluon\packages\dal\pydal\parsers\__init__.py",

[web2py] Re: warning: new pydal

2020-01-06 Thread Leonel Câmara
I seem to be having quite a few issues with json and jsonb fields. -- 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

Re: [web2py] warning: new pydal

2020-01-03 Thread Leonel Câmara
Actually the problem kind of is mine (oopsies) because I updated my app validators to the new style using the validate method instead of __call__, so it's not a web2py backwards compatibility problem I think, since the old way to do validators should work fine. -- Resources: -

[web2py] Re: warning: new pydal

2020-01-02 Thread Leonel Câmara
It seems good, the only problem I've had until now was that I had to update my Validators to have a record_id argument in their validate method. Make sure that you warn people about that in the release notes. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Illegal instruction 4

2019-12-06 Thread Leonel Câmara
You can probably solve this by simply using the source version of web2py. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message

[web2py] Re: Extraction of web2py configuration support

2019-12-03 Thread Leonel Câmara
Config support for your apps comes included with any relatively recent web2py version, you just need to look into a modern welcome app models to see how to use it in your old apps. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py

[web2py] Re: Redis session error - latest web2py master

2019-12-03 Thread Leonel Câmara
> > py4web does sessions in redis by default (if you have redis). Just saying. > Massimo, this really doesn't help. Web2py had working redis sessions and right now, in master, it doesn't. Web2py should not break existing apps just because there's py4web, there's no way people can all migrate

[web2py] Re: Redis session error - latest web2py master

2019-11-15 Thread Leonel Câmara
I haven tried it, but I think the best fix is not to make the decode work by putting the obviously missing parenthesis. The fix is simply to remove the .decode, because to_native should take care of it, so this: rtn = {to_native(k.decode): v for k, v in self.db.r_server.hgetall(key). items()}

[web2py] Re: Redis session error - latest web2py master

2019-11-06 Thread Leonel Câmara
We also got this bug when we tried to upgrade to the latest web2py and had to rollback. We were using the old 2.X pyredis and then tried with 3.X you get the same problem with both. Please report this issue in github, if no one fixes it we will probably end up fixing it as we also need this

[web2py] Re: What happened to DAL(None)?

2019-08-12 Thread Leonel Câmara
DAL(None) still works, you do need to do a bit of setting up if you want to use it for forms, namely set the DAL default validators. See how SQLFORM.factory does it: https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L2053 -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Re: Anthony was right... web3py has a big naming conflict

2019-07-22 Thread Leonel Câmara
I would call it pywebal "python web abstraction layer" -- 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

[web2py] Re: Linking multiple many to many relationships

2019-07-19 Thread Leonel Câmara
You need another table which is an answer table, the answers will have a reference to the question and the team that answered. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: my grating help

2019-07-19 Thread Leonel Câmara
I would check manually in the database if the table is there with the structure defined in the model. If it is then do a fake migrate. If it's not then delete the table file (you already did) and do a regular migrate. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: web2py scripts (homemade task queues) and python2 compatibility

2019-07-16 Thread Leonel Câmara
You're right, you must use the print function because web2py now has a "from __future__ import print_function" which forces you to use the print function even in python2 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: Running web2py in a container / Kubernetes

2019-07-11 Thread Leonel Câmara
I would probably just use InDBMigrator and ditch the databases directory. -- 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

[web2py] Re: Many apps in a single app.

2019-07-09 Thread Leonel Câmara
This looks good, if you want to take it a step further and have something like sub-controller-functions in your apps that will have their own views folder inside the app views folder you can use this decorator I made: def parent_controller(views_folder=None, pop_args_zero=True): """

[web2py] Re: Tip to remove L from interger 750L when exporting json to view?

2019-06-25 Thread Leonel Câmara
Just return the dict as is on the controller and then in the view you can do something like: {{from gluon import serializers}} {{=XML(serializers.json(spendData ), sanitize=False)}} Another alternative is to use the ASSIGNJS helper if you want this in a javascript variable:

[web2py] Re: Tip to remove L from interger 750L when exporting json to view?

2019-06-25 Thread Leonel Câmara
That just means it's a long (python 2 has integers and longs). How are you putting that dict in the view? I would just serialize it using json. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: Datatables serverside JSON/Ajax

2019-06-11 Thread Leonel Câmara
It's because you're not using the generic.json view and you're also not setting the response.headers content-type to json. I would simply change your function to this which will do everything for you: def manageCareer(): rows = db((db.Career.faculty == db.Faculty.id)&(db.Career.degree ==

[web2py] Re: new free toys

2019-06-04 Thread Leonel Câmara
I also made something not long ago, it's an excel formula parser you can use in python to process excel formulas https://github.com/aidhound/hotxlfp -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: pyDAL "adapter" for Pandas syntax (phylosophical)

2019-06-03 Thread Leonel Câmara
Sorry to dig this thread up, but I had to take a look at this recently. I think the most efficient way is to use pydal to make the sql query and then have pandas do it. As an example say you want a dataframe which has the user's id and their first_name import pandas as pd conn =

[web2py] Re: Could this problem in production be related to web2py?

2019-05-24 Thread Leonel Câmara
Thanks a lot for explaining what was happening. -- 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

[web2py] Re: Using a recursive select but encountered a broken reference

2019-05-23 Thread Leonel Câmara
So you're indeed using common filters because that's how record versioning is implemented. In this case you can solve it by removing the reference before deleting, however if you still want to be able to see the deleted record on the one referencing it you can set the versioned table

[web2py] Re: Can I use my function like decorator?

2019-05-23 Thread Leonel Câmara
You should decorate like this @emailConfirmed not like this @emailConfirmed() fun is the function it is decorating, so yes it's your swed and docs functions -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: SQL ALL & ANY operators - ?

2019-05-22 Thread Leonel Câmara
No. But you can use belongs to do the same thing. -- 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

[web2py] Re: Using a recursive select but encountered a broken reference

2019-05-22 Thread Leonel Câmara
Are you using common filters? -- 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] Re: Redirect to new page from ajax request

2019-05-22 Thread Leonel Câmara
you can use redirect(URL(..), client_side=True) -- 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

[web2py] Re: Can I use my function like decorator?

2019-05-22 Thread Leonel Câmara
Note that decorators need a function as an argument and should return another function, given that knowledge you just need to change your function a bit def emailConfirmed(fun): def decorated(): if session.abit_email is None: redirect(URL('default','index'))

[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
It basically has to do with python namespaces. You did not import Rows into your current namespace. The definition is there in the context where the select rows were created but in your namespace you could have another Rows definition that is quite different or none at all. Web2py imports a lot

[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
If you have a module called peartree.py which has only this class Pear: pass def shake(): return Pear() If in another module you do: import peartree mypear = peartree.shake() mypear will be an instance of Pear, however Pear is not defined in this context and you cannot use the

[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
You need to import Rows from pydal.objects -- 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

[web2py] Re: Web3py Auth

2019-05-21 Thread Leonel Câmara
I use the groups and permissions mechanics extensively in my applications. They're useful for lots of stuff. Sharing can be as simple as giving permission for a record. I also use tags for the same purpose but they're better for stuff which will be changing based on properties of an entity

[web2py] Re: Custom validator that avoids saving duplicate / similar values on a database with custom forms

2019-05-20 Thread Leonel Câmara
Valitadors have an error_message __init__ argument. So you can just do IS_IN_DB(..., error_message=T('*that name is already used, please choose a different name for your items*')) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py

[web2py] Re: I can not import module in app

2019-05-17 Thread Leonel Câmara
Inside the application which has the module in its modules folder all you need is "import mytest" -- 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

[web2py] Re: How to do I stop auth.requires_login() from redirecting to the default/user controller?

2019-05-10 Thread Leonel Câmara
Also you probably want to change these as well auth.settings.verify_email_next auth.settings.request_reset_password_next -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list

[web2py] Re: How to do I stop auth.requires_login() from redirecting to the default/user controller?

2019-05-10 Thread Leonel Câmara
You need to set login_url auth.settings.login_url = URL(YOUR_NEW_CONTROLLER, YOUR_NEW_FUNCTION) -- 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

[web2py] Re: Could this problem in production be related to web2py?

2019-05-09 Thread Leonel Câmara
Yes I meant stuff exactly like that. -- 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

[web2py] Re: Could this problem in production be related to web2py?

2019-05-09 Thread Leonel Câmara
Seems like a locking problem due to threads. Do you create any thread in your application? If so you need to remove master=true from your uwsgi .ini config. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: gmail unable to send email

2019-05-06 Thread Leonel Câmara
If you don't send too many emails I recommend using sparkpost as they have a free tier and I made a plugin that makes it really easy to use with web2py https://github.com/leonelcamara/web2py_sparkpost -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Converting large app from Python2 to Python3 - how do you handle code in views ?

2019-04-17 Thread Leonel Câmara
You can look at yatl code. https://github.com/web2py/yatl To see how web2py does it. But frankly I doubt you have much python 3 incompatible code in your views, I would just test them as they are, they're probably fine. -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Re: How can I return a report to the user in the view?

2019-04-17 Thread Leonel Câmara
You have to either convert those '\n' into or paragraph tags by doing something like this in the view {{=DIV(*[P(line) for line in report.split('\n')])}} or put the report inside a PRE tag to tell the browser the text comes preformatted {{=form}} {{=report}} -- Resources: -

[web2py] Re: howto prevent XSS in json data

2019-04-17 Thread Leonel Câmara
Please open an issue, you're right, this is a bug and a security problem, it's also very easy to fix by simply copy pasting escapejs from django. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: howto prevent XSS in json data

2019-04-16 Thread Leonel Câmara
Another thing you can do is simply quote the name import urllib filter_settings = dict(name=urllib.quote(request.vars.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

[web2py] Re: howto prevent XSS in json data

2019-04-15 Thread Leonel Câmara
Change it to: var filterSettings = {{=XML(filter_settings, sanitize=True)}}; -- 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

[web2py] Re: auth_user automatically lowercase all email fields

2019-04-08 Thread Leonel Câmara
> > because students are inconsistent > Ahahaha if it was only students our lives would be much easier. On a more serious note, although most email systems are case insensitive nowadays it is allowed by the RFC to be case sensitive so it can be a different email. In the real world, I had

[web2py] Re: Disabling Migration In Production

2019-04-08 Thread Leonel Câmara
migrate_enabled=False will disable migrations even if a table has migrate=True, migrate=False works like the default migrate for tables. If you don't have migrate defined at the table level they are basically the same thing. -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Recursive table relation

2019-04-06 Thread Leonel Câmara
Possibly because you have require instead of requires? -- 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

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-06 Thread Leonel Câmara
Did you import ValidationError as well? -- 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

[web2py] Re: Custom validator broken in 2.18.4, working in 2.17.2

2019-04-05 Thread Leonel Câmara
The way validators are in 2.18.4 you need to do it like this: class IS_MEMBERSHIP_YEAR_END(Validator) : def __init__(self, error_message='Not a membership year end'): self.error_message = error_message def validate(self, value): yearend = datetime.date(2018,9,30)

[web2py] Re: compile_application() not including symlinked views (while it includes symlinked controllers)

2019-04-04 Thread Leonel Câmara
Could it be a permissions problem? -- 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

[web2py] Re: How can I disable auto-login after registration?

2019-04-03 Thread Leonel Câmara
If you don't have auth.settings.registration_requires_verification = True then web2py will login the user anyway, which kind of makes sense, because why wouldn't it? The login_after_registration setting is really just a way to bypass those requirements if you want to let the user get logged in

[web2py] Re: how to add users to existing programmatically using an if statement

2019-03-31 Thread Leonel Câmara
register_bare returns the user record, so you can get user_id in user.id You can get the group id by doing # Assuming you create a group with role = 'Manager' and another with role = 'Assistante' group_id_manager = auth.id_group('Manager') group_id_assistant = auth.id_group('Assistant')

[web2py] Re: Using the results of a variable returned by one function in another function

2019-03-28 Thread Leonel Câmara
Just send the services id in the URL either as an arg or a var and then do something like this: rslts=db((db.business.place==results.id) & (db.business.services==request.vars.services_id)).select() Notice that I also removed a query you had in the select call, which was wrong. -- Resources:

[web2py] Re: Compartilhar aplicações feita em Web2py em Rede Local.

2019-03-28 Thread Leonel Câmara
Hey Alessandro, this is an international group so please use English instead of Portuguese. Basically you just need to be sure your computer has a static local network ip which you can probably configure in your wireless router if he's the one running DHCP. Then run web2py on that ip instead

[web2py] Re: web3py again....

2019-03-28 Thread Leonel Câmara
I haven't tried it, but looking at the code... Can you explain a little bit more what you're trying to achieve here? This seems like it's bottle with pydal and yatl. Why not just use bottle then? It will force me to learn bottle anyway. -- Resources: - http://web2py.com -

[web2py] Re: Redis and Python3?

2019-03-27 Thread Leonel Câmara
It's not your values Joe, pickle serializes them as a string so they would be fine. It's web2py session locked field which is True or False. It's probably easy to fix this in redis_session.py -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Inconsistent file upload behaviour

2019-03-27 Thread Leonel Câmara
You probably just need to rewind the file because request.vars already loaded it. request.vars.csvfile.file.seek(0) candidate_file = request.vars.csvfile.file.read() Instead you can just do: candidate_file = request.vars.csvfile.value Which uses the value of the file already got by request

[web2py] Re: python web2py.py -L options.py doesn't seem to comply with errors_to_console = True

2019-03-22 Thread Leonel Câmara
I think it's print_errors and not errors_to_console if you're using an options.py -- 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

[web2py] Re: Information about db._adapter.dialect.quote in the book

2019-03-22 Thread Leonel Câmara
It's not in the book because ideally you should never use it unless you're executing sql directly which is discouraged, and if you're doing that you should know what you're doing. You don't need to quote manually, like you're doing, in your example because you're not executing sql directly. So

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
That's weird. It seems looking at the adapter in pydal, sqlite does not start a transaction after connection like most adapters. Reading the sqlite documentation, that's probably because sqlite starts a transaction automatically as soon as anything writes to the database. So, basically,

[web2py] Re: Is it possible to run a Python script when starting web2py, without the shell option?

2019-03-21 Thread Leonel Câmara
It's possible to use an options.py file to setup the parameters of the windows service. See http://www.web2py.com/AlterEgo/default/show/77 Since it's just python you can use options.py to run your script -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Is it possible to run a Python script when starting web2py, without the shell option?

2019-03-21 Thread Leonel Câmara
What does it even mean run only once when web2py starts? Web2py can be running in multiple processes and in multiple threads. The answer totally depends on what you're trying to do and how you run web2py. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: How to create a nested json dictionary by loading data from a flat, parent-referencing list?

2019-03-21 Thread Leonel Câmara
The brackets are there because it's a list of roots in your tree, if you know for sure that you will have always one and only one root, you can do: {{response.write(json(your_tree[0]), escape=False)}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
The transaction is atomic, that means there's nothing happening in the middle. Your use case is fine. Of course, that if you give the user a form, while he's editing it, the form can be changed by others as well, in that case you need to add your own locking or check the record for

[web2py] Re: How to create a nested json dictionary by loading data from a flat, parent-referencing list?

2019-03-21 Thread Leonel Câmara
You can simply do in a view: {{from gluon.serializers import json}} Then where you want it in the view: {{response.write(json(your_tree), escape=False)}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: IS_IN_SET instead of IS_IN_DB

2019-03-21 Thread Leonel Câmara
IS_IN_DB has a label keyword argument, the label can be a string template or a function. You can make a function that given a value gives you the label (getting it from the other table) and use it in IS_IN_DB. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
It does. A transaction is an atomic operation. https://www.geeksforgeeks.org/acid-properties-in-dbms/ -- 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) ---

[web2py] Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread Leonel Câmara
Web2py always "wraps" your controller functions in a db transaction, so yes, you can do that with any database which has transactions correctly implemented. You don't need to worry about doing it manually. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] Re: When using SQLite does web2py use the older rollback-mode transaction mechanism or the newer WAL?

2019-03-20 Thread Leonel Câmara
Looking at: https://github.com/web2py/pydal/blob/master/pydal/adapters/sqlite.py#L73 I don't see any self.execute('pragma journal_mode=wal;') So I'm guessing the older. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code)

[web2py] Re: How to catch index error

2019-03-19 Thread Leonel Câmara
Notice that, it seems you are using [-1] because want to get the last record where the user was awake/light sleep/sleep, however you don't use an order by, so depending on the strategy the database decides to use, there's no guarantee that it will be the last. This is also inefficient because

[web2py] Re: How can I add entries to languages\pt.py file when a user adds a record?

2019-03-19 Thread Leonel Câmara
Something like this: from gluon.languages import write_dict def make_portuguese_entry(fields, recordid): T.force('pt') T.t[fields[name_of_the_field]] = fields[name_of_the_field_pt] if T.is_writable: write_dict(T.language_file, T.t)

[web2py] Re: ST_Transform in GIS support

2019-03-19 Thread Leonel Câmara
That looks great to me! -- 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] Re: How can I add entries to languages\pt.py file when a user adds a record?

2019-03-19 Thread Leonel Câmara
How would web2py know how to translate it when the record is inserted to fill that part? Is it one of the fields? -- 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

[web2py] Re: How can I add entries to languages\pt.py file when a user adds a record?

2019-03-19 Thread Leonel Câmara
Ideally you don't. Frankly web2py's translation system is not ideal for dynamic content. That said, you can simply put a function in the record's table _after_insert that is something like this: def make_portuguese_entry(fields, recordid): T.force('pt') T(fields[name_of_the_field],

[web2py] Re: Error accessing app edit

2019-03-18 Thread Leonel Câmara
This was due to changes I made to the way web2py discovers exposed functions in a controller file. It uses the python parser so it has a problem with syntax errors. I made a pull request that teaches the admin to deal with them: https://github.com/web2py/web2py/pull/2151 -- Resources: -

[web2py] Re: Geometry fields and validators

2019-03-15 Thread Leonel Câmara
I think that's perfectly fine, I would just make a validator to wrap it so you can use it more easily. -- 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) ---

[web2py] Re: Geometry fields and validators

2019-03-15 Thread Leonel Câmara
This is the validator I use for my geometry fields import re from pydal.validators import Validator, ValidationError class IS_GEOLOCATION(Validator): """ Validate that the input is a location within latitude and longitude constraints. """ regex_geopoint =

[web2py] Re: I would like to allow the user to change the language, but I can't find why it isn't complying

2019-03-15 Thread Leonel Câmara
This is how I do it in one of my websites in model: SUPPORTED_LANGUAGES = ('en', 'pt') # or just load this from config def pick_lang(): twoletter = session.lang or T.accepted_language[:2] if twoletter in SUPPORTED_LANGUAGES: T.force(twoletter) return twoletter else:

[web2py] Re: Is it possible to make a form field depend on another form field without submiting the form?

2019-03-15 Thread Leonel Câmara
Here's an example I made long ago, I would do things differently nowadays but it shows how it can be done. https://groups.google.com/forum/#!topic/web2py/z_lGYsO6LKE -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

  1   2   3   4   5   6   7   8   9   10   >