Re: [web2py] web2py 2.16.1 and login menu on mobile systems NOT WORKING

2018-04-22 Thread Carlos Cesar Caballero Díaz
Yes, I usually use a newer bootstrap version, and make some fixes in the 
layout bar.


Testing the trunk I can see that is fixed, but there are some responsive 
issues. Is there some issue open about this? If there is no one working 
I can send some fixes.


Greetings.

El 22/04/18 a las 15:54, Andrea Fae' escribió:
If you try to use welcome application on web2py 2.16.1 login menu 
(hamburger icon) is not working. Clicking on it nothing 
happens...it's a bug.

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

For more options, visit https://groups.google.com/d/optout.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] please help us test trunk web2py

2018-04-22 Thread Carlos Cesar Caballero Díaz
Hi, I was testing and there are some issues with the DAL parse_as_rest 
and Python 3. There are also some style issues with the welcome app navbar.


I can work in the navbar if no one is working.

Greetings.


El 24/02/18 a las 21:44, Massimo Di Pierro escribió:

Please help us test the version of web2py which is posted on github.

I would like to release a new stable version and I would like to know 
if any of the changes has broken backward compatibility.

Also the icons are back in the latest welcome but use font-awesome.

Please check it. Thanks.

Massimo

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

For more options, visit https://groups.google.com/d/optout.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: SyntaxError: table already defined: definition

2018-04-22 Thread Maurice Waka
I solved the thread.local error by declaring the
rows=db(db.health).select() as a global object in my code.
I hope I won't get into trouble.
Thanks @ Anthony.

On Sun, 22 Apr 2018, 22:48 Maurice Waka  wrote:

> I looked at my question, the reference function was actually a typo, my
> apology, it was supposed to be definition().
> I worked it out again as follows:
> *model:*
>
> db = DAL('sqlite://storage.sqlite', migrate=False, fake_migrate=False)
> response.generic_patterns = ['*'] if request.is_local else []
> auth = Auth(db, hmac_key=Auth.get_or_create_key())
> auth.define_tables()
> crud, service, plugins = Crud(db), Service(), PluginManager()
> current.db= db
> db.define_table('definition',
> Field('definition', 'text', length= 100, default="We'll update
> soon.", notnull=True))
>
>
>
> *module:#define code*
>
> from gluon import current
> from pydal import DAL, Field
> db = current.db
>
> def definition():
> rows = db(db.definition).select()
> for row in rows:
> return row.definition
>
> With this , the error disappeared but when running the code in web2py, i
> now have a new headache:
>
>   File 
> "applications/Hestque_Wellness/modules/Hestquewell/abnvalinterpretation/wellabnvalinterpret0.py",
>  line 101, in wellabnvalinterpret
> rows = db(db.health).select()
>   File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 2250, 
> in select
> return adapter.select(self.query, fields, attributes)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/sqlite.py", 
> line 82, in select
> return super(SQLite, self).select(query, fields, attributes)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
> 762, in select
> return self._select_aux(sql, fields, attributes, colnames)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
> 718, in _select_aux
> rows = self._select_aux_execute(sql)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
> 712, in _select_aux_execute
> self.execute(sql)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/__init__.py", 
> line 63, in wrap
> if not args[0].connection:
>   File "/usr/local/lib/python2.7/dist-packages/pydal/connection.py", line 36, 
> in connection
> return getattr(THREAD_LOCAL, self._connection_uname_)
> AttributeError: 'thread._local' object has no attribute 
> '_pydal_connection_140327873342608_17719'
>
>
> The module wellabnvalinterpret0 imports definition()function. It accesses
> the health db.
>
> Kind regards
>
> On Sun, Apr 22, 2018 at 9:00 PM, Maurice Waka 
> wrote:
>
>> Will send it once I get back to the comp
>>
>> On Sun, 22 Apr 2018, 20:55 Anthony  wrote:
>>
>>> Can't help without the code.
>>>
>>> --
>>> 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/7xCGTfc6xAA/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>

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


[web2py] Insert not inserting data

2018-04-22 Thread Kenneth
Hello,

I can't understand this simple problem. 

tracker = db.usage_tracker.insert(client = 6728, product_group = 2, product 
= 15)

nothing appears in the database. ID counter is updated. If I look 
at db._lastsql I get 

INSERT INTO usage_tracker(logged_in,product,client,product_group) VALUES 
('2018-04-23 01:51:34.001992',15,6728,2);

this is in a normal controller. 

If I put the same tracker = db.usage_tracker.insert(client = 6728, 
product_group = 2, product = 15) in an own function in controller it works. 


Kenneth

-- 
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 2.16.1 and login menu on mobile systems NOT WORKING

2018-04-22 Thread Andrea Fae'
If you try to use welcome application on web2py 2.16.1 login menu 
(hamburger icon) is not working. Clicking on it nothing happens...it's 
a bug.
Am I right?

-- 
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: SyntaxError: table already defined: definition

2018-04-22 Thread Maurice Waka
I looked at my question, the reference function was actually a typo, my
apology, it was supposed to be definition().
I worked it out again as follows:
*model:*

db = DAL('sqlite://storage.sqlite', migrate=False, fake_migrate=False)
response.generic_patterns = ['*'] if request.is_local else []
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables()
crud, service, plugins = Crud(db), Service(), PluginManager()
current.db= db
db.define_table('definition',
Field('definition', 'text', length= 100, default="We'll update
soon.", notnull=True))



*module:#define code*

from gluon import current
from pydal import DAL, Field
db = current.db

def definition():
rows = db(db.definition).select()
for row in rows:
return row.definition

With this , the error disappeared but when running the code in web2py, i
now have a new headache:

  File 
"applications/Hestque_Wellness/modules/Hestquewell/abnvalinterpretation/wellabnvalinterpret0.py",
line 101, in wellabnvalinterpret
rows = db(db.health).select()
  File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line
2250, in select
return adapter.select(self.query, fields, attributes)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/sqlite.py",
line 82, in select
return super(SQLite, self).select(query, fields, attributes)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py",
line 762, in select
return self._select_aux(sql, fields, attributes, colnames)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py",
line 718, in _select_aux
rows = self._select_aux_execute(sql)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py",
line 712, in _select_aux_execute
self.execute(sql)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/__init__.py",
line 63, in wrap
if not args[0].connection:
  File "/usr/local/lib/python2.7/dist-packages/pydal/connection.py",
line 36, in connection
return getattr(THREAD_LOCAL, self._connection_uname_)
AttributeError: 'thread._local' object has no attribute
'_pydal_connection_140327873342608_17719'


The module wellabnvalinterpret0 imports definition()function. It accesses
the health db.

Kind regards

On Sun, Apr 22, 2018 at 9:00 PM, Maurice Waka  wrote:

> Will send it once I get back to the comp
>
> On Sun, 22 Apr 2018, 20:55 Anthony  wrote:
>
>> Can't help without the code.
>>
>> --
>> 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/7xCGTfc6xAA/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: SyntaxError: table already defined: definition

2018-04-22 Thread Maurice Waka
Will send it once I get back to the comp

On Sun, 22 Apr 2018, 20:55 Anthony  wrote:

> Can't help without the code.
>
> --
> 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/7xCGTfc6xAA/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: SyntaxError: table already defined: definition

2018-04-22 Thread Anthony
Can't help without the code.

-- 
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 not working on smartphone - no the same menu layout

2018-04-22 Thread Andrea Fae'
I included tether, and with Chrome I don't see this error

Source map error: request failed with status 404
Resource URL: https://
andfae.pythonanywhere.com/tcf/static/css/bootstrap.min.css
Source Map URL: bootstrap.min.css.map[Learn More]

Did you try with Chrome? I don't have any other error in the console.


Il giorno venerdì 20 aprile 2018 21:59:08 UTC+2, Dave S ha scritto:
>
>
>
> On Friday, April 20, 2018 at 11:15:52 AM UTC-7, Andrea Fae' wrote:
>>
>> Please help me...
>>
>>
> I'm not going to be much help, but I can confirm that the "hamburger" 
> doesn't appear to have any life, where as the "<" and ">" buttons in the 
> regular part of the page do change the date displayed.  This is with Chrome 
> on a Samsung G8.
>
> Opening the page in Firefox on my desktop has a conventional menu that 
> drops down the two login options.
>
> I don't know too much about website developer tools on Android itself, but 
> perhaps you can use a simulator environment to watch more closely what the 
> JS is doing.
>
> Some sites have an "m." variant of the address to signal "mobile 
> environment" and you can use that address on a desktop browser to play with 
> the mobile interface, but I don't think web2py has that built-in.  
> PythonAnywhere might have that as a feature, but that wouldn't help because 
> web2py would still see the desktop user agent.
>
> Oooh, I just tried narrowing the desktop window, and the menu bar switched 
> to hamburger, and the hamburger is silent.  Turning on FF inspector, I see 
> two errors on the console:
>
> Error: Bootstrap tooltips require Tether (http://tether.io/)
> bootstrap.min.js:7:3482
>
> Source map error: request failed with status 404
> Resource URL: https://
> andfae.pythonanywhere.com/tcf/static/css/bootstrap.min.css
> Source Map URL: bootstrap.min.css.map[Learn More]
>
>
> The second error may be relevant.
>
> Dave S
> /dps
>
>
>
>
> Il giorno mercoledì 18 aprile 2018 20:31:38 UTC+2, Andrea Fae' ha scritto:
>>>
>>> this is my application
>>>
>>> https://andfae.pythonanywhere.com/tcf/default/index
>>>
>>> I can't login with android. I don't know. I see in the upper right of 
>>> the smartphone 3 lines but when I click nothing happens...How to fix it?
>>> I didn't find anything about this problem it. 
>>> Maybe is it regarding bootstrap 4 in web2py?
>>> 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] bootstrap.min.js:7 Uncaught Error: Bootstrap tooltips require Tether (http://tether.io/)

2018-04-22 Thread Andrea Fae'
what can I do to include tether in web2py project telling me that bootstrap 
4 (worse than bootstrap 3) require tether? Where and what do I have to 
include?
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.


Re: [web2py] Re: Get rows by id list keeping the order

2018-04-22 Thread Carlos Cesar Caballero Díaz
Thanks Anthony, I will go with the first option and guess how to adapt 
it to postgress too.


Greetings.


El 22/04/18 a las 12:12, Anthony escribió:
On Sunday, April 22, 2018 at 11:46:13 AM UTC-4, Carlos Cesar Caballero 
wrote:


Hi guys, I have a list of ids, and I need to obtain the records
keeping
the list order. In MySQL I can use FIELD() in the "order by" for
that.
Can I get the ordered records using the DAL?


The DAL doesn't have anything built in that will work across database 
backends, but if you are using MySQL, you should be able to do:


|
db(query).select(orderby='Field(id, %s)'%', '.join(str(id)forid 
inlist_of_ids))

|

Alternatively, if the list is not too long, you can just do the 
sorting in Python after selection:


|
db(query).select().sort(lambdar:list_of_ids.index(r.id))
|

Anthony

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

For more options, visit https://groups.google.com/d/optout.


--
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: SyntaxError: table already defined: definition

2018-04-22 Thread Maurice Waka
I tried not recreating the DAL object but got the error : DAL has no
attribute: 'definition'

On Sun, 22 Apr 2018, 18:31 Anthony  wrote:

> Hard to say for sure without seeing the code for the definition()
> function, but presumably the reference() function is being called more than
> once -- every time after the first, it is attempting to redefine a table
> that has already been defined (which is not allowed unless you set
> redefine=True).
>
> Also, there is no reason to keep recreating the DAL object (and if you are
> going to do that, there is no reason to keep adding it to current, as you
> are not using the object added to current but simply creating a new object
> in each module). Just create the DAL object once in a model file and add it
> to current there.
>
> Actually, a better approach may be to just make the db object an argument
> of the functions that use it, which will make everything more explicit:
>
> define = definition(db)
>
> Anthony
>
> On Sunday, April 22, 2018 at 11:08:05 AM UTC-4, Maurice Waka wrote:
>>
>> I have a module that imports another that reads a db as follows:
>>
>> from gluon import current
>> from pydal import DAL, Field
>> from unidecode import unidecode
>> from applications.Hestque_Wellness.modules.Hestquewell.q_refs import
>> definition
>> db = DAL('sqlite://storage.sqlite')
>> current.db = db
>> define = definition()
>>
>>
>> The imported module is as follows:
>>
>> from gluon import current
>> from pydal import DAL, Field
>> db = DAL('sqlite://storage.sqlite')
>> current.db = db
>>
>>
>> def reference():
>> db = current.db
>> db.define_table('definition', Field('definition'), migrate=False)
>> rows = db(db.definition).select()
>> for row in rows:
>> return row.definition
>>
>> I keep getting this error:
>>
>> definition = definition()
>>   File "applications/Hestque_Wellness/modules/Hestquewell/q_refs.py", line 
>> 321, in definition
>> db.define_table('definition', Field('definition'), migrate=False)
>>   File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 571, in 
>> define_table
>> raise SyntaxError('table already defined: %s' % tablename)
>> SyntaxError: table already defined: definition
>>
>> what could be the problem?
>>
>>
>> Kind regards
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/7xCGTfc6xAA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Get rows by id list keeping the order

2018-04-22 Thread Anthony
On Sunday, April 22, 2018 at 11:46:13 AM UTC-4, Carlos Cesar Caballero 
wrote:
>
> Hi guys, I have a list of ids, and I need to obtain the records keeping 
> the list order. In MySQL I can use FIELD() in the "order by" for that. 
> Can I get the ordered records using the DAL?
>

The DAL doesn't have anything built in that will work across database 
backends, but if you are using MySQL, you should be able to do:

db(query).select(orderby='Field(id, %s)' % ', '.join(str(id) for id in 
list_of_ids))

Alternatively, if the list is not too long, you can just do the sorting in 
Python after selection:

db(query).select().sort(lambda r: list_of_ids.index(r.id))

Anthony

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


[web2py] Get rows by id list keeping the order

2018-04-22 Thread Carlos Cesar Caballero Díaz
Hi guys, I have a list of ids, and I need to obtain the records keeping 
the list order. In MySQL I can use FIELD() in the "order by" for that. 
Can I get the ordered records using the DAL?


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.


[web2py] Re: 1 field with 2 different represent

2018-04-22 Thread Anthony
On Saturday, April 21, 2018 at 6:00:21 PM UTC-4, 黄祥 wrote:
>
> *case:*
> let say i have field mobile_phone in the table, i want whatever user input 
> can shown in two format:
> 123
> and
> https://api.whatsapp.com/send?phone=123;>123
>
> is it possible to have 1 field with 2 different represent or should i 
> create virtual field or just create new field?
>

It's not clear what you mean. Even if that were possible, how would you 
expect it to work? Where are you using it?

Anthony

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


[web2py] Re: SyntaxError: table already defined: definition

2018-04-22 Thread Anthony
Hard to say for sure without seeing the code for the definition() function, 
but presumably the reference() function is being called more than once -- 
every time after the first, it is attempting to redefine a table that has 
already been defined (which is not allowed unless you set redefine=True).

Also, there is no reason to keep recreating the DAL object (and if you are 
going to do that, there is no reason to keep adding it to current, as you 
are not using the object added to current but simply creating a new object 
in each module). Just create the DAL object once in a model file and add it 
to current there.

Actually, a better approach may be to just make the db object an argument 
of the functions that use it, which will make everything more explicit:

define = definition(db)

Anthony

On Sunday, April 22, 2018 at 11:08:05 AM UTC-4, Maurice Waka wrote:
>
> I have a module that imports another that reads a db as follows:
>
> from gluon import current
> from pydal import DAL, Field
> from unidecode import unidecode
> from applications.Hestque_Wellness.modules.Hestquewell.q_refs import 
> definition
> db = DAL('sqlite://storage.sqlite')
> current.db = db
> define = definition()
>
>
> The imported module is as follows:
>
> from gluon import current
> from pydal import DAL, Field
> db = DAL('sqlite://storage.sqlite')
> current.db = db
>
>
> def reference():
> db = current.db
> db.define_table('definition', Field('definition'), migrate=False)
> rows = db(db.definition).select()
> for row in rows:
> return row.definition
>
> I keep getting this error:
>
> definition = definition()
>   File "applications/Hestque_Wellness/modules/Hestquewell/q_refs.py", line 
> 321, in definition
> db.define_table('definition', Field('definition'), migrate=False)
>   File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 571, in 
> define_table
> raise SyntaxError('table already defined: %s' % tablename)
> SyntaxError: table already defined: definition
>
> what could be the problem?
>
>
> Kind regards
>
>

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


Re: [web2py] web2py, nginx and big files

2018-04-22 Thread Carlos Cesar Caballero Díaz

Thanks Richard, I will take a look.

Greetings.


El 20/04/18 a las 14:56, Richard Vézina escribió:

You seems to have found good information...

I don't have much time to investigate that subject and realize it 
could be quite complexe...


And involve security issue : 
https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/



Although, I thought that you might have a read that code base of apps 
like these listing :


https://opensource.com/life/15/12/5-open-source-web-apps-self-hosted

This kind of apps surely had to workaround large file issue that you 
have...


Richard

On Fri, Apr 20, 2018 at 10:39 AM, Carlos Cesar Caballero Díaz 
> wrote:



El 19/04/18 a las 16:21, Richard Vézina escribió:

Ah ok, make sens then. Are you storing the file in database or on
file system at web2py level??



In the file system, I think that storing big (or so many) files in
the database can overload it.



There is surely a way to make the copy only once at the right
place, but I am pretty sure it mean writting some customization
at uwsgi level and most probably some conf in nginx to bypass it
usual mechanism.


I have being reading and found this
https://stackoverflow.com/a/44751210/1818267
 its interesting,
besides it carries some new issues to solve.



I try to make some research and get back to you if I can fin
anything that could help.

Good luck


Thanks, I'll be very grateful (more grateful :D).

Greetings



Richard

On Wed, Apr 18, 2018 at 10:37 PM, Carlos Cesar Caballero Díaz
> wrote:


El 18/04/18 a las 13:54, Richard Vézina escribió:

That big... Hope it could work for you...


Well, right now is working with your suggestion, but not
perfect, is really slow because nginx uploads the file to a
tmp file, next seems to copy the file to another place (I
assume to uwsgi) and next is copied to web2py uploads, really
annoying. I think that there should be a better way to do that.



Are you trying to make El packet transiting the island
faster or what...

:D


Not exactly, but I like how you think :D

I am working with Joven Club, a "company" that provides
technical and learning services throughout the country, and I
am building a tool for helping with the software installation
service, it's really simple, basically a software installers
repository where people can search and download (and certain
people upload the files, of course).




Richard

On Wed, Apr 18, 2018 at 1:45 PM, Carlos Cesar Caballero Díaz
> wrote:

Thanks Richard, It seems to be working now. The files
can be several Gigabytes.


Greetings.


El 17/04/18 a las 13:10, Richard Vézina escribió:

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 > wrote:

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
   

[web2py] Re: Adding custom attributes to fields and tables

2018-04-22 Thread Anthony
First, what happens when you try:

db.person.salutation.mycustomwidget = 'select2'

Second, what are you really trying to do? How do you intend to use that 
custom attribute exactly?

Anthony


On Sunday, April 22, 2018 at 6:15:03 AM UTC-4, xelomac wrote:
>
> I want to add a custom attribute so that I can decide which customwidget 
> has to be used for a form field connected to that field.
> Example:
>
> db.define_table('person',
> Field('salutation', mycustomwidget='select2', label = T('Salutation'), 
> requires=IS_IN_SET(GENDER), represent=lambda v, r: GENDER[v]),
> Field('first_name', label = T('First Name')),
> format = '%(last_name)s')
>
>
> I had no luck defining that custom attribute the way it is described in 
> the book. How and and where would I define such a custom attribute 
> 'mycustomwidget' for the table 'person' or even better for all tables?
>
> Adding attributes to fields and tables
>
> If you need to add custom attributes to fields, you can simply do this:
>
> 1
>
> db.table.field.extra = {}
>
> "extra" is not a keyword ; it's a custom attributes now attached to the 
> field object. You can do it with tables too but they must be preceded by an 
> underscore to avoid naming conflicts with fields:
>
> 1
>
> db.table._extra = {} 
>
>
>

-- 
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] SyntaxError: table already defined: definition

2018-04-22 Thread Maurice Waka
I have a module that imports another that reads a db as follows:

from gluon import current
from pydal import DAL, Field
from unidecode import unidecode
from applications.Hestque_Wellness.modules.Hestquewell.q_refs import 
definition
db = DAL('sqlite://storage.sqlite')
current.db = db
define = definition()


The imported module is as follows:

from gluon import current
from pydal import DAL, Field
db = DAL('sqlite://storage.sqlite')
current.db = db


def reference():
db = current.db
db.define_table('definition', Field('definition'), migrate=False)
rows = db(db.definition).select()
for row in rows:
return row.definition

I keep getting this error:

definition = definition()
  File "applications/Hestque_Wellness/modules/Hestquewell/q_refs.py", line 321, 
in definition
db.define_table('definition', Field('definition'), migrate=False)
  File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 571, in 
define_table
raise SyntaxError('table already defined: %s' % tablename)
SyntaxError: table already defined: definition

what could be the problem?


Kind regards

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


[web2py] Adding custom attributes to fields and tables

2018-04-22 Thread xelomac
I want to add a custom attribute so that I can decide which customwidget 
has to be used for a form field connected to that field.
Example:

db.define_table('person',
Field('salutation', mycustomwidget='select2', label = T('Salutation'), 
requires=IS_IN_SET(GENDER), represent=lambda v, r: GENDER[v]),
Field('first_name', label = T('First Name')),
format = '%(last_name)s')


I had no luck defining that custom attribute the way it is described in the 
book. How and and where would I define such a custom attribute 
'mycustomwidget' for the table 'person' or even better for all tables?

Adding attributes to fields and tables

If you need to add custom attributes to fields, you can simply do this:

1

db.table.field.extra = {}

"extra" is not a keyword ; it's a custom attributes now attached to the 
field object. You can do it with tables too but they must be preceded by an 
underscore to avoid naming conflicts with fields:

1

db.table._extra = {} 


-- 
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.