[web2py] Re: db.company.insert() error

2017-08-29 Thread Ben Lawrence
def get_company_name(s):
"""Takes out common domain suffixes e.g. com, net

:param s: domain name
:type s: string

:returns: sanitized string
:rtype: unicode string
"""
return (((s.replace('.com',' ')).replace('.net',' '))\
.replace('.org',' '))\
.replace('.',' ').replace('co',' ')

On Tuesday, August 29, 2017 at 6:46:32 PM UTC-7, Anthony wrote:
>
> What does the get_company_name() function look like?
>
> On Tuesday, August 29, 2017 at 6:22:57 PM UTC-4, Ben Lawrence wrote:
>>
>> 2.15.3-stable+timestamp.2017.08.07.07.32.04
>> (Running on nginx/1.10.3, Python 2.7.12)
>>
>>
>> Hi
>> I hesitate to ask this because it will betray my stupidity
>>
>> I have this:
>>
>> *c_rows = db(db.company.domain_tag == c_domain).select()*
>> if *len(c_rows)==0*:  # add the company
>> c_id = db.company.insert(
>> name = get_company_name(c_domain),
>> e_mail = valid_email,
>> *domain_tag = c_domain )*
>> else:  # length MUST be one
>> c_id = c_rows.last().id
>>
>> and this the error:
>>
>> File "applications/remail/models/scheduler.py", line 120, in 
>> insert_company
>> domain_tag = c_domain )
>>   File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 734, in insert
>> ret = self._db._adapter.insert(self, row.op_values())
>>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 486, in insert
>> raise e
>> IntegrityError: duplicate key value violates unique constraint 
>> "company_domain_tag_key"
>> DETAIL:  Key (domain_tag)=(platronics.com) already exists.
>>
>>
>> Wha?! if domain_tag is already there would len(c_rows) > 0  and so would 
>> not try to insert the record?
>>
>>
>>

-- 
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-29 Thread Val K
try this trick:
db.Table1.blah = db.Table1.bar.clone(name = 'blah', _rname='bar')
db(...).select(db.Table1.blah)





On Tuesday, August 29, 2017 at 3:11:36 AM UTC+3, Paolo Caruccio wrote:
>
> 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: db.company.insert() error

2017-08-29 Thread Anthony
What does the get_company_name() function look like?

On Tuesday, August 29, 2017 at 6:22:57 PM UTC-4, Ben Lawrence wrote:
>
> 2.15.3-stable+timestamp.2017.08.07.07.32.04
> (Running on nginx/1.10.3, Python 2.7.12)
>
>
> Hi
> I hesitate to ask this because it will betray my stupidity
>
> I have this:
>
> *c_rows = db(db.company.domain_tag == c_domain).select()*
> if *len(c_rows)==0*:  # add the company
> c_id = db.company.insert(
> name = get_company_name(c_domain),
> e_mail = valid_email,
> *domain_tag = c_domain )*
> else:  # length MUST be one
> c_id = c_rows.last().id
>
> and this the error:
>
> File "applications/remail/models/scheduler.py", line 120, in insert_company
> domain_tag = c_domain )
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
> 734, in insert
> ret = self._db._adapter.insert(self, row.op_values())
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 486, in insert
> raise e
> IntegrityError: duplicate key value violates unique constraint 
> "company_domain_tag_key"
> DETAIL:  Key (domain_tag)=(platronics.com) already exists.
>
>
> Wha?! if domain_tag is already there would len(c_rows) > 0  and so would 
> not try to insert the record?
>
>
>

-- 
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: Print statement fails in command line script (v2.15.3)

2017-08-29 Thread Anthony
Looks like shell.py imports print_function from __future__, which requires 
use of the print() function. I suppose this should be considered a breaking 
of backward compatibility, so feel free to report an issue on Github.

Anthony

On Tuesday, August 29, 2017 at 4:33:53 PM UTC-4, Jim Karsten wrote:
>
> I run many scripts from the command line. After upgrading to v2.15.3, I 
> find print statements produce a SyntaxError. If I convert the statements to 
> a print function it works. This was not a problem in v2.14.6.
>
> To illustrate:
>
> $ cat test.py
> #!/usr/bin/env python
> if __name__ == '__main__':
> print 'Hello!'
>
> $ python web2py.sh --no-banner -S myapp -R test.py
> Traceback (most recent call last):
>   File "/srv/http/web2py/2.15.3/web2py/gluon/shell.py", line 270, in run
> execfile(startfile, _env)
>   File "/root/tmp/test.py", line 4
> print 'abc'
> SyntaxError: invalid syntax
>
> This works:
>
> $ cat test2.py
> #!/usr/bin/env python
> if __name__ == '__main__':
> print('Hello!')
>
> $ python web2py.py --no-banner -S myapp -R test2.py
> Hello!
>
> Is this is expected behaviour? Is there a command line option, or a small 
> change that permits cli scripts to continue to accept python2 syntax?
>
>  Thanks,
> Jim
>

-- 
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-29 Thread 黄祥
got it, my bad forget to add .as_list() on the rows

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: Print statement fails in command line script (v2.15.3)

2017-08-29 Thread Dave S


On Tuesday, August 29, 2017 at 1:33:53 PM UTC-7, Jim Karsten wrote:
>
> I run many scripts from the command line. After upgrading to v2.15.3, I 
> find print statements produce a SyntaxError. If I convert the statements to 
> a print function it works. This was not a problem in v2.14.6.
>
>
What python version are you running?  

I have a few controller functions that I run with -S, but I don't have them 
on my 2.15.3 instance at the moment.  But I do have URL-accessed 
controllers with print statements, and those seem fine ... 2.15.3, Python 
2.7.3 (on an antique Fedora).



 

> To illustrate:
>
> $ cat test.py
> #!/usr/bin/env python
> if __name__ == '__main__':
> print 'Hello!'
>
> $ python web2py.sh --no-banner -S myapp -R test.py
> Traceback (most recent call last):
>   File "/srv/http/web2py/2.15.3/web2py/gluon/shell.py", line 270, in run
> execfile(startfile, _env)
>   File "/root/tmp/test.py", line 4
> print 'abc'
> SyntaxError: invalid syntax
>
> This works:
>
> $ cat test2.py
> #!/usr/bin/env python
> if __name__ == '__main__':
> print('Hello!')
>
> $ python web2py.py --no-banner -S myapp -R test2.py
> Hello!
>
> Is this is expected behaviour? Is there a command line option, or a small 
> change that permits cli scripts to continue to accept python2 syntax?
>
>  Thanks,
> Jim
>


/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] db.company.insert() error

2017-08-29 Thread Ben Lawrence
2.15.3-stable+timestamp.2017.08.07.07.32.04
(Running on nginx/1.10.3, Python 2.7.12)


Hi
I hesitate to ask this because it will betray my stupidity

I have this:

*c_rows = db(db.company.domain_tag == c_domain).select()*
if *len(c_rows)==0*:  # add the company
c_id = db.company.insert(
name = get_company_name(c_domain),
e_mail = valid_email,
*domain_tag = c_domain )*
else:  # length MUST be one
c_id = c_rows.last().id

and this the error:

File "applications/remail/models/scheduler.py", line 120, in insert_company
domain_tag = c_domain )
  File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
734, in insert
ret = self._db._adapter.insert(self, row.op_values())
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 486, in insert
raise e
IntegrityError: duplicate key value violates unique constraint 
"company_domain_tag_key"
DETAIL:  Key (domain_tag)=(platronics.com) already exists.


Wha?! if domain_tag is already there would len(c_rows) > 0  and so would 
not try to insert the record?


-- 
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] Print statement fails in command line script (v2.15.3)

2017-08-29 Thread Jim Karsten
I run many scripts from the command line. After upgrading to v2.15.3, I 
find print statements produce a SyntaxError. If I convert the statements to 
a print function it works. This was not a problem in v2.14.6.

To illustrate:

$ cat test.py
#!/usr/bin/env python
if __name__ == '__main__':
print 'Hello!'

$ python web2py.sh --no-banner -S myapp -R test.py
Traceback (most recent call last):
  File "/srv/http/web2py/2.15.3/web2py/gluon/shell.py", line 270, in run
execfile(startfile, _env)
  File "/root/tmp/test.py", line 4
print 'abc'
SyntaxError: invalid syntax

This works:

$ cat test2.py
#!/usr/bin/env python
if __name__ == '__main__':
print('Hello!')

$ python web2py.py --no-banner -S myapp -R test2.py
Hello!

Is this is expected behaviour? Is there a command line option, or a small 
change that permits cli scripts to continue to accept python2 syntax?

 Thanks,
Jim

-- 
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-29 Thread Dave S


On Tuesday, August 29, 2017 at 1:19:29 AM UTC-7, Artem wrote:
>
> Hi ,
> Yes, tried
> it rise error : OperationalError: no such table: table1 
>

I think the problem is the db() out front.  You're asking for an operation 
(method) on a database object that doesn't have your tables.  You have a 
db, as well as  db1 and db2?

I'm not doing any better than Manuele is coming up with a way of doing 
this.  You need a list of ids from both tables, and those have to come from 
separate databases.  You could try changing the db() to either db1() or 
db2(), but I'm not confidant that it would work, and I imagine you'd only 
get the entries from the one table, just filtered by the other.  

Niphlod and Massimo and Giovanni are probably the experts you need.

/dps


>
> On Tuesday, August 29, 2017 at 5:58:20 AM UTC+8, 黄祥 wrote:
>>
>> 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: how to rewrite an URL to drop a function name showing in the address bar

2017-08-29 Thread 98ujko9
I use the stock Rocket server that comes with web2py and I restart it 
 after changing the routes.py. I must say that I don't fully understand the 
big picture of how the apps the compiler and the operating system 
cooperate. One time I uploaded a site to GAE with two separate apps but the 
tables in the models were named the same. web2py saw the models as separate 
and GAE as one and both apps were accessing the tables of the first app 
only.
In this project I kept my apps separate because I wanted to have a generic 
versions of each that I can quickly reuse elsewhere. Now I see this design 
might be flawed. 
I will follow your advice and place the code under one app. I feel too, 
that I might have a glitch in my setup. 
Big thank you for the help with routes.

Thanks for your time.

On Tuesday, August 29, 2017 at 8:52:49 AM UTC-4, Anthony wrote:
>
> Using the same routes, I cannot replicate the generated URLs you observe. 
> Make sure you reload routes (via admin) or restart the web server.
>
> Also, do you really need a separate init app and notes app? Especially the 
> init app -- what is it doing? If it just provides a single home page, that 
> doesn't belong in a separate app.
>
> Anthony
>
> On Monday, August 28, 2017 at 7:57:39 PM UTC-4, 98u...@gmail.com 
>  wrote:
>>
>> 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 

Re: [web2py] Re: how to create pdf report in web2py???

2017-08-29 Thread Alex
Thanks!

at the moment we don't have a user list, but that's something we have to 
think about. You can also contact us per mail.

One way to save the report is using the localStorageReportKey setting (see 
https://www.reportbro.com/docs/options ), e.g.
$("#reportbro").reportBro({
localStorageReportKey: 'myReportKey'
});

this way the report is saved on the client in local storage with given key 
when you click the save button. When the plugin is initialized the report 
is automatically loaded from local storage. This is fine for testing but in 
a real-world application you usually want to save the report in your 
application (database).

For this you can use the saveCallback option, e.g.
function saveReport() {
var report = $('#reportbro').reportBro('getReport');

$.ajax('', {
data: JSON.stringify(report),
type: "PUT", contentType: "application/json",
success: function(data) {
...
},
error: function(jqXHR, textStatus, errorThrown) {
...
}
});
}

$(document).ready(function() {
$('#reportbro').reportBro({
saveCallback: saveReport
});
});

how you are saving the report server-side is up to you.

Alex

On Tuesday, August 29, 2017 at 3:15:52 PM UTC+2, Javier Pepe wrote:
>
> Alex
>
> The tool is very good, you have a user list for question, i am to try the 
> designer and not found howto save this.
>
> Thanks
>
> 2017-08-26 10:19 GMT-03: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+un...@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: weird issue with date field

2017-08-29 Thread Anthony
If you have upgraded an existing app, make sure you update the web2py 
JavaScript files as well.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the 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: AttributeError: 'SQLite' object has no attribute 'file_open'

2017-08-29 Thread Lisandro
John, could you try with the web2py version for testers?
The commit fixed the problem, but I think it will be included in the next 
stable version.

At least that's what I did: I downloaded the "for testers" source code 
version, and it worked ok:
This is the link to the download:
https://mdipierro.pythonanywhere.com/examples/static/nightly/web2py_src.zip

You can find it also in the official webpage:
http://web2py.com/init/default/download

Hope it helps.
Regards,
Lisandro.

El martes, 29 de agosto de 2017, 5:47:39 (UTC-3), Jitun John escribió:
>
> Hi Massimo,
>
> I have the 2.15.3 version installed, but the issue remains.
> I confirm the same code works on 2.14.6
>
>
>
> 
>
>
>
>
>
>
>
>
> On Sunday, August 13, 2017 at 2:40:08 AM UTC+5:30, Massimo Di Pierro wrote:
>>
>> Committed c995fd7 that should fix 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.


Re: [web2py] Re: how to create pdf report in web2py???

2017-08-29 Thread Javier Pepe
Alex

The tool is very good, you have a user list for question, i am to try the
designer and not found howto save this.

Thanks

2017-08-26 10:19 GMT-03: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.


Re: [web2py] Re: weird issue with date field

2017-08-29 Thread Yoel Benitez Fonseca
umm.. should test it again ... thnk

2017-08-28 22:37 GMT-04:00 Peter :

> For what it's worth...
>
> I downloaded the latest,
>
> 2.15.3-stable+timestamp.2017.08.07.12.51.45
> (Running on Rocket 1.2.6, Python 2.7.12)
>
>
> pasted your code into db.py
>
> used crud.create in the controller (I know I should move on)
>
> created a view  (default)
> {{extend 'layout.html'}}
> This is the default/test_date.html template
> {{=BEAUTIFY(response._vars)}}
>
>
> and it worked ok...
>
>
>
>
> 
>
>
>
> 
>
>
>
> 
>
>
>
> 
>
>
> 
>
>
>
>
> checked the sqlite db  and entries appear normal...
>
> "1""my name""12345678901""2017-08-29""25.0""35.0"
> "2""my name""12345678902""2017-08-30""25.0""35.0"
>
>
>
>
> --
> 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: how to rewrite an URL to drop a function name showing in the address bar

2017-08-29 Thread Anthony
Using the same routes, I cannot replicate the generated URLs you observe. 
Make sure you reload routes (via admin) or restart the web server.

Also, do you really need a separate init app and notes app? Especially the 
init app -- what is it doing? If it just provides a single home page, that 
doesn't belong in a separate app.

Anthony

On Monday, August 28, 2017 at 7:57:39 PM UTC-4, 98uj...@gmail.com wrote:
>
> 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-29 Thread Val K
as_list() is missed, try:
people = json.dumps(rows.as_list())



On Tuesday, August 29, 2017 at 4:45:47 AM UTC+3, 黄祥 wrote:
>
> 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;>
>  cellspacing="0" width="100%">
> 
> 
> 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] Re: AttributeError: 'SQLite' object has no attribute 'file_open'

2017-08-29 Thread Jitun John
Hi Massimo,

I have the 2.15.3 version installed, but the issue remains.
I confirm the same code works on 2.14.6











On Sunday, August 13, 2017 at 2:40:08 AM UTC+5:30, Massimo Di Pierro wrote:
>
> Committed c995fd7 that should fix 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.


Re: [web2py] Two database join query

2017-08-29 Thread Manuele

I think there's no way in a single query...

try making two different query and join results creating a brand new 
rows object


I hope it could help

Manuele


Il 28/08/2017 18:04, Artem ha scritto:

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 ="SELECTdb1.id, db1.title,db2.data FROMdb1.table1 INNER JOIN 
db2.table2ONdb2.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: Two database join query

2017-08-29 Thread Artem
Hi ,
yes i'm tried .
it rise error : OperationalError: no such table: table1 

On Tuesday, August 29, 2017 at 5:58:20 AM UTC+8, 黄祥 wrote:
>
> 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.