[web2py] Re: put multiple database tables like grid in one place

2017-08-28 Thread 黄祥
trying your suggestion with datatables that have web2py multiple table 
relations join
*ref:*
http://www.web2pyslices.com/slice/show/2052/using-datatablesnet-with-web2py-for-ultra-fast-grid-display

*models/db.py*
db.define_table('sale_order', Field('sale_order_no') )
db.define_table('cash_in', Field('cash_in_no'), Field('sale_order_no', 
'reference sale_order') )
db.define_table('cash_out', Field('cash_out_no'), Field('sale_order_no', 
'reference sale_order') )
if db(db.sale_order).isempty():
db.sale_order.update_or_insert(sale_order_no = 'SO1')
db.cash_in.update_or_insert(cash_in_no = 'CI1', sale_order_no = 1)
db.cash_in.update_or_insert(cash_in_no = 'CI2', sale_order_no = 1)
db.cash_out.update_or_insert(cash_out_no = 'CO1', sale_order_no = 1)
db.cash_out.update_or_insert(cash_out_no = 'CO2', sale_order_no = 1)

*controllers/default.py*
def index():
import json
#query = ((db.cash_in.sale_order_no == db.sale_order.id) | 
(db.cash_out.sale_order_no == db.sale_order.id) )
#rows = db(query).select().as_list()
#left = [db.cash_in.on(db.sale_order.id == db.cash_in.sale_order_no), 
db.cash_out.on(db.sale_order.id == db.cash_out.sale_order_no) ]
left = db.cash_in.on(db.sale_order.id == db.cash_in.sale_order_no)
rows = db().select(db.sale_order.ALL, db.cash_in.ALL, left = left)
people = json.dumps(rows)
return dict(results = XML(people) )

*views/default/index.html*
{{extend 'layout.html'}}
https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js";>
https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css";>



Sale Order No
Cash In No
Cash Out No




$(document).ready(function(){
$("#person-table").DataTable({
data:  {{=results}},
columns: [
{ data: 'sale_order.sale_order_no' },
{ data: 'cash_in.cash_in_no' },
{ data: 'cash_out.cash_out_no' }
]
})
});


*Return an error traceback*
Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 219, in 
restricted
exec(ccode, environment)
  File 
"/Users/MacBookPro/site/web2py/applications/a/controllers/default.py", line 
60, in 
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 409, in 

self._caller = lambda f: f()
  File 
"/Users/MacBookPro/site/web2py/applications/a/controllers/default.py", line 
19, in index
people = json.dumps(rows)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
 
line 243, in dumps
return _default_encoder.encode(obj)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 270, in iterencode
return _iterencode(o, 0)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py",
 
line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError:  is not JSON serializable

is it possible to pass dal join rows result into json format in web2py?

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] Google Survey

2017-08-28 Thread Shazia Nusrat
Hi,

Is there any web reference for web2py application like google survey?
Appreciate if someone can refer me to repo or web reference.

I need to fully design we2py Survey application just like google where
users should be able to create surveys and also take surveys.

Regards,
Shazia

-- 
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: Alias column names (akin to AS clause) in db select

2017-08-28 Thread Paolo Caruccio
Maybe 

def test():
rows = db(db.Table1.foo==db.Table2.foo).select(db.Table1.foo.with_alias(
'foo'), db.Table2.bar.with_alias('blah'))
for row in rows:
print row.foo, row.blah
return locals()

should work.

Another way - if you can rewrite tables definitions - is to use the "rname" 
field value. From the web2py book 
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?#Field-constructor
 

>
> *rname* provides the field was a "real name", a name for the field known 
> to the database adapter; when the field is used, it is the rname value 
> which is sent to the database. *The web2py name for the field is then 
> effectively an alias*.


So with 

db.define_table('Table2', Field('blah', 'string', rname="bar")

the query becomes

db(db.Table1.foo==db.Table2.foo).select(db.Table1.foo, db.Table2.blah)

If you want alias fields in a query without joins you could write

rows = db(db.Table2.id>0).select('bar AS blah')



Il giorno lunedì 28 agosto 2017 08:50:20 UTC+2, Brendan Barnwell ha scritto:
>
> On Monday, July 31, 2017 at 1:25:31 PM UTC-7, Paolo Caruccio wrote:
>>
>> Maybe the web2py book could help you:
>>
>>
>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=with_alias#Self-Reference-and-aliases
>>
>>
> That appears to only be talking about using aliases for tables, and 
> specifically to be able to create and query tables that reference one 
> another.  What I'm describing is conceptually much simpler than that: I 
> just want to take a query that already works and give my own names to the 
> columns of the result.
>

-- 
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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread 98ujko9
I removed routes_in and routes_out. The routes.py file in the site's root 
looks like so:


routers = dict(
# base router
BASE=dict(
default_application='init',
),
stock=dict(
default_function='index',
functions=dict(
default=['index','call','download','user',],
showcase=['index',]
)
),
)


During development I launch the stock app from the administrative interface 
and the address bar shows:
https://192.168.1.25:8000/stock 

/default
During its running one  menu item STOCK (it serves as home button, 
beginning of listing) is visible, rendered by code:

response.menu_stock = [(T('Stock'), False, URL('stock','default','index'), 
[])
]
 upon clicking on it the address bar also shows:
https://192.168.1.25:8000/stock 

/default

I have two more apps in this site:

INIT- which is sort of like a facade for the website when you type the 
domain name in the browser it starts. 
I launch STOCK app from within INIT with the same menu construct as above. 
The browser also shows 'default'.

NOTES- which are instructions to myself and my customer.

I may add more apps in this project down the road.

Curious, when I launch the app through address bar by typing: 
https://192.168.1.25:8000/stock 

the app starts and the address bar remains unchanged.

Thanks for you time.

 
On Monday, August 28, 2017 at 2:40:07 PM UTC-4, Anthony wrote:
>
> First, get rid of routes_in/routes_out -- they will not work in 
> conjunction with "router".
>
> Regarding "default" in the URL -- how are you generating the URL. You can 
> always add default_controller="default", but that should not be necessary, 
> as "default" is the default value for default_controller anyway.
>
> Anthony
>
> On Monday, August 28, 2017 at 2:14:15 PM UTC-4, 98u...@gmail.com 
>  wrote:
>>
>> Big thank you! This works.
>>
>> One little detail emerged though. Now that  I replaced the pattern 
>> router.py (having my line in routes_out as above) in my site root with the 
>> parameter rewrite method my URL shows 'default':
>>
>> https://192.168.1.25:8000/stock 
>> 
>> /default
>> and I was aiming for:
>> https://192.168.1.25:8000/stock 
>> 
>>
>> I added a line: controllers='DEFAULT' has no effect:
>>
>> routers = dict(
>> stock=dict(
>> controllers='DEFAULT',
>> default_function='index',
>> functions=dict( 
>> default=['index', ...],
>> showcase=['index', ...]
>> )
>> ),
>> )
>>
>> Thanks for your time
>>
>> On Monday, August 28, 2017 at 11:19:09 AM UTC-4, Anthony wrote:
>>>
>>> On Monday, August 28, 2017 at 10:05:27 AM UTC-4, 98u...@gmail.com wrote:

 No, the name 'index' withing 'showcase' is idle.

>>>
>>> Then just use the parameter-based rewrite system with a configuration 
>>> like this:
>>>
>>> routers = dict(
>>> stock=dict(
>>> default_function='index',
>>> functions=dict(
>>> default=['index', ...],
>>> showcase=['index', ...]
>>> )
>>> ),
>>> )
>>>
>>> Then simply change the "asset" function to "index".
>>>
>>> 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: put multiple database tables like grid in one place

2017-08-28 Thread Dave S


On Monday, August 28, 2017 at 2:50:29 PM UTC-7, 黄祥 wrote:
>
> my current models
> db.define_table('sale_order', 
> Field('sale_order_no'), 
> Field('sale_order_date', 'date'),
> Field('customer', 'reference customer'), 
> Field('product', 'reference product'), 
> Field('quantity', 'integer'),
> Field('price', 'double'),
> Field('total_price', 'double'),
> Field('grand_total', 'double'),
> Field('discount_percentage', 'double'),
> Field('discount_nominal', 'double'),
> Field('tax_percentage', 'double'),
> Field('tax_nominal', 'double'),
> Field('service_tax_percentage', 'double'),
> Field('service_tax_nominal', 'double'),
> Field('grand_total_net', 'double'),
> Field('total_paid', 'double'),
> Field('paid_return', 'double'),
> format = '%(sale_order_no)s')
>
> db.define_table('cash_in', 
> Field('cash_in_no'), 
> Field('cash_in_date', 'date'),
> Field('transaction_no'), 
> Field('chart_of_account', 'reference chart_of_account'), 
> Field('amount', 'double'), 
> Field('discount', 'double'), 
> Field('place', 'reference chart_of_account'), 
> format = '%(cash_in_no)s')
>
> db.define_table('cash_out', 
> Field('cash_out_no'), 
> Field('cash_out_date', 'date'),
> Field('transaction_no'), 
> Field('chart_of_account', 'reference chart_of_account'), 
> Field('amount', 'double'), 
> Field('discount', 'double'), 
> Field('place', 'reference chart_of_account'), 
> format = '%(cash_out_no)s')
>
> i usually divide table order as :
> - header (for field order_no, order, date, customer, etc except the 
> product ordered) 
> - detail (for field product, qty, price, total price)
> now i combine it into 1 table, so that user can see the the header and 
> detail in 1 sqlform grid table (frontend)
> but sometime in 1 transaction user will have multiple payment (cash_in), 
> costs (cash_out) and tax (cash_out)
> so i want to combine the 3 table above into 1 single grid view
> just don't know how to do either redefine my table or use js framework for 
> view, tried sqlform.grid with left join before but the search is contain of 
> repeated table fields.
>
> thanks and best regards,
> stifan
>


This is useful detail, but by "sketch" I was thinking of some sort of 
mock-up of what the user would on the screen.

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


Re: [web2py] Re: Currency formating

2017-08-28 Thread Daniel Dos Santos Guilhermino
Bruno,

It's so old! But helped a lot.

Thank you.

Any way, news about locale?

Best regards,

Daniel Guilhermino

Em quarta-feira, 25 de agosto de 2010 18:03:54 UTC-3, rochacbruno escreveu:
>
> I solved using temporarily this:
>
> def Moeda(valor, formatado=True):
> from locale import setlocale, currency, LC_ALL
> try:
> setlocale(LC_ALL,'pt_BR.UTF-8')
> except:
> setlocale(LC_ALL,'portuguese')
>
> if formatado:
> return 'R$ %s' % currency(valor, grouping=True, symbol=False)
> else:
> return currency(valor, grouping=False, 
> symbol=False).replace(',','')
>
>
> >>> Moeda(1)
> R$ 10.000,00
>
> This will be okay until I have more apps running on the same server, now I 
> have just one.
>
> I am trying to figure out the best way 
>
> 2010/8/25 Bruno Rocha >
>
>> Massimo,
>>
>> What is your recomendation to deal with currency in web2py?
>>
>> 2010/8/25 Bruno Rocha >
>>
>> Look at 
>>> http://code.google.com/p/python-money/source/browse/trunk/money/Money.py
>>>
>>> Python-money does not use "locale"
>>>
>>> 2010/8/25 mdipierro >
>>>
>>> web2py cannot support locale because it is not thread safe, If one app
 changes the locale it would change it for all apps.

 On Aug 25, 12:07 am, Bruno Rocha  wrote:
 > Hi,
 >
 > Actually, I am using these methods to work with money formating.
 >
 > some tries with python-money and works very wellhttp://
 code.google.com/p/python-money/
 >
 > and sometimes
 >
 > import locale
 > locale.setlocale(locale.LC_ALL,('pt_BR','UTF8'))>>> 
 locale.currency(1090909, grouping=True)
 >
 > 'R$ 1.090.909,00'
 >
 > So I a thinking about, how to include that as a DAL type? exactly in
 > the same way web2py threats with Upload fields, we could have a
 > datatype 'money' working with 'locale'
 >
 > 
 db.define_table('product',Field('price','money',locale=('pt_BR','UTF8')))
 > or even declaring locale.setlocale() in the begining of the model file
 >
 > By now I am doing that with 'represent' or directly in views, but,
 > Is there any chance to include that in web2py core?

>>>
>>>
>>>
>>> -- 
>>>
>>> http://rochacbruno.com.br
>>>
>>
>>
>>
>> -- 
>>
>> http://rochacbruno.com.br
>>
>
>
>
> -- 
>
> http://rochacbruno.com.br
>

-- 
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: Two database join query

2017-08-28 Thread 黄祥
had you tried ?
*e.g. not tested*
rows = db(db1.table1.pid == db2.table2.pid).select()

ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Inner-joins

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: put multiple database tables like grid in one place

2017-08-28 Thread 黄祥
my current models
db.define_table('sale_order', 
Field('sale_order_no'), 
Field('sale_order_date', 'date'),
Field('customer', 'reference customer'), 
Field('product', 'reference product'), 
Field('quantity', 'integer'),
Field('price', 'double'),
Field('total_price', 'double'),
Field('grand_total', 'double'),
Field('discount_percentage', 'double'),
Field('discount_nominal', 'double'),
Field('tax_percentage', 'double'),
Field('tax_nominal', 'double'),
Field('service_tax_percentage', 'double'),
Field('service_tax_nominal', 'double'),
Field('grand_total_net', 'double'),
Field('total_paid', 'double'),
Field('paid_return', 'double'),
format = '%(sale_order_no)s')

db.define_table('cash_in', 
Field('cash_in_no'), 
Field('cash_in_date', 'date'),
Field('transaction_no'), 
Field('chart_of_account', 'reference chart_of_account'), 
Field('amount', 'double'), 
Field('discount', 'double'), 
Field('place', 'reference chart_of_account'), 
format = '%(cash_in_no)s')

db.define_table('cash_out', 
Field('cash_out_no'), 
Field('cash_out_date', 'date'),
Field('transaction_no'), 
Field('chart_of_account', 'reference chart_of_account'), 
Field('amount', 'double'), 
Field('discount', 'double'), 
Field('place', 'reference chart_of_account'), 
format = '%(cash_out_no)s')

i usually divide table order as :
- header (for field order_no, order, date, customer, etc except the product 
ordered) 
- detail (for field product, qty, price, total price)
now i combine it into 1 table, so that user can see the the header and 
detail in 1 sqlform grid table (frontend)
but sometime in 1 transaction user will have multiple payment (cash_in), 
costs (cash_out) and tax (cash_out)
so i want to combine the 3 table above into 1 single grid view
just don't know how to do either redefine my table or use js framework for 
view, tried sqlform.grid with left join before but the search is contain of 
repeated table fields.

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] Re: web2py 2.15.3 is OUT

2017-08-28 Thread Anthony
On Monday, August 28, 2017 at 2:03:43 PM UTC-4, Yoel Benitez Fonseca wrote:
>
> Hi, 
>
> new copy of 2.15.3, create a model with a date Field - using SQLite, 
> in appadmin or a CRUD form the date widget don't show the year, just 
> the name of the day.
>

How is this related to the current thread?

-- 
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: put multiple database tables like grid in one place

2017-08-28 Thread Dave S


On Wednesday, August 23, 2017 at 2:58:49 PM UTC-7, 黄祥 wrote:
>
> is there any way to put multiple database tables like grid in one place 
> using web2py way? 
>

Can you sketch some sort of mock up, so we have a clearer idea of what 
you'd like?
 

> tried before just using 2 database tables, and use distinct on 
> SQLFORM.grid but theres a lot of redundant/repeated data in the 
> SQLFORM.grid search form field.
> e.g. database tables
> sale_order_header (field : sale_order_no, sale_order_date, customer)
> sale_order_detail (field : sale_order_id, product, qty, price, total_price)
> cash_in (field : sale_order_id, coa, amount) # for payment
> cash_out (field : sale_order_id, coa, amount) # for costs
>
> is my database table schema relationship is right, or should i combine it 
> into 1 table? 
> or should i tried to the nosql database like mongodb, so that i can put 
> all into 1 collection / table, and the field is repeated of all the child 
> table above ?
>
> thanks and best regards,
> stifan
>

Yet Another Way To Consider is using Datatables, and populating the display 
via client javascript.  Since I haven't actually tried using Datatables 
myself, my guess as to how hard that is based on examples others have 
posted here.

/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] Rocket logs and server crash

2017-08-28 Thread Dave S
I came in to a message from UptimeRobot that my server was down (4:20 am 
mytime).  So I check the logs ...

The httpserver.log file ends at 4:02, with the last successful UptimeRobot 
check.  The logs/web2py.log has 3 entries beyond that, at 4:05 Rocket is 
throwing an exception because self.sslobj.do_handshake() got "Connection 
reset by peer".  Unfortunately, the traceback report doesn't indicate who 
the peer is  is this something left over from the UR check, or a 
different client trying to access the service?

ps -ef indicated that all my python processes were still running, but my 
browser timed out looking for the index page.  I killed all the processes, 
restarted everything, and server is now responding normally to me and to 
UptimeRobot.  Even though I'm preparing to switch to nginx, I'd like to 
better understand the Rocket "crash".

The process had been started from the command line, and put in the 
background (and the parent shell eventually quitted).  As an orphan 
process, no console messages are on the screen, and there is no more detail 
in the logs than the 3 tracebacks (all the same).  The top level is 
rocket.py, line 590 (2.14.6), in listen(), which calls self.wrap_socket(), 
etc.  Is there any place besides the log to look for artifacts that would 
give me more information?  Oh, /var/log/messages has a "Possible SYN 
flooding pn port 443" entry at 4:05.

Thanks for any pointers.

Dave
/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: Two database join query

2017-08-28 Thread Artem
My app require two database .
This why i post a question here ... 

On Tuesday, August 29, 2017 at 1:55:09 AM UTC+8, Alfonso Serra wrote:
I guess this is the solution:
https:
//stackoverflow.com/questions/6824717/sqlite-how-do-you-join-tables-from-different-databases
 


If you want to write simpler sqls, the tables should be within the same 
database.

   is no question to standard sqlite library , i think .

-- 
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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread Anthony
First, get rid of routes_in/routes_out -- they will not work in conjunction 
with "router".

Regarding "default" in the URL -- how are you generating the URL. You can 
always add default_controller="default", but that should not be necessary, 
as "default" is the default value for default_controller anyway.

Anthony

On Monday, August 28, 2017 at 2:14:15 PM UTC-4, 98uj...@gmail.com wrote:
>
> Big thank you! This works.
>
> One little detail emerged though. Now that  I replaced the pattern 
> router.py (having my line in routes_out as above) in my site root with the 
> parameter rewrite method my URL shows 'default':
>
> https://192.168.1.25:8000/stock 
> 
> /default
> and I was aiming for:
> https://192.168.1.25:8000/stock 
> 
>
> I added a line: controllers='DEFAULT' has no effect:
>
> routers = dict(
> stock=dict(
> controllers='DEFAULT',
> default_function='index',
> functions=dict( 
> default=['index', ...],
> showcase=['index', ...]
> )
> ),
> )
>
> Thanks for your time
>
> On Monday, August 28, 2017 at 11:19:09 AM UTC-4, Anthony wrote:
>>
>> On Monday, August 28, 2017 at 10:05:27 AM UTC-4, 98u...@gmail.com wrote:
>>>
>>> No, the name 'index' withing 'showcase' is idle.
>>>
>>
>> Then just use the parameter-based rewrite system with a configuration 
>> like this:
>>
>> routers = dict(
>> stock=dict(
>> default_function='index',
>> functions=dict(
>> default=['index', ...],
>> showcase=['index', ...]
>> )
>> ),
>> )
>>
>> Then simply change the "asset" function to "index".
>>
>> 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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread 98ujko9
Big thank you! This works.

One little detail emerged though. Now that  I replaced the pattern 
router.py (having my line in routes_out as above) in my site root with the 
parameter rewrite method my URL shows 'default':

https://192.168.1.25:8000/stock 

/default
and I was aiming for:
https://192.168.1.25:8000/stock 


I added a line: controllers='DEFAULT'

routers = dict(
stock=dict(
controllers='DEFAULT',
default_function='index',
functions=dict( 
default=['index', ...],
showcase=['index', ...]
)
),
)

Thanks for your time

On Monday, August 28, 2017 at 11:19:09 AM UTC-4, Anthony wrote:
>
> On Monday, August 28, 2017 at 10:05:27 AM UTC-4, 98u...@gmail.com 
>  wrote:
>>
>> No, the name 'index' withing 'showcase' is idle.
>>
>
> Then just use the parameter-based rewrite system with a configuration like 
> this:
>
> routers = dict(
> stock=dict(
> default_function='index',
> functions=dict(
> default=['index', ...],
> showcase=['index', ...]
> )
> ),
> )
>
> Then simply change the "asset" function to "index".
>
> 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.


Re: [web2py] Re: web2py 2.15.3 is OUT

2017-08-28 Thread Yoel Benitez Fonseca
Hi,

new copy of 2.15.3, create a model with a date Field - using SQLite,
in appadmin or a CRUD form the date widget don't show the year, just
the name of the day.

I come from 2.14.6, don't know if this is something related only to
2.15.3 or is that i'm missing something.

2017-08-27 21:13 GMT-04:00 Anthony :
> It's not clear how that would be related to response.js, as it appears the
> code returned via response.js is in fact being executed in the browser. It's
> hard to say what's going wrong in the browser without knowing more about the
> JS and what the DOM looks like at that point.
>
> Anthony
>
>
> On Sunday, August 27, 2017 at 8:16:19 PM UTC-4, 黄祥 wrote:
>>
>> it seems response.js have a different behaviour in new version
>> e.g. (the same code work well in 2.14.6)
>> ...
>> if form.process().accepted:
>> ...
>> target_response = "jQuery('#test .close').click();
>> jQuery('#test').get(0).reload()"
>> response.js =  target_response
>> #redirect(request.env.http_web2py_component_location, client_side =
>> True)
>>
>> in 2.14.6, after the form submited it automatically reload the web2py
>> component and the page still responding, while in the latest version the
>> modal is closed, the component data is reload with new value but the page is
>> not responding, just have the dark silouette of the page, the solution is
>> must refresh the page or append :
>> redirect(request.env.http_web2py_component_location, client_side = True)
>> is it normal or did i missed something in the latest version ?
>>
>> 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.



-- 
Msc. Yoel Benítez Fonseca
Dpto. Informática. Redacción Adelante
http://www.adelante.cu/

-- 
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: Two database join query

2017-08-28 Thread Alfonso Serra
I guess this is the solution:
https://stackoverflow.com/questions/6824717/sqlite-how-do-you-join-tables-from-different-databases

If you want to write simpler sqls, the tables should be within the same 
database.

-- 
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: how to create pdf report in web2py???

2017-08-28 Thread António Ramos
We have a winner.
Great tool...


2017-08-26 14:19 GMT+01:00 Alex :

> We created a report tool since creating pdf reports in a web application
> is a common problem and none of the existing solutions were optimal for us.
> We needed something that is easy to integrate, easy to use (to design the
> reports) and easy to maintain (e.g. to create new versions of an existing
> report template).
>
> https://www.reportbro.com
>
> The designer to create report templates is a javascript plugin which can
> easily be integrated in a web application. Server-side we developed a
> python package - which you can either download or install via pip - to
> create the pdf (or xlsx) file with a given report template and data.
> Because it's python it is easy to use in an existing web2py app.
>
> We appreciate any kind of feedback!
>
> Alex
>
> --
> 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] weird issue with date field

2017-08-28 Thread Yoel Benitez Fonseca
hi, i got a new copy of the lasted stable web2py from web2py.com, put
in this simple model:

tbl = db.define_table(
"productos",
Field('nombre', 'string', length=100, label='Nombre'),
Field('codigo', 'string', length=30, label='Código'),
Field('fecha_caducidad', 'date', label='Fecha caducidad'),
Field('precio_compra', 'double', label='Precio compra'),
Field('precio_venta', 'double', label='Precio venta'),
)

tbl.nombre.requires = [IS_NOT_EMPTY()]
tbl.codigo.requires = [IS_NOT_EMPTY(), IS_LENGTH(11)]
tbl.fecha_caducidad.requires = IS_DATE()
tbl.precio_venta.requires.append(IS_NOT_EMPTY())
tbl.precio_compra.requires.append(IS_NOT_EMPTY())


And when testing the 'date' field in the page, with the default
widget, ignored the years putting instead the day name and 1900 as the
year.

¿is there something a'm missing? with 2.14.6 that dont happen.

I have tried with the format parameter in the validator with the same results.

-- 
Msc. Yoel Benítez Fonseca
Dpto. Informática. Redacción Adelante
http://www.adelante.cu/

-- 
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] Two database join query

2017-08-28 Thread Artem
Hello !
Hope someone can help . Thanks in advance !
I have two database :
db1 = DAL('sqlite://first.sqlite')
db2 = DAL('sqlite://second.sqlite')
with tables :
db1.define_table('table1',
Field('id',requires=IS_NOT_EMPTY()),
Field('pid',type='integer'),
Field('title',type='string'),
)
and
db2.define_table('table2',
Field('id',requires=IS_NOT_EMPTY()),
Field('pid',type='integer'),
Field('data',type='string'),
)
How to execute sqlite join ,something like: 
sql ="SELECT db1.id, db1.title,db2.data FROM db1.table1 INNER JOIN 
db2.table2 ON db2.table2.pid == db1.table1.pid"
db1.executesql(sql) doesn't work 


-- 
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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread Anthony
On Monday, August 28, 2017 at 10:05:27 AM UTC-4, 98uj...@gmail.com wrote:
>
> No, the name 'index' withing 'showcase' is idle.
>

Then just use the parameter-based rewrite system with a configuration like 
this:

routers = dict(
stock=dict(
default_function='index',
functions=dict(
default=['index', ...],
showcase=['index', ...]
)
),
)

Then simply change the "asset" function to "index".

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: easy deploy on OpenShift

2017-08-28 Thread Manuele

Il 22/08/2017 11:02, Manuele ha scritto:


Dear web2py users,

I'd like to submit to your attention this github project:

https://github.com/manuelep/openshift_web2py

it's a fork from the original homonym project  no more mantained.


Uhm... ok Openshift announced that it's going to dismiss accounts of 
version 2 of their services... can anybody help me to update project to 
version 3 of the Openshift service?


Thanks a lot

Manuele

--
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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread 98ujko9
No, the name 'index' withing 'showcase' is idle.

On Monday, August 28, 2017 at 9:56:13 AM UTC-4, Anthony wrote:
>
> Do you have a /showcase/index function?
>
> On Monday, August 28, 2017 at 2:03:40 AM UTC-4, 98u...@gmail.com 
>  wrote:
>>
>> I chose pattern-based rewrite because I don't know better. I am temporary 
>> part time web coder relying on web2py book 100% with understanding at about 
>> 60%. Being a mature person I am fond of eloquence in life as well as in 
>> URL's however complexity has its price. I sense from what you are saying I 
>> should stick with parametric router or leave it alone and keep the "asset" 
>> function where it naturally is . A quick sketch of what I am having fun 
>> with (this is ongoing process):
>>
>>
>> 
>> Thanks in advance.
>>
>> On Sunday, August 27, 2017 at 7:55:27 PM UTC-4, Anthony wrote:
>>>
>>> Got it. Next time, please provide more detail regarding your current 
>>> code/setup. Is there any particular reason you need to be using the 
>>> pattern-based rewrite system? If so, you'll just need to create a regex 
>>> that matches the route in question, or create a regex that matches all the 
>>> other possible functions in the controller and create a fallback route 
>>> *after* that to direct to the "asset" function.
>>>
>>> Anthony
>>>
>>> On Sunday, August 27, 2017 at 1:33:09 PM UTC-4, 98u...@gmail.com wrote:

 I could make "asset" function the default for the "showcase" controller 
 however I am not sure how as I am already using renamed 
 routes.patterns.example.py (the book recommends not to mix pattern and 
 parameter routing methods) in the root of the website (multiple apps in my 
 case) to rewrite one URL (works nicely):

 routes_out = (
 ('/stock/default/index',BASE + '/stock'),# <== my addition
 # do not reroute admin unless you want to disable it
 ('/admin/$anything', BASE + '/admin/$anything'),
 # do not reroute appadmin unless you want to disable it
 ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
 # do not reroute static files
 ('/$app/static/$anything', BASE + '/$app/static/$anything'),
 # do other stuff
 (r'.*http://otherdomain\.com.* /app/ctr(?P.*)', r'\g'),
 (r'/app(?P.*)', r'\g'),
 # restore the BASE prefix
 ('/$anything', BASE + '/$anything'),
 )

 Thanks in advance for any assistance


 On Sunday, August 27, 2017 at 12:17:16 PM UTC-4, Anthony wrote:
>
> On Saturday, August 26, 2017 at 4:05:59 PM UTC-4, 98u...@gmail.com 
> wrote:
>>
>> How can I rewrite the URL (to drop asset):
>>
>> https://192.168.1.25:8000/stock/showcase/asset/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
>> to look like:
>>
>> https://192.168.1.25:8000/stock/showcase/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
>> the app 'stock' ins't default
>> the controllert 'showcase' isn't default
>> the function 'asset' isn't default
>>
>
> Do you use another function as the default within the "showcase" 
> controller? If not, you can define "asset" as the default function just 
> for 
> the "showcase" controller using the parameter-based router. 
> Alternatively, 
> you can use the default function to handle the above routes by checking 
> for 
> a URL arg and returning the appropriate response. For example, if the 
> default function is "index":
>
> def index():
> if not request.args:
> [code currently in the "index" function]
> else:
> [code currently in the "asset" function]
>
> Finally, you could use the pattern-based rewrite system, though that 
> can start to get complex.
>
> 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 rewrite an URL to drop a function name showing in the address bar

2017-08-28 Thread Anthony
Do you have a /showcase/index function?

On Monday, August 28, 2017 at 2:03:40 AM UTC-4, 98uj...@gmail.com wrote:
>
> I chose pattern-based rewrite because I don't know better. I am temporary 
> part time web coder relying on web2py book 100% with understanding at about 
> 60%. Being a mature person I am fond of eloquence in life as well as in 
> URL's however complexity has its price. I sense from what you are saying I 
> should stick with parametric router or leave it alone and keep the "asset" 
> function where it naturally is . A quick sketch of what I am having fun 
> with (this is ongoing process):
>
>
> 
> Thanks in advance.
>
> On Sunday, August 27, 2017 at 7:55:27 PM UTC-4, Anthony wrote:
>>
>> Got it. Next time, please provide more detail regarding your current 
>> code/setup. Is there any particular reason you need to be using the 
>> pattern-based rewrite system? If so, you'll just need to create a regex 
>> that matches the route in question, or create a regex that matches all the 
>> other possible functions in the controller and create a fallback route 
>> *after* that to direct to the "asset" function.
>>
>> Anthony
>>
>> On Sunday, August 27, 2017 at 1:33:09 PM UTC-4, 98u...@gmail.com wrote:
>>>
>>> I could make "asset" function the default for the "showcase" controller 
>>> however I am not sure how as I am already using renamed 
>>> routes.patterns.example.py (the book recommends not to mix pattern and 
>>> parameter routing methods) in the root of the website (multiple apps in my 
>>> case) to rewrite one URL (works nicely):
>>>
>>> routes_out = (
>>> ('/stock/default/index',BASE + '/stock'),# <== my addition
>>> # do not reroute admin unless you want to disable it
>>> ('/admin/$anything', BASE + '/admin/$anything'),
>>> # do not reroute appadmin unless you want to disable it
>>> ('/$app/appadmin/$anything', BASE + '/$app/appadmin/$anything'),
>>> # do not reroute static files
>>> ('/$app/static/$anything', BASE + '/$app/static/$anything'),
>>> # do other stuff
>>> (r'.*http://otherdomain\.com.* /app/ctr(?P.*)', r'\g'),
>>> (r'/app(?P.*)', r'\g'),
>>> # restore the BASE prefix
>>> ('/$anything', BASE + '/$anything'),
>>> )
>>>
>>> Thanks in advance for any assistance
>>>
>>>
>>> On Sunday, August 27, 2017 at 12:17:16 PM UTC-4, Anthony wrote:

 On Saturday, August 26, 2017 at 4:05:59 PM UTC-4, 98u...@gmail.com 
 wrote:
>
> How can I rewrite the URL (to drop asset):
>
> https://192.168.1.25:8000/stock/showcase/asset/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
> to look like:
>
> https://192.168.1.25:8000/stock/showcase/2017-Some-fridge?id=79&_signature=c2e7899530c858f1b478cb7ea5f03bb30d4f68e1
> the app 'stock' ins't default
> the controllert 'showcase' isn't default
> the function 'asset' isn't default
>

 Do you use another function as the default within the "showcase" 
 controller? If not, you can define "asset" as the default function just 
 for 
 the "showcase" controller using the parameter-based router. Alternatively, 
 you can use the default function to handle the above routes by checking 
 for 
 a URL arg and returning the appropriate response. For example, if the 
 default function is "index":

 def index():
 if not request.args:
 [code currently in the "index" function]
 else:
 [code currently in the "asset" function]

 Finally, you could use the pattern-based rewrite system, though that 
 can start to get complex.

 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.