[web2py] Re: belongs handle if there is only one value

2017-07-29 Thread 黄祥
thx 4 the way out massimo, another way is to use if condition that check 
the data type
*e.g.*
if test0 != 'None' and type(test0) == 'str':
query = (db.test1.test0 == test0)
elif test0 != 'None' and type(test0) == 'list':
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)

thanks and best regards,
stifan

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


Re: [web2py] Datatables Query String Parsing

2017-07-29 Thread villas
Thanks for responses and José that code will be a good help.

In my case, parsing the query is quite trivial to extract a search string 
and the sort order,  which is all I needed just now.

After playing around more,  it seems to me that Web2py would be really 
improved with something like Datatables (as well as the sqlform grid).

   - For small datasets you can feed in all the data at once and use js 
   pagination and searching etc.  It's quick and avoids a lot of queries.
   - For large datasets,  the ajax interaction is great.


The number of queries that the sqlform grid produces is very inefficient,  
and that is why I have been experimenting with Datatables in the first 
place.

Indeed Datatables seems to fit really well with Massimo's ideas for the 
future (I mean making better use of the client-side and reducing 
bandwidth).  

Best 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] Re: Weird problems generating menu from database

2017-07-29 Thread Вячеслав Анатольевич
Hi!

Paraphrase the question, can anyone explain how to create 
a drop-down menu from a database table or show a working example?

-- 
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: IMPORTANT - WEB2PY CONSULTING

2017-07-29 Thread Oasis Agano
Hello,

Can you add me too?
Name: Oasis AGANO

Software developer/consultant & Digital Nomad.
I've been using web2py since 2014.

I will share my site later(work in progress).
meanwhile my email is oasisag...@gmail.com.


kr,
Oasis

On Monday, February 16, 2015 at 12:21:36 AM UTC+2, Massimo Di Pierro wrote:
>
> We need to update the list of companies that provide web2py consulting.
> This list is obsolete:
>
> http://web2py.com/init/default/support
>
> Some links are broke. Most pages do not even mention web2py. Some of them 
> have a design that is simply not acceptable for a web development company.
>
> That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
> page to have a decent design and MENTION WEB2PY on the main site. Then 
> respond to this thread by providing an updated link and the country were 
> you incorporated. If you have a self-employed individual list your country 
> of residence.
>
>

-- 
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: belongs handle if there is only one value

2017-07-29 Thread Massimo Di Pierro
shouldn't this be:

if test0 != None and type(test0) == str:
query = (db.test1.test0 == test0)
elif test0 != None and type(test0) == list:
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)

On Saturday, 29 July 2017 02:27:41 UTC-5, 黄祥 wrote:
>
> thx 4 the way out massimo, another way is to use if condition that check 
> the data type
> *e.g.*
> if test0 != 'None' and type(test0) == 'str':
> query = (db.test1.test0 == test0)
> elif test0 != 'None' and type(test0) == 'list':
> query = (db.test1.test0.belongs(test0) )
> else:
> query = (db.test1.id > 0)
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: Weird problems generating menu from database

2017-07-29 Thread Massimo Di Pierro
Let me assume there is only one level and this cannot be arbitrarily 
nested. Also I assume the initial model of this thread:

db.define_table('store_catalog',
Field('maincategory', 'string'),
Field('subcategory', 'string'),
Field('description', 'text'))

t = store_catalog
rows = db(t).select()
from collections import defaultdict
d=defaultdict(list)
for row in rows: d[row.maincategory].append(row.subcategory)
response.menu = [
[T(key), False, None, [[T(sub), False, 'link'] for sub in 
sorted(d[key])]] for key in sorted(d)
]

On Saturday, 29 July 2017 08:00:40 UTC-5, Вячеслав Анатольевич wrote:
>
> Hi!
>
> Paraphrase the question, can anyone explain how to create 
> a drop-down menu from a database table or show a working example?
>
>

-- 
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: Execution error of script sessions2trash

2017-07-29 Thread domezzzz


El viernes, 28 de julio de 2017, 17:07:21 (UTC-3), dome escribió:
>
> Version: 2.15.2-stable+timestamp.2017.07.19.12.18.41 
> 
>  web2py.exe for windows
>
> Start logging--
>File "c:\web2py_sitio\gluon\shell.py", line 268, in run 
>  execfile(startfile, _env)
>File "scripts/sessions2trash.py", line 90
>  print 'key: %s' % str(item)
>^
>SyntaxError: invalid syntax
> End logging--
>
> Adding any print '.' or print('...) or print sys.argv, gives error.
> And also, in any source that is launched in cmd mode.
> It looks like a web2py.exe problem
> In version 2.14.6 works.
>
> Regards.
> -
> 29.07.2017
> ¡ups!
> Apologies, I did not do all the relevant tests.
> You had to change ALL the print to py3 form.
>

-- 
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: belongs handle if there is only one value

2017-07-29 Thread 黄祥
if test0 != None and type(test0) == str:
query = (db.test1.test0 == test0)
elif test0 != None and type(test0) == list:
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)

return error traceback when access 
http://127.0.0.1:8000/a/default/test1?test0=None#
*ValueError: invalid literal for long() with base 10: 'None'*

this works
if test0 != 'None' and type(test0) == str:
query = (db.test1.test0 == test0)
elif test0 != 'None' and type(test0) == list:
query = (db.test1.test0.belongs(test0) )
else:
query = (db.test1.id > 0)

sometime i confuse the null value (None or '') in web2py, what works in 
models or database side and what works in controllers and views side is 
different.
like example above, when i put the code in models None is works but as an 
example above i put it on controllers or view side, it should be 'None'
another thing is for query or update value to set null value assign it into 
None or ''

thanks and best regards,
stifan

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


[web2py] Re: Weird problems generating menu from database

2017-07-29 Thread Вячеслав Анатольевич
Thanks for the answer, Massimo!

But this example makes the menu items in one line with one drop-down menu item.
Like this:

Menuitem Menuitem
- submenuitem- submenuitem

I have three fields, they must be somthing like this (anothermenu - just for 
example - to understand that is top menu):

 
 
Menuitem
- submenuitem
   - subsubmenuitem
- submenuitem
- submenuitem
Menuitem
-submenuitem
-submenuitem
- subsubmenuitem
- subsubmenuitem
- subsubmenuitem
-submenuitem
-submenuitem

Please, can you tell me how to do 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.