Re: [web2py] fabric app

2015-09-04 Thread Massimo Di Pierro
I can confirm Niphlod was the first to deliver. Anyway, I will take a look 
at yours in the next few days.
Meanwhile could you explain what yours does exactly? There is lots of code 
in there.

Massimo

On Friday, 4 September 2015 08:06:34 UTC-5, Carlos Cesar Caballero wrote:
>
> Well not so much, I just join some snippets in my free time... I known 
> fabric and is great, but I was looking for something more 
> server-independent, it's slower than the Massimo request, but can work 
> independently of the server configuration or OS.
>
>
> El 03/09/15 a las 14:50, Richard Vézina escribió:
>
> Nice Carlos, you should had work really hard... Do you know Fabric (
> http://www.fabfile.org/)?  
>
> I guess you had save some boiler plate...
>
> :)
>
> Richard
>
> On Thu, Sep 3, 2015 at 2:21 PM, Carlos Cesar Caballero Díaz <
> desarro...@spicm.cfg.sld.cu> wrote:
>
>> Hi massimo I took it as an exercise, and this is what I make:
>>
>> https://github.com/cccaballero/app_deploy
>>
>> can be used like:
>>
>> python main.py https://github.com/myuser/repo.git 
>> username:password@domain:/home/www-data/web2py/applications/estore3
>>
>> the script make all the stuff locally, so nothing spacial need to be 
>> installed in the server, only a sftp capable ssh server.
>>
>> El 02/09/15 a las 00:02, Massimo Di Pierro escribió:
>>
>> I would like an app that does this: 
>>
>> deploy https://github.com/mdipierro/estore3 
>> username@domain:/home/www-data/web2py/applications/estore3
>>
>> possibly based on fabric. Definitively written in Python.
>>
>> the app "deply" should assume web2py is installed
>> 1) clone locally https://github.com/mdipierro/estore3
>> 2) zip it
>> 3) copy it to 
>> username@domain:/home/www-data/web2py/applications/estore3.zip
>> 4) unzip it into 
>> username@domain:/home/www-data/web2py/applications/estore3-tmp/
>> 5) if username@domain:/home/www-data/web2py/applications/estore3 does not 
>> exist skip to 11)
>> 6) zip 
>> username@domain:/home/www-data/web2py/applications/estore3-.zip 
>> username@domain:/home/www-data/web2py/applications/estore3/*
>> 7) create a file 
>> username@domain:/home/www-data/web2py/applications/estore3/DISABLED 
>> containing the current datetime
>> 8) stop the web server (apache and or nginx)
>> 9) copy all files and folders from estore3/ to estore3-tmp/  except 
>> models, views, controllers, modules, sessions
>> 10) remove estore3/
>> 11) rename estore-tmp3/ as estore/
>> 12) restarts the web server
>>
>> There should also be an option:
>>
>> deploy -revert  
>> username@domain:/home/www-data/web2py/applications/estore3
>> that restores the content of 
>> username@domain:/home/www-data/web2py/applications/estore3-.zip
>>
>> should work with any git web2py app (not just estore3 which was an 
>> example) and MUST WORK with private github repo.
>>
>> It is OK to assume that the current user has ssh keys to access both the 
>> git repo and the remote server.
>>
>> I will pay $100 if you can send it to me in the next 2 days. Feel free to 
>> discuss here if you understand it and think we can do this better.
>>
>> Massimo
>>
>>
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
> 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

[web2py] Re: An error occured, please reload the page

2015-09-04 Thread Annet
Hi Anthony,

Anyway, this message should probably be optional or configurable -- maybe 
>> submit a github issue requesting that.
>>
>
 The message "An error occured, please reload the page" is a bit confusing, 
clicking reload the page doesn't
resolve the error.

When I go to http://127.0.0.1:8000/admin/default/errors/app there's an 
error log related to the message. When I resolve
the error the message no longer appears.

Does this imply that web2py constantly scans my application for errors, and 
detects them before I run any code.

Do I turn this off in production?


Kind regards,

Annet

-- 
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: Web2py-Heroku: Relation "my_table" already exists

2015-09-04 Thread Massimo Di Pierro
You have to use get_db.

Heroku has a non-reliable file system. It can be be reset at any time. By 
default web2py stores metadata about tables on the filesystem so if it is 
reset the information is lost and web2py thinks your table do not exist. 
get_db configures DAL for you to store all metadata in the database itself.

Massimo

On Thursday, 3 September 2015 15:55:05 UTC-5, James McGlynn wrote:
>
> I am not using get_db.
> I am just using DAL and retrieving the database connection string from an 
> environment variable. 
>
> db = DAL(os.environ['DATABASE_URL'], pool_size=10)
>
> Even though I am just doing this, my app works fine on Heroku until I add 
> a new table definition to my model file and git push before first running 
> the app locally using the Heroku db. 
>
> It sounds like I should be using get_db instead of what I am doing. I will 
> try to get that working and see if it has any effect on my scenario. If it 
> does stop the error from occurring in that situation, it would still be of 
> interest to me to know why the error is happening given the way I'm doing 
> it now, but I don't want to take any more of your time so I'll just mark 
> this as complete for now and ask a new question if I still can't figure it 
> out by the time I get get_db working.
>
> Thanks for your help. 
>
>
> On Wednesday, September 2, 2015 at 12:51:10 PM UTC-4, Anthony wrote:
>>
>> Hmm, looks like that should work automatically if you're using the Heroku 
>> contrib module to connect to your db. Are you doing:
>>
>> from gluon.contrib.heroku import get_db
>> db = get_db(name=None, pool_size=10)
>>
>> Anthony
>>
>>
>> On Tuesday, September 1, 2015 at 11:48:27 PM UTC-4, James McGlynn wrote:
>>>
>>> Thanks for the response!
>>>
>>> I was able to find documentation on how web2py stores metadata in 
>>> *.table files. So I understand what you are saying about them, and I agree 
>>> that turning off migrations when running remotely would get rid of the 
>>> error. 
>>>
>>> But my question was about how/when web2py decides it needs to create the 
>>> "web2py_filesystem" table for storing metadata without a filesystem and 
>>> how/when it decides to look for metadata in that table, rather than the 
>>> file system. 
>>>
>>> I found this answer 
>>>  from 
>>> Massimo on another thread:
>>>
>>> web2py stores metadata about DB tables which have been created. This is 
 necessary for migrations. Normally this metadata is store in *.table 
 files. 
 Heroku has a strange filesystem that gets wiped up at random times. For 
 this reason the *.table files are not in the "normal filesystem". Web2py 
 creates a filesystem in database in a table called "web2py_filesystem" and 
 stores the *.table files in there.
>>>
>>>
>>> So I just would like to understand how this happens. Is there a place in 
>>> the source I could start reading that handles this?
>>>
>>> Thank you.
>>>
>>>
>>> On Monday, August 31, 2015 at 9:48:59 PM UTC-4, Anthony wrote:

 The *.table files include metadata about the tables for use with the 
 migrations functionality. If the *.table file is missing and migrations 
 are 
 turned on, web2py will assume the associated table needs to be created 
 (resulting in an error if it already exists). Probably you simply want to 
 turn off migrations in the production environment.

 Anthony

 On Monday, August 31, 2015 at 9:00:38 PM UTC-4, James McGlynn wrote:
>
>
> class 'psycopg2.ProgrammingError' relation "my_table" already exists
>
> I have configured my app so that I can set a flag to use either a 
> local sqlite db, or a remote Heroku db when running locally, but when 
> running remotely on Heroku, the Heroku db is always used. The databases 
> do 
> not contain the same data, nor do I need/want them to. 
>
> I have come across this error a few times now for different 
> reasons. I'm pretty comfortable with resolving it at this point, but one 
> way I consistently get the error is by creating a new table while 
> developing locally with sqlite and then pushing my changes to Heroku, 
> without first running locally with the postgresql db.
>
> Can someone explain why my app seems to need a .table file for the new 
> table to be pushed to heroku, even though it gets eventually removed by 
> Heroku anyway? Does the logic for the storing metadata in the db use the 
> .table files in the filesystem to create the metadata stored in the db 
> the 
> first time it senses that its running on Heroku or something?
>
> How would this work on a platform like elasticbeanstalk, which doesn't 
> offer the luxury of having the files on the file system temporarily 
> available after a push. 
>


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/

[web2py] Re: IS_IN_DB table in other database

2015-09-04 Thread Annet
Hi Anthony,

Thanks for your reply.

Did you try it and have a problem?


Yes, I did. From your reply I concluded that I must have done something 
wrong.
It took some time to figure out what the problem was, but it's all working 
fine now.


Kind regards,

Annet 

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


[web2py] appconfig.ini

2015-09-04 Thread Annet
In appconfig.ini I have the following settings:

; db configuration
[db]
uri   = postgres://:r@localhost:5432/database_name
migrate   = False
migrate_enabled = False
pool_size = 1
lazy_tables = True
ignore_field_case = True

and in db.py:

myconf = AppConfig(reload=True)

db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', 
cast=int), lazy_tables=myconf.take('db.lazy_tables'), 
migrate_enabled=myconf.take('db.migrate_enabled'), 
ignore_field_case=myconf.take('db.ignore_field_case'), 
check_reserved=['all'])

When I define a table:

db.define_table('vtx_label',
Field(),
Field(),
...
on_define = set_requirement,
migrate = 'vtx_label.table)

and click the 'Save file' icon the table is being defined in the postgres 
database, so migrate = False and
migrate_enabled = False are ignored?

Or is this my mistake?

Kind regards,

Annet

-- 
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: Web2py Restfull API Token authentication

2015-09-04 Thread Dave S
On Wednesday, September 2, 2015 at 1:15:48 AM UTC-7, Niphlod wrote:
>
> I'm back from holidays, JWT support is on the way to master repo. Stay 
> tuned, also because I have some experience with js frameworks but not with 
> Angular. We may tune the code for JWT to make Angular integration easy. If 
> a slice comes out detailing the integration process wouldn't hurt :-P 
>

Ah, another expansion of the reading list.   I'm skimming RFC 7515 right 
now.

/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] SQL query equivalent in DAL

2015-09-04 Thread Dave S


On Friday, September 4, 2015 at 1:37:07 PM UTC-7, Anthony wrote:
>
>
> (see, no "Field('name', 'reference othertable', ...)")
>>
>  
> Field('computer', db.pc) 
>
> This is a reference to the "pc" table.
>
>  
Ooops! 

/dps "Location, location, location"


-- 
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: Display value from reference fields and not ids in SQLFORM.grid

2015-09-04 Thread LoveWeb2py
And of course I find it within a minute of posting... lol

Here is my solution:


in model:
db.define_table('table2',
 Field('field1','reference table1'),
 Field('field2','reference table1', requires=IS_IN_DB(db, 
db.table1.id, '%(field2)s')),
 migrate=False)

in controller:
db.table2.field2.represent = lambda s,r: s.field2
grid=SQLFORM.smartgrid(table2)
return dict(grid=grid)

Hope this helps someone in the future. Time for beer!




On Friday, September 4, 2015 at 4:49:31 PM UTC-4, LoveWeb2py wrote:
>
> I've been struggling with this for hours! 
>
> db.define_table('table1',
>   Field('field1', 'string'),
>   Field('field2','date'),
>   format='%(field1)s %(field2)s', migrate=False)
>
> db.define_table('table2',
>  Field('field1','reference table1'),
>  Field('field2','reference table1'),
>  migrate=False)
>
> I'm trying to show table2 in a SQLFORM, but it only shows the field 1 
> values, for both fields. I want to show field 2 values  in table 1 for 
> table 2. In SQLFORM.grid it only returns the id instead of the grid.
>
> I'm so frustrated! 
>
> I've tried:
> https://groups.google.com/forum/#!topic/web2py/bO1N4r2j0Dg
>
> http://stackoverflow.com/questions/1012179/how-to-generate-a-many-to-many-relationship-form-in-web2py
> http://markmail.org/message/usmvxp5zctssog7d
>
 

>
> Any advice is greatly appreciated. I'm sure it's something simple, but I 
> just can't seem to find it.
>

-- 
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] Display value from reference fields and not ids in SQLFORM.grid

2015-09-04 Thread LoveWeb2py
I've been struggling with this for hours! 

db.define_table('table1',
  Field('field1', 'string'),
  Field('field2','date'),
  format='%(field1)s %(field2)s', migrate=False)

db.define_table('table2',
 Field('field1','reference table1'),
 Field('field2','reference table1'),
 migrate=False)

I'm trying to show table2 in a SQLFORM, but it only shows the field 1 
values, for both fields. I want to show field 2 values  in table 1 for 
table 2. In SQLFORM.grid it only returns the id instead of the grid.

I'm so frustrated! 

I've tried:
https://groups.google.com/forum/#!topic/web2py/bO1N4r2j0Dg
http://stackoverflow.com/questions/1012179/how-to-generate-a-many-to-many-relationship-form-in-web2py
http://markmail.org/message/usmvxp5zctssog7d

Any advice is greatly appreciated. I'm sure it's something simple, but I 
just can't seem to find it.

-- 
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] SQL query equivalent in DAL

2015-09-04 Thread P T
Got it. I need to remove the initial db to make that into a query

(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id))




On Friday, September 4, 2015 at 3:37:50 PM UTC-5, P T wrote:
>
> Thank you Richard, your expression returns ROWS and can't be used in 
> SQLFORM.grid. When I removed the last select 
>
> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id))
>
> then I get 
>
> File "E:\web2py 2.9.12\gluon\sqlhtml.py", line 2139, in grid
>  field_id = tables[0]._id
> IndexError: list index out of range
>
>
> Dave, the tables are related. e.g. the table "assigned" has a field 
> "computer" of type db.pc
>
>
>
> Thanks,
> PT
>
>
> On Friday, September 4, 2015 at 3:23:47 PM UTC-5, Dave S wrote:
>>
>> I'm puzzled about the why ...
>>
>> On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote:
>>>
>>> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id
>>> )).select(db.pc.ALL)
>>>
>>> Richard
>>>
>>>
>>>
>>> On Fri, Sep 4, 2015 at 3:35 PM, P T  wrote:
>>>

 Hello Forum,

 Please help me in getting the equivalent DAL query for the following 
 SQL query. I intend to pass this on to SQLFORM.grid

 Select * from db.pc where db.pc.id not in (select unique 
 db.assigned.computer from db.assigned)


>> when there's no reference between tables:
>>
>>
>>  
>>
>>> Web2Py Version
 2.9.12-stable+timestamp.2015.02.15.23.04.25
 (Running on Rocket 1.2.6, Python 2.7.9) 

 db.define_table('staff',
 Field('name', 'string', unique=True),
format='%(name)s')

 db.define_table('pc',
 Field('csi', 'string', unique=True),
format='%(csi)s')

 db.define_table('assigned',
 Field('staff', db.staff),
 Field('computer', db.pc))

 Thanks,
 PT


>>>
>> (see, no "Field('name', 'reference othertable', ...)")
>>
>> /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] SQL query equivalent in DAL

2015-09-04 Thread P T
Thank you Richard, your expression returns ROWS and can't be used in 
SQLFORM.grid. When I removed the last select 

db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id))

then I get 

File "E:\web2py 2.9.12\gluon\sqlhtml.py", line 2139, in grid
 field_id = tables[0]._id
IndexError: list index out of range


Dave, the tables are related. e.g. the table "assigned" has a field "computer" 
of type db.pc



Thanks,
PT


On Friday, September 4, 2015 at 3:23:47 PM UTC-5, Dave S wrote:
>
> I'm puzzled about the why ...
>
> On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote:
>>
>> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id
>> )).select(db.pc.ALL)
>>
>> Richard
>>
>>
>>
>> On Fri, Sep 4, 2015 at 3:35 PM, P T  wrote:
>>
>>>
>>> Hello Forum,
>>>
>>> Please help me in getting the equivalent DAL query for the following SQL 
>>> query. I intend to pass this on to SQLFORM.grid
>>>
>>> Select * from db.pc where db.pc.id not in (select unique 
>>> db.assigned.computer from db.assigned)
>>>
>>>
> when there's no reference between tables:
>
>
>  
>
>> Web2Py Version
>>> 2.9.12-stable+timestamp.2015.02.15.23.04.25
>>> (Running on Rocket 1.2.6, Python 2.7.9) 
>>>
>>> db.define_table('staff',
>>> Field('name', 'string', unique=True),
>>>format='%(name)s')
>>>
>>> db.define_table('pc',
>>> Field('csi', 'string', unique=True),
>>>format='%(csi)s')
>>>
>>> db.define_table('assigned',
>>> Field('staff', db.staff),
>>> Field('computer', db.pc))
>>>
>>> Thanks,
>>> PT
>>>
>>>
>>
> (see, no "Field('name', 'reference othertable', ...)")
>
> /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] SQL query equivalent in DAL

2015-09-04 Thread Anthony


> (see, no "Field('name', 'reference othertable', ...)")
>
 
Field('computer', db.pc) 

This is a reference to the "pc" table.

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] SQL query equivalent in DAL

2015-09-04 Thread Dave S
I'm puzzled about the why ...

On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote:
>
> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id
> )).select(db.pc.ALL)
>
> Richard
>
>
>
> On Fri, Sep 4, 2015 at 3:35 PM, P T > 
> wrote:
>
>>
>> Hello Forum,
>>
>> Please help me in getting the equivalent DAL query for the following SQL 
>> query. I intend to pass this on to SQLFORM.grid
>>
>> Select * from db.pc where db.pc.id not in (select unique 
>> db.assigned.computer from db.assigned)
>>
>>
when there's no reference between tables:


 

> Web2Py Version
>> 2.9.12-stable+timestamp.2015.02.15.23.04.25
>> (Running on Rocket 1.2.6, Python 2.7.9) 
>>
>> db.define_table('staff',
>> Field('name', 'string', unique=True),
>>format='%(name)s')
>>
>> db.define_table('pc',
>> Field('csi', 'string', unique=True),
>>format='%(csi)s')
>>
>> db.define_table('assigned',
>> Field('staff', db.staff),
>> Field('computer', db.pc))
>>
>> Thanks,
>> PT
>>
>>
>
(see, no "Field('reference', ...)")

/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] SQL query equivalent in DAL

2015-09-04 Thread Richard Vézina
db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id
)).select(db.pc.ALL)

Richard



On Fri, Sep 4, 2015 at 3:35 PM, P T  wrote:

>
> Hello Forum,
>
> Please help me in getting the equivalent DAL query for the following SQL
> query. I intend to pass this on to SQLFORM.grid
>
> Select * from db.pc where db.pc.id not in (select unique
> db.assigned.computer from db.assigned)
>
> Web2Py Version
> 2.9.12-stable+timestamp.2015.02.15.23.04.25
> (Running on Rocket 1.2.6, Python 2.7.9)
>
> db.define_table('staff',
> Field('name', 'string', unique=True),
>format='%(name)s')
>
> db.define_table('pc',
> Field('csi', 'string', unique=True),
>format='%(csi)s')
>
> db.define_table('assigned',
> Field('staff', db.staff),
> Field('computer', db.pc))
>
> Thanks,
> PT
>
> --
> 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] SQL query equivalent in DAL

2015-09-04 Thread P T

Hello Forum,

Please help me in getting the equivalent DAL query for the following SQL 
query. I intend to pass this on to SQLFORM.grid

Select * from db.pc where db.pc.id not in (select unique 
db.assigned.computer from db.assigned)

Web2Py Version
2.9.12-stable+timestamp.2015.02.15.23.04.25
(Running on Rocket 1.2.6, Python 2.7.9) 

db.define_table('staff',
Field('name', 'string', unique=True),
   format='%(name)s')

db.define_table('pc',
Field('csi', 'string', unique=True),
   format='%(csi)s')

db.define_table('assigned',
Field('staff', db.staff),
Field('computer', db.pc))

Thanks,
PT

-- 
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] Action when file streaming finishes

2015-09-04 Thread Niphlod
the problem with any approach is that the http hasn't really an event that 
signals that the file has been downloaded (and completed) successfully. 
The usual workaround is to put the location of the file on some list and 
remove it later by cycling the aforementioned list (say, every day or so).

On Friday, September 4, 2015 at 2:56:53 PM UTC+2, desta wrote:
>
> Thank you for the reply. I learned something new today! 
> os.tmpfile() seems very useful but I don't think I can apply it in my 
> situation.
>
> The controller creates the file through an API call to a different server 
> running on the system. As a response, the controller gets the file 
> location. So it knows where the file is located and streams it to the 
> client. From my understanding os.tmpfile() would work if I created the file 
> within the controller.
>
> Thank you.
>
>
>
> On Friday, September 4, 2015 at 3:50:00 PM UTC+3, Yoel Benitez Fonseca 
> wrote:
>>
>> if it a temporary file create by os.tmpfile() you don't need to care 
>> about deleting it, the system will take care of everything for you. 
>>
>> -- 
>> Yoel 
>>
>> 2015-09-04 8:32 GMT-04:00, desta : 
>> > Hello, 
>> > 
>> > When the client clicks on a specific link, a temporary file is created 
>> by a 
>> > 
>> > controller which is then downloaded (using the `response.stream`). I 
>> want 
>> > to delete the file after the download finishes. 
>> > 
>> > Could you please share any suggestions? 
>> > 
>> > Thank you. 
>> > 
>> > -- 
>> > Resources: 
>> > - http://web2py.com 
>> > - http://web2py.com/book (Documentation) 
>> > - http://github.com/web2py/web2py (Source code) 
>> > - https://code.google.com/p/web2py/issues/list (Report Issues) 
>> > --- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "web2py-users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an 
>> > email to web2py+un...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/d/optout. 
>> > 
>>
>>
>> -- 
>> Msc. Yoel Benítez Fonseca 
>> Especialista en TI 
>> http://redevil.cubava.cu/ 
>> Tel.: (53 32)284701 
>>
>

-- 
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] 'module' object has no attribute 'startswith'

2015-09-04 Thread Richard Vézina
Could it be possible that you upgrade web2py but not the appadmin
controller?

Richard

On Thu, Sep 3, 2015 at 3:01 AM, Johann Spies  wrote:

> We have an app working with a database on another server through an
> ssh-tunnel.
>
> The app is working.  But the admin app which worked previously suddenly
> throws an error when one try to we tries the "database administration"
> button - but only for this app.
>
> The traceback is this:
>
> Traceback (most recent call last):
>   File "/home/js/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File "/home/js/web2py/applications/wos_2015_3/views/appadmin.html" 
> , 
> line 93, in 
> {{tablename=request.args[1]}}
>   File "/home/js/web2py/gluon/packages/dal/pydal/base.py", line 899, in 
> __getitem__
> return self.__getattr__(str(key))
>   File "/home/js/web2py/gluon/packages/dal/pydal/base.py", line 905, in 
> __getattr__
> return self.lazy_define_table(tablename, *fields, **args)
>   File "/home/js/web2py/gluon/packages/dal/pydal/base.py", line 845, in 
> lazy_define_table
> field.represent = auto_represent(field)
>   File "/home/js/web2py/gluon/packages/dal/pydal/helpers/methods.py", line 
> 286, in auto_represent
> if field.db and field.type.startswith('reference') and \
> AttributeError: 'module' object has no attribute 'startswith'
>
>
> How do I debug this?
>
> migrate = False for all the tables with fake_migrate on for the
> auth_related tables.
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
> --
> 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] fabric app

2015-09-04 Thread Carlos Cesar Caballero Díaz
Well not so much, I just join some snippets in my free time... I known 
fabric and is great, but I was looking for something more 
server-independent, it's slower than the Massimo request, but can work 
independently of the server configuration or OS.



El 03/09/15 a las 14:50, Richard Vézina escribió:
Nice Carlos, you should had work really hard... Do you know Fabric 
(http://www.fabfile.org/)?


I guess you had save some boiler plate...

:)

Richard

On Thu, Sep 3, 2015 at 2:21 PM, Carlos Cesar Caballero Díaz 
mailto:desarro...@spicm.cfg.sld.cu>> wrote:


Hi massimo I took it as an exercise, and this is what I make:

https://github.com/cccaballero/app_deploy

can be used like:

python main.py https://github.com/myuser/repo.git
username:password@domain:/home/www-data/web2py/applications/estore3

the script make all the stuff locally, so nothing spacial need to
be installed in the server, only a sftp capable ssh server.

El 02/09/15 a las 00:02, Massimo Di Pierro escribió:

I would like an app that does this:

deploy https://github.com/mdipierro/estore3
username@domain:/home/www-data/web2py/applications/estore3

possibly based on fabric. Definitively written in Python.

the app "deply" should assume web2py is installed
1) clone locally https://github.com/mdipierro/estore3
2) zip it
3) copy it to
username@domain:/home/www-data/web2py/applications/estore3.zip

4) unzip it into
username@domain:/home/www-data/web2py/applications/estore3-tmp/
5) if username@domain:/home/www-data/web2py/applications/estore3
does not exist skip to 11)
6) zip
username@domain:/home/www-data/web2py/applications/estore3-.zip
username@domain:/home/www-data/web2py/applications/estore3/*
7) create a file
username@domain:/home/www-data/web2py/applications/estore3/DISABLED
containing the current datetime
8) stop the web server (apache and or nginx)
9) copy all files and folders from estore3/ to estore3-tmp/
 except models, views, controllers, modules, sessions
10) remove estore3/
11) rename estore-tmp3/ as estore/
12) restarts the web server

There should also be an option:

deploy -revert 
username@domain:/home/www-data/web2py/applications/estore3
that restores the content of
username@domain:/home/www-data/web2py/applications/estore3-.zip

should work with any git web2py app (not just estore3 which was
an example) and MUST WORK with private github repo.

It is OK to assume that the current user has ssh keys to access
both the git repo and the remote server.

I will pay $100 if you can send it to me in the next 2 days. Feel
free to discuss here if you understand it and think we can do
this better.

Massimo



-- 
Resources:

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


-- 
Resources:

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


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




--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- htt

Re: [web2py] Action when file streaming finishes

2015-09-04 Thread desta
Thank you for the reply. I learned something new today! 
os.tmpfile() seems very useful but I don't think I can apply it in my 
situation.

The controller creates the file through an API call to a different server 
running on the system. As a response, the controller gets the file 
location. So it knows where the file is located and streams it to the 
client. From my understanding os.tmpfile() would work if I created the file 
within the controller.

Thank you.



On Friday, September 4, 2015 at 3:50:00 PM UTC+3, Yoel Benitez Fonseca 
wrote:
>
> if it a temporary file create by os.tmpfile() you don't need to care 
> about deleting it, the system will take care of everything for you. 
>
> -- 
> Yoel 
>
> 2015-09-04 8:32 GMT-04:00, desta >: 
> > Hello, 
> > 
> > When the client clicks on a specific link, a temporary file is created 
> by a 
> > 
> > controller which is then downloaded (using the `response.stream`). I 
> want 
> > to delete the file after the download finishes. 
> > 
> > Could you please share any suggestions? 
> > 
> > Thank you. 
> > 
> > -- 
> > Resources: 
> > - http://web2py.com 
> > - http://web2py.com/book (Documentation) 
> > - http://github.com/web2py/web2py (Source code) 
> > - https://code.google.com/p/web2py/issues/list (Report Issues) 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
>
>
> -- 
> Msc. Yoel Benítez Fonseca 
> Especialista en TI 
> http://redevil.cubava.cu/ 
> Tel.: (53 32)284701 
>

-- 
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] Action when file streaming finishes

2015-09-04 Thread Yoel Benitez Fonseca
if it a temporary file create by os.tmpfile() you don't need to care
about deleting it, the system will take care of everything for you.

--
Yoel

2015-09-04 8:32 GMT-04:00, desta :
> Hello,
>
> When the client clicks on a specific link, a temporary file is created by a
>
> controller which is then downloaded (using the `response.stream`). I want
> to delete the file after the download finishes.
>
> Could you please share any suggestions?
>
> Thank you.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Msc. Yoel Benítez Fonseca
Especialista en TI
http://redevil.cubava.cu/
Tel.: (53 32)284701

-- 
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] Action when file streaming finishes

2015-09-04 Thread desta
Hello,

When the client clicks on a specific link, a temporary file is created by a 
controller which is then downloaded (using the `response.stream`). I want 
to delete the file after the download finishes.

Could you please share any suggestions?

Thank you.

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