[web2py] appconfig local vs api provide by another web2py app

2018-04-17 Thread 黄祥
just curious, is there any performance difference while storing appconfig 
in local (private/appconfig.ini) or by using json api that provide by 
another web2py app?
*objective*
to create central configuration webapp between web2py app

*e.g. for json api that provide by another web2py app*
applications/appconfig
applications/a0
applications/b0

so models/db.py in applications a0 and b0 must have something like
*models/db.py*
app_id = 1 #different between app a0 and b0
import requests
from requests.auth import HTTPBasicAuth 
auth = HTTPBasicAuth('admin', 'password')
r = requests.get("http://127.0.0.1:8000/appconfig/api/args_rows_as_json/%s; 
% (app_id), auth = auth).json()
db = DAL(r[0]['db_uri'], pool_size = r[0]['pool_size'], migrate = 
r[0]['migrate'] )

any idea, or comments ?

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] Buttons labels change to "Working..." when pressed

2018-04-17 Thread Junior Phanter
check your we2py_ajax.html in your view folder, try change the line "var
w2p_ajax_disable_with_message = "{{=T('Working...')}}";"

2018-04-17 23:12 GMT-03:00 Michael Cowen :

>
> I am not sure if this is related to web2py or something else so I thought
> I would ask ...
>
> I have three buttons that I make a toggle switch through Java script.  The
> Java script changes their class name which then lets different CSS style
> them.  I have noticed that when I click a button, EVERY single button on
> the page flashes with the word "Working ...".  My class name changes are
> applied to this intermediate state that I cannot figure out where it is
> coming from.  So the toggling happens to the buttons like I want, but the
> labels change and I did not do this in code.  Then when the labels change
> back, my class name changes are gone.  It is as if something remembers the
> page, executes the Java script against an automatic modified version of the
> page, then when complete restores the page.  Is this something the web2py
> framework does ?   I cannot find any JavaScript running that would explain
> this.
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Buttons labels change to "Working..." when pressed

2018-04-17 Thread Michael Cowen

I am not sure if this is related to web2py or something else so I thought I 
would ask ...

I have three buttons that I make a toggle switch through Java script.  The 
Java script changes their class name which then lets different CSS style 
them.  I have noticed that when I click a button, EVERY single button on 
the page flashes with the word "Working ...".  My class name changes are 
applied to this intermediate state that I cannot figure out where it is 
coming from.  So the toggling happens to the buttons like I want, but the 
labels change and I did not do this in code.  Then when the labels change 
back, my class name changes are gone.  It is as if something remembers the 
page, executes the Java script against an automatic modified version of the 
page, then when complete restores the page.  Is this something the web2py 
framework does ?   I cannot find any JavaScript running that would explain 
this.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] AppConfig in JSON returns unicode

2018-04-17 Thread Joe Barnhart
This is sort of a bug, sort of a feature.  I just converted to the JSON 
version of AppConfig (in the gluon/contrib) and discovered the strings it 
produces are all unicode -- even in Python 2.x environments.

I'm not sure of ALL of the ramifications, but I discovered it causes crypt 
fields to fail when a key is provided.  I'm using a known key because I 
need to keep compatibility with past users who have accounts, but as soon 
as I tried to use the crypt field to enter the first logon when 
initializing the new website, it failed. It tested the "digest_alg" to see 
if it was a "str" and failed because it was "unicode".

Anyway, the workaround is to use "str()" on any fields that are critical. 
 Longer term, it may be useful for the maintainer of AppConfig to return 
strings instead of unicode from JSON format files.

-- Joe

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] web2py, nginx and big files

2018-04-17 Thread Richard Vézina
How big?

https://www.bookstackapp.com/docs/admin/upload-limits/

https://www.nginx.com/resources/wiki/modules/upload/#upload-max-file-size

Quote from the above link:
For “hard” limit client_max_body_size directive must be used. The value of
zero for this directive specifies that no restrictions on file size should
be applied.


Have a look at your nginx config upload_max_file_size and
client_max_body_size

I can't find the default nginx limit, but I think upload are around 5 mg, I
recall having issue long time ago about upload limit and the attachement
was a little over 5 meg, so...

In the link you provide there not seems to have limit overriding default,
so my guess is that your file is bigger than the client_max_body_size

Good luck

Richard

On Tue, Apr 17, 2018 at 12:10 PM, Carlos Cesar Caballero Díaz <
carlos.caball...@cfg.jovenclub.cu> wrote:

> Hi, I have a web2py + nginx setup (https://github.com/arisobel/w
> eb2py_scripts/blob/master/setup-web2py-nginx-p3-uwsgi-ubuntu.sh) and I
> need to upload big files to my application, the app is working ok with the
> built in server, but with nginx the form submission fails with no response
> when there are big files.
>
> Any tip for solving this?
>
>
> Greetings.
>
> --
> 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] web2py, nginx and big files

2018-04-17 Thread Carlos Cesar Caballero Díaz
Hi, I have a web2py + nginx setup 
(https://github.com/arisobel/web2py_scripts/blob/master/setup-web2py-nginx-p3-uwsgi-ubuntu.sh) 
and I need to upload big files to my application, the app is working ok 
with the built in server, but with nginx the form submission fails with 
no response when there are big files.


Any tip for solving this?


Greetings.

--
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: I cant access db data

2018-04-17 Thread Maurice Waka
Thanks. It worked.

On Tue, 17 Apr 2018, 15:37 Anthony  wrote:

> On Tuesday, April 17, 2018 at 1:33:29 AM UTC-4, Maurice Waka wrote:
>>
>> Sorry, am still experiencing the same issue.
>> This module is one of the many that I import to the controller .
>> i.e.
>>
>> controller:
>> from gluon import current
>> db = current.db
>>
>
> There is nothing in web2py that automatically adds the db object (or any
> object created by your own code) to the current object, so you must do
> this yourself. The above line should instead be the opposite assignment:
>
> current.db = db
>
> In other words, in a model file or controller, you can add objects to
> current, and then in a module, you can import current and access those
> objects.
>
> Alternatively, any object in the web2py global environment (including any
> created in the model files) can also be accessed via the current.globalenv
> dictionary. For example:
>
> current.globalenv['db']
>
> 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/wBVbeSdbc9o/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: I cant access db data

2018-04-17 Thread Anthony
On Tuesday, April 17, 2018 at 1:33:29 AM UTC-4, Maurice Waka wrote:
>
> Sorry, am still experiencing the same issue.
> This module is one of the many that I import to the controller .
> i.e.
>
> controller:
> from gluon import current
> db = current.db
>

There is nothing in web2py that automatically adds the db object (or any 
object created by your own code) to the current object, so you must do this 
yourself. The above line should instead be the opposite assignment:

current.db = db

In other words, in a model file or controller, you can add objects to 
current, and then in a module, you can import current and access those 
objects.

Alternatively, any object in the web2py global environment (including any 
created in the model files) can also be accessed via the current.globalenv 
dictionary. For example:

current.globalenv['db']

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to redirect http to https?

2018-04-17 Thread Dave S


On Monday, April 16, 2018 at 7:51:21 AM UTC-7, Anthony wrote:
>
> Another option is to configure your web server to do the redirect.
>
>
And that's easy enough in NGINX that even I have been able to set it up.  I 
did use the request.requires_https() method when I was still using Rocket, 
but that ended when I got into certificate update issues.

/dps
 

> On Monday, April 16, 2018 at 9:32:36 AM UTC-4, Leonel Câmara wrote:
>>
>> You can just put this in your model:
>>
>> request.requires_https()
>>
>

-- 
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: Datetime onSelect event

2018-04-17 Thread Dave S


On Monday, April 16, 2018 at 1:52:54 AM UTC-7, tomasz bandura wrote:
>
> Hello,
>
> I need to do some action after selecting value in datetime field.
> After my investigation it looks the one way is to create  my own datetime 
> component with implemented 'onSelect' event.
>
> Another option  is to use another datetime (jquery) control.
>
> I'd like to avoid it but i have no an idea how to add an event listener to 
> datetime control on a page.
>
> Has anyone already met such an issue?
>
> Tomasz 
>

Not a direct answer, because this doesn't use a datetime widget (IssueYr is 
an integer for this usage), but I have lines like the following in my view 
file:

   jQuery('#QM_IssueYr').blur(function(){
   if (jQuery('#QM_IssueYr').val() < 1999) {
   /* alert("trying to go to Mint"); */
   jQuery('#QM_Mint').focus();

where the references are to form fields. I used blur()  because that seemed 
to do the best job of capturing "leaving the field", but you may want to 
handle a different event.  The element reference was obtained by doing an 
"inspect element" on a "dumb" view, but there is a anming convention in 
use, and I expect FORM follows it even as SQLFORM does.

/dps


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Dealing with db objects on duplicated app

2018-04-17 Thread Sergio Romero



I don't know why, but I delete the sqli databases of each applications and 
instantiate the DAL with migrate=false. It shows an error on db.auth_users 
because it doesn't exist. Then I change each dal instantiation to migrate= 
true and none errors wasn't took place and users are not shared anymore.

Any ideas of this behavior?

Thanks


El martes, 17 de abril de 2018, 9:14:38 (UTC+2), Dave S escribió:
>
>
>
> On Monday, April 16, 2018 at 10:48:34 PM UTC-7, Sergio Romero wrote:
>>
>> I used the starter app example of mjbeller
>>
>> I have the same app code on each app to instantiate the DAL but with 
>> different appconfig.ini
>>
>> appconfig.ini of app1
>>
>> uri= sqlite://storage.sqlite
>> migrate= true
>> pool_size  = 10 ; ignored for sqlite
>>
>>
>> appconfig.ini of app2
>>
>> uri= sqlite://storage2.sqlite
>> migrate= false
>> pool_size  = 10 ; ignored for sqlite
>>
>>
>> I used the same code to instantiate the DAL object on each app
>>
>> ## app configuration made easy. Look inside private/appconfig.ini
>> from gluon.contrib.appconfig import AppConfig
>> ## once in production, remove reload=True to gain full speed
>> myconf = AppConfig(reload=True)
>> myconf_env = myconf.get('environment.type')
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL(myconf.get(myconf_env + 'db.uri'),
>>  pool_size = myconf.get(myconf_env + 'db.pool_size'),
>>  migrate_enabled = myconf.get(myconf_env + 'db.migrate'),
>>  check_reserved = ['mysql', 'postgres'])  # ['all'])
>> else:
>> ## connect to Google BigTable (optional 'google:datastore://namespace')
>> db = DAL('google:datastore+ndb')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>>
>>
>> Thanks
>>
>>
> Normally, when you copy app1 to app2, they will each have separate 
> database directories (.../applications/app1/database/ and 
> .../applications/app2/database/), and the table files of each app will 
> live in the appropriate directory, and the storage.sqlite files will also 
> be be in the appropriate directory.  Can you confirm that this is what you 
> have?
>
> And please show us the model files that you experience difficulty with.
>
> Dave S
> /dps
>
>
>
>  
>
>> El martes, 17 de abril de 2018, 2:03:20 (UTC+2), Anthony escribió:
>>>
>>> They are not sharing the same db object just by virtue of it having the 
>>> same name in the code. The code of each app is executed independently 
>>> within requests for each app. Please show the code you are using to 
>>> instantiate the DAL object in each app.
>>>
>>> Anthony
>>>
>>> On Monday, April 16, 2018 at 7:58:03 PM UTC-4, Sergio Romero wrote:

 Hi there. 

 I have to deal with a duplicate example app on the same rocket server 
 instance. I have modified the sqlite file with each application interact 
 but both of the applicattions has the same db dal object name. 

 When I start the server each applications shares the users and have 
 some problems with the foreign keys when I try to insert a row on a table 
 of app1 if the same table exists on app2 

 How can I deal with this situation without refactor the db object name 
 of one of the application to isolate both applications and don't share the 
 instantiate db object between them. 

 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: uploading a file with a form ( without SQLFORM)

2018-04-17 Thread Dave S


On Friday, April 13, 2018 at 1:15:36 PM UTC-7, Multiplery wrote:
>
> Hey folks,
>
> I'm attempting to upload a file directly without the use of a SQLForm but 
> rather the ordinary FORM.
> From previous threads regarding the topic i figured my controller should 
> look something like this:
>
> [code]
> def index():
> 
> import shutil 
> form = FORM( 
> INPUT( _name="upload", _type="file"),
> INPUT( _type="Submit", _value="Upload" ))
> if form.accepts(request,session):
> if form.vars: 
>  
>filename=request.vars.upload.filename
>file=request.vars.upload.file
>shutil.copyfileobj(file,open('/path'+filename,'wb')) 
> return dict (form = form)
> [/code]
>
> yet no file appears in the folder of my path. I'm not sure if the problem 
> is with my code or maybe elsewhere, for example permission based. I'm using 
> a raspberry with a raspiban os. i Already tried to start python as root 
> user. 
>
> Can someone spot a mistake in the code? has someone tried to run this on a 
> debian based os and knows if its a permission problem? I'm aware of the 
> potential dangers of the shutil.copyfileobj, so no worries about that.
>
> Sincerely,
>
>
Shouldn't you be passing the [relevant] request.post_vars to form.accepts() ?  
See the top-level paragraph for *FORM* in chapter 7, and also


/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Dealing with db objects on duplicated app

2018-04-17 Thread Dave S


On Monday, April 16, 2018 at 10:48:34 PM UTC-7, Sergio Romero wrote:
>
> I used the starter app example of mjbeller
>
> I have the same app code on each app to instantiate the DAL but with 
> different appconfig.ini
>
> appconfig.ini of app1
>
> uri= sqlite://storage.sqlite
> migrate= true
> pool_size  = 10 ; ignored for sqlite
>
>
> appconfig.ini of app2
>
> uri= sqlite://storage2.sqlite
> migrate= false
> pool_size  = 10 ; ignored for sqlite
>
>
> I used the same code to instantiate the DAL object on each app
>
> ## app configuration made easy. Look inside private/appconfig.ini
> from gluon.contrib.appconfig import AppConfig
> ## once in production, remove reload=True to gain full speed
> myconf = AppConfig(reload=True)
> myconf_env = myconf.get('environment.type')
>
> if not request.env.web2py_runtime_gae:
> ## if NOT running on Google App Engine use SQLite or other DB
> db = DAL(myconf.get(myconf_env + 'db.uri'),
>  pool_size = myconf.get(myconf_env + 'db.pool_size'),
>  migrate_enabled = myconf.get(myconf_env + 'db.migrate'),
>  check_reserved = ['mysql', 'postgres'])  # ['all'])
> else:
> ## connect to Google BigTable (optional 'google:datastore://namespace')
> db = DAL('google:datastore+ndb')
> ## store sessions and tickets there
> session.connect(request, response, db=db)
>
>
> Thanks
>
>
Normally, when you copy app1 to app2, they will each have separate database 
directorys (.../applications/app1/database/ and 
.../applications/app2/database/), and the table files of each app will live 
in the appropriate directory, and the storage.sqlite files will also be be 
in the appropriate directory.  Can you confirm that this is what you have?

And please show us the model files that you experience difficulty with.

Dave S
/dps



 

> El martes, 17 de abril de 2018, 2:03:20 (UTC+2), Anthony escribió:
>>
>> They are not sharing the same db object just by virtue of it having the 
>> same name in the code. The code of each app is executed independently 
>> within requests for each app. Please show the code you are using to 
>> instantiate the DAL object in each app.
>>
>> Anthony
>>
>> On Monday, April 16, 2018 at 7:58:03 PM UTC-4, Sergio Romero wrote:
>>>
>>> Hi there. 
>>>
>>> I have to deal with a duplicate example app on the same rocket server 
>>> instance. I have modified the sqlite file with each application interact 
>>> but both of the applicattions has the same db dal object name. 
>>>
>>> When I start the server each applications shares the users and have some 
>>> problems with the foreign keys when I try to insert a row on a table of 
>>> app1 if the same table exists on app2 
>>>
>>> How can I deal with this situation without refactor the db object name 
>>> of one of the application to isolate both applications and don't share the 
>>> instantiate db object between them. 
>>>
>>> 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.