[web2py] Re: controller return list instead of string or dict

2013-07-30 Thread Niphlod
can you explain better what's going on ? the generic json view (as any 
other view) is made to serialize a python object to something (in json's 
case, a json string). 
If you already return a string because your code encodes it already, than 
you don't need any view, because the job the view usually does has been 
done already by your code.

On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>
> Hi,
> We're running into an issue with our restful api where a certain method is 
> returning a json string (eg: " ['one', 'two', 'three'] "), however web2py 
> wants to render this as a string even when the request.extension is forced 
> to json, and the response.view is forced to generic.json. I've tracked the 
> issue down to gluon/main.py:231 where it checks if "page" is a dict, and 
> what seems to be happening is that the valid json string above is instead 
> being concatenated as a string representation. Adding this below the check 
> for dict seems to fix it, but I'm not sure how well it fixes the problem:
>
> elif isinstance(page, list):
> response._vars = page
> run_view_in(response._view_environment)
> page = response.body.getvalue()
>
> Any suggestions for other ways to go about fixing this? 
>
> Thanks,
> Matt
>
>
>

-- 

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




Re: [web2py] Re: A good py Logger Lib that works with web2Py (like Log4J)

2013-07-30 Thread Jake Angulo
Thanks All!

Will try to both pdb and errormator and see what works for me.


On Tue, Jul 30, 2013 at 3:50 AM, Derek  wrote:

> Take a look at errormator. I use it in some of my non-web2py apps simple
> enough.
>
>
> On Sunday, July 28, 2013 5:51:28 PM UTC-7, Jake Angulo wrote:
>>
>>
>> Hi Guys,
>>
>> I develop using vi & notepad++ and find it very difficult to debug with
>> these limited tools.  I debug by runtime output / stdout & doing a lot of
>> print.
>>
>> Is there a good Py logging library (like log4j in java) that also works
>> with web2py?
>>
>> Appreciate any recommendeations.
>>
>>
>> Rgds,
>>
>>  --
>
> ---
> 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/groups/opt_out.
>
>
>

-- 

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




[web2py] Re: how to create a readonly connection to remote db

2013-07-30 Thread Monika Yadav


On Monday, July 29, 2013 7:33:21 PM UTC+5:30, Niphlod wrote:
>
> there's no default "read-only" in client-side libraries that connects to a 
> database. What do you need specifically ?
>
> On Monday, July 29, 2013 1:49:11 PM UTC+2, Monika Yadav wrote:
>>
>> how to create a readonly connection to remote db without using 
>> executesql...i want to use the dal properties
>>
>


we are creating a automated testing framework to test a user interface of a 
website.for that purpose we are given read only rights to that mysql 
database from which we want to fetch data and put a check.

 i have created a DAL object for that say db1.
 but when i run db1.(db1.table_name.attribute=something).select

it says that the DAL object has no attribute table_name
but with the help of this DAL object i am able to run the raw sql query 
using executesql method

-- 

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




[web2py] Re: how to create a readonly connection to remote db

2013-07-30 Thread Niphlod
even if you just read a table and you want to read that table with a DAL 
select, you need to code the model in your application. just set 
migrate=False on the table definitions if tables are already there, and DAL 
will be happy to work with them

On Tuesday, July 30, 2013 7:42:54 AM UTC+2, Monika Yadav wrote:
>
>
>
> On Monday, July 29, 2013 7:33:21 PM UTC+5:30, Niphlod wrote:
>>
>> there's no default "read-only" in client-side libraries that connects to 
>> a database. What do you need specifically ?
>>
>> On Monday, July 29, 2013 1:49:11 PM UTC+2, Monika Yadav wrote:
>>>
>>> how to create a readonly connection to remote db without using 
>>> executesql...i want to use the dal properties
>>>
>>
>
>
> we are creating a automated testing framework to test a user interface of 
> a website.for that purpose we are given read only rights to that mysql 
> database from which we want to fetch data and put a check.
>
>  i have created a DAL object for that say db1.
>  but when i run db1.(db1.table_name.attribute=something).select
>
> it says that the DAL object has no attribute table_name
> but with the help of this DAL object i am able to run the raw sql query 
> using executesql method
>

-- 

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




[web2py] Re: How write subquery of LEFT JOIN using DAL?

2013-07-30 Thread Massimo Di Pierro
You cannot do this with DAL in one query but there may be other ways. What 
is you model? Do this table have an id field?

If I understand in english:
- you have a table called value with fields "indicator", "client_date", 
"value", "checked"
- you first select all distinct values of indicator and for each of them 
you find the one with the min(client_date)
- then if the value of this record is "checked==T" you select the record 
else you discard it
- for each resulting record you select all fields

If the table has a unique record "id" this can more easily be done with 
db.value.client_date.belongs(subselect).

Queries this complex are often a sign of design problems. It would be 
easier to have a column "first" which you set to true for the first entry 
of each "indicator". Than you select would be very simple and much faster. 
I personally do not want to support queries like this in web2py. It would 
be easy to add logic in DAL to support but in my opinion this should be 
discouraged.


On Monday, 29 July 2013 05:00:20 UTC-5, Denis Rykov wrote:
>
> Please help me to write the following SQL query using DAL:
>
> SELECT indicator.*, v.date, v.value FROM indicator
> LEFT JOIN (
> SELECT value.value, _.indicator, date
> FROM (SELECT indicator, min(client_date) AS "date" FROM value 
> WHERE created_by = 1 GROUP BY indicator) _
> LEFT JOIN value ON _.indicator = value.indicator and _.date = 
> value.client_date
> ) v
> ON indicator.id = v.indicator
> WHERE indicator.checked = 'T'
>

-- 

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




[web2py] Re: I have some questions about Central Authorization Service (CAS)

2013-07-30 Thread Massimo Di Pierro
When you visit the forum page if the corresponding requires_login() than it 
would automatically redirect to myapp (check that you are logged in) and 
back as you expect. But if you visit an action that does not require login, 
web2py does not assume that you need to be logged in and does not check 
whether you are logged in into the provider app (myapp). That is why in 
this case you need to trigger the action by pressing login. If you need to 
be logged in to use forum, you should add the requires_login() decorators 
to all the actions.

If the provider app (myapp) uses social login (for example has a 
private/janrain.key file) CAS should work with social login. In this case 
the issue is, do you need CAS in this case?

On Monday, 29 July 2013 23:55:59 UTC-5, Chun-Hung Chen wrote:
>
> Hi,
>
> Let me describe what I want to achieve. There are 2 domains, 
> myapp.domain.name and forum.domain.name. I want login one domin and 
> automatically login at another domain. From book and search, CAS could be a 
> solution. Thus I set up auth.domain.name and setting cas_prodiver=
> auth.domain.name.
>
> However, after I login myapp.domain.name, forum.domain.name is not 
> automatically login but need to click "login" to accomplish login 
> process(however, I don't need to input user id and password again). How do 
> I ensure when I login A.domain.name, I am also automatically login in 
> B.domain.name.
>
> Besides, as auth.domain.name, I also want to add some social login, such 
> as Facebook and GMail. Is there anyone with experience with multiple login 
> methods and CAS?
>
> Thanks.
>
> Regards,
> Chun-Hung
>

-- 

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




[web2py] Re: How to create a hyperlink from a display field in sqlForm?

2013-07-30 Thread Alex Glaros
any hints would be appreciated!

On Sunday, July 28, 2013 4:55:53 AM UTC-7, Alex Glaros wrote:
>
> How do I create a hyperlink back to parent record ObjectSuperType.id from 
> displayed field db.TaxonomyDetail.objected below?
>
> The link would take user to the controller that displays parent table 
> ObjectSuperType.  How do I pass the parms to the other controller?
>
> Here is the controller for the detail record.  Look for field 
> db.TaxonomyDetail.objectID. I’d like to list its value, and also link from 
> it to the parent ObjectSuperType.id.
>
> def manage_taxonomy_detail(): 
> query = ((db.Taxonomy.id == db.TaxonomyData.taxonomyID) & 
> (db.TaxonomyDetail.taxonomyDataID==db.TaxonomyData.id))
> taxonomyList = 
> SQLFORM.grid(query,create=True,editable=True,deletable=True, 
> details=True,links_in_grid=True,
> paginate=10,
> fields=[db.Taxonomy.taxonomyLongName, 
> db.TaxonomyData.taxonomyDataName, db.TaxonomyDetail.objectID, 
> db.TaxonomyDetail.partyID])
> return dict(taxonomyList = taxonomyList)
>
> Here is the db.TaxonomyDetail table:
>
> db.define_table('TaxonomyDetail', ## Allows user to assign a taxonomy 
> field to any object
> Field('objectID', 'reference ObjectSuperType'),
> Field('taxonomyID','reference Taxonomy'), 
> Field('taxonomyDataID','reference TaxonomyData'),
> Field('partyID','reference Party', label='Data Owner'),
> Field('publicAccessLevel','reference PublicAccessLevelLookupTable'),
> Field('taxonomyDetailComments', 'string')) ## by person entering the data
> ## ^^
> db. TaxonomyDetail.objectID.requires = IS_IN_DB(db, 'ObjectSuperType.id', 
> '%(objectDisplayName)s',zero=T('choose one'))
> db. TaxonomyDetail.objectID.represent = lambda id,row: 
> db.ObjectSuperType(id).objectDisplayName
> db. TaxonomyDetail.taxonomyID.requires = IS_IN_DB(db, 'Taxonomy.id', 
> '%(taxonomyLongName)s',zero=T('choose one'))
> db. TaxonomyDetail.taxonomyDataID.requires = IS_IN_DB(db, 
> db.TaxonomyData.id, '%(taxonomyDataName)s',zero=T('choose one'))
> db. TaxonomyDetail.publicAccessLevel.requires = IS_IN_DB(db, 
> db.PublicAccessLevelLookupTable.publicAccessCode, 
> '%(publicAccessDescription)s',zero=T('choose one'), orderby=
> db.PublicAccessLevelLookupTable.id)
> db. TaxonomyDetail.partyID.requires = IS_IN_DB(db, db.Party.id, 
> '%(displayName)s',zero=T('choose one'))
> db. TaxonomyDetail.partyID.represent = lambda id,row: 
> db.Party(id).displayName
>
> Here is the controller for the parent ObjectSuperType.  How do I pass the 
> parms to it?
>
> def manage_object_super_type(): ## 
> grid = SQLFORM.smartgrid(db.ObjectSuperType), 
> return dict(grid=grid)
>
> thanks,
>
> Alex Glaros
>

-- 

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




[web2py] Re: python 3.3.2

2013-07-30 Thread Mirek Zvolský
>>  do I need some additional plugins to hook it up to my existing mysql db

Just write a connection string and table description in your model file - 
6th chapter of book describes this.

However in web2py all tables have autoincrement integer primary key called 
"id".
This field will be added automatically (when migration is enabled, which is 
default).
However you need have compatible foreign keys in linked tables (integer 
foreign keys with appropriate values for primary key "id").

If you already have a different style of primary/foreign keys, then 
connection is possible, but it will be not easy. It's better to redesign 
primary/foreign keys in such case.

-- 

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




Re: [web2py] Re: How to create a hyperlink from a display field in sqlForm?

2013-07-30 Thread Johann Spies
Here is an example of what I did yesterday. Maybe that will give you a hint:

 Field("url", represent = lambda x, record: A('click here for website',
_target = "_blank",
_href = x)) ,

In the grid the url column shows a link.

Regards
Johann


-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 

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




[web2py] Problem with virtual field

2013-07-30 Thread Eduardo Cruz
Hi, I have this table 
db.define_table('station',
dates,
Field('name', 'string', unique=True),
Field('average_time', 'integer'),
Field('area_id', 'reference area', requires=IS_IN_DB(db, 
'area.id', '%(name)s') ,label="Area", represent=lambda value,row: 
db.area(value).name),
Field('turn_id', 'reference turn', label="Turno Actual", 
default=1),
Field("is_active", 'boolean', default=True),
Field.Virtual('area_name', lambda row: 
db.area(row.station.area_id).name),
Field('turn_is_hold', compute=lambda row: 
db.turn(row.turn_id).is_hold),
Field("turn_is_transfer", compute=lambda row: 
db.turn(row.turn_id).is_transfer),
)


And when I try to register an user web2py gives me this error
 'Row' object has no attribute 'area_id'


If I comment the virtual field it just works but the problem is that I use 
that virtual field in another controller and it works just fine, I dont 
know why I does not works when enter to form to register an user.
any ideas?

-- 

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




[web2py] Re: controller return list instead of string or dict

2013-07-30 Thread Matt
We've got a controller with a restful method (using the @request.restful 
decorator), which makes calls over a json rpc socket and then returns the 
result. Sometimes the result of the json rpc call is a list of strings, 
which is properly converted back into python as a list type. When we do 
"return locals()" at this point (a la the rest services example in the 
book), even with a forced request.extension = 'json' and response.view = 
'generic.json' the value is not rendered as json but instead as just a 
plain string.

My sense is because python is following the path in main.py that I 
mentioned previously, determining the result is not a dict, and therefore 
not running any of the views on it (hence generic.json is not being 
called/used). Further, its just passing the list of strings along and 
python is concatenating that into just a single string.

It's not ideal for us to manually convert the result to a string just for 
this case where everything else works just fine by making it into the 
generic.json view. This used to "just work" for us because we did manual 
json.dumps conversion of the data, but this is the whole point of 
generic.json right? 

Regards,
Matt


On Tuesday, July 30, 2013 3:22:54 AM UTC-4, Niphlod wrote:
>
> can you explain better what's going on ? the generic json view (as any 
> other view) is made to serialize a python object to something (in json's 
> case, a json string). 
> If you already return a string because your code encodes it already, than 
> you don't need any view, because the job the view usually does has been 
> done already by your code.
>
> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>>
>> Hi,
>> We're running into an issue with our restful api where a certain method 
>> is returning a json string (eg: " ['one', 'two', 'three'] "), however 
>> web2py wants to render this as a string even when the request.extension is 
>> forced to json, and the response.view is forced to generic.json. I've 
>> tracked the issue down to gluon/main.py:231 where it checks if "page" is a 
>> dict, and what seems to be happening is that the valid json string above is 
>> instead being concatenated as a string representation. Adding this below 
>> the check for dict seems to fix it, but I'm not sure how well it fixes the 
>> problem:
>>
>> elif isinstance(page, list):
>> response._vars = page
>> run_view_in(response._view_environment)
>> page = response.body.getvalue()
>>
>> Any suggestions for other ways to go about fixing this? 
>>
>> Thanks,
>> Matt
>>
>>
>>

-- 

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




[web2py] auth.user_groups are cached? Can't see changes beeing done in admin UI until user logout/login again

2013-07-30 Thread David Marko
auth.user_groups are cached? Cant see changes beeing done in admin UI until 
user logout/login again . Any idea how to make this information to be 
fresh? I mean when I remove user from group, it should be working 
immediately ...

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Jonathan Lundell
On 30 Jul 2013, at 12:22 AM, Niphlod  wrote:
> can you explain better what's going on ? the generic json view (as any other 
> view) is made to serialize a python object to something (in json's case, a 
> json string). 
> If you already return a string because your code encodes it already, than you 
> don't need any view, because the job the view usually does has been done 
> already by your code.

The explanation isn't quite clear. I believe he's returning a list, intending 
that to be serialized as JSON. But web2py serializes anything that's not a dict 
as a string, so generic.json (for example) is never used.

The question is: what should happen when a controller returns a list? The JSON 
serializer is happy to serialize a list. Is there any downside in doing it? 
Does it make any sense right now for a controller to return a list?

> 
> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
> Hi,
> We're running into an issue with our restful api where a certain method is 
> returning a json string (eg: " ['one', 'two', 'three'] "), however web2py 
> wants to render this as a string even when the request.extension is forced to 
> json, and the response.view is forced to generic.json. I've tracked the issue 
> down to gluon/main.py:231 where it checks if "page" is a dict, and what seems 
> to be happening is that the valid json string above is instead being 
> concatenated as a string representation. Adding this below the check for dict 
> seems to fix it, but I'm not sure how well it fixes the problem:
> 
> elif isinstance(page, list):
> response._vars = page
> run_view_in(response._view_environment)
> page = response.body.getvalue()
> 
> Any suggestions for other ways to go about fixing this? 
> 
> Thanks,
> Matt
> 


-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt


On Tuesday, July 30, 2013 10:26:45 AM UTC-4, Jonathan Lundell wrote:
>
> On 30 Jul 2013, at 12:22 AM, Niphlod > 
> wrote:
>
> can you explain better what's going on ? the generic json view (as any 
> other view) is made to serialize a python object to something (in json's 
> case, a json string). 
> If you already return a string because your code encodes it already, than 
> you don't need any view, because the job the view usually does has been 
> done already by your code.
>
>
> The explanation isn't quite clear. I believe he's returning a list, 
> intending that to be serialized as JSON. But web2py serializes anything 
> that's not a dict as a string, so generic.json (for example) is never used.
>
> The question is: what should happen when a controller returns a list? The 
> JSON serializer is happy to serialize a list. Is there any downside in 
> doing it? Does it make any sense right now for a controller to return a 
> list?
>
>
Exactly. Apologies for lack of clarity.

Matt

>
> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>>
>> Hi,
>> We're running into an issue with our restful api where a certain method 
>> is returning a json string (eg: " ['one', 'two', 'three'] "), however 
>> web2py wants to render this as a string even when the request.extension is 
>> forced to json, and the response.view is forced to generic.json. I've 
>> tracked the issue down to gluon/main.py:231 where it checks if "page" is a 
>> dict, and what seems to be happening is that the valid json string above is 
>> instead being concatenated as a string representation. Adding this below 
>> the check for dict seems to fix it, but I'm not sure how well it fixes the 
>> problem:
>>
>> elif isinstance(page, list):
>> response._vars = page
>> run_view_in(response._view_environment)
>> page = response.body.getvalue()
>>
>> Any suggestions for other ways to go about fixing this? 
>>
>> Thanks,
>> Matt
>>
>>
>
>

-- 

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




[web2py] Re: auth.user_groups are cached? Can't see changes beeing done in admin UI until user logout/login again

2013-07-30 Thread Massimo Di Pierro
Yes they are cached. You can call

auth.update_groups() 

at every request to make sure the groups are updated but this is a lot of 
extra DB IO.

On Tuesday, 30 July 2013 08:55:13 UTC-5, David Marko wrote:
>
> auth.user_groups are cached? Cant see changes beeing done in admin UI 
> until user logout/login again . Any idea how to make this information to be 
> fresh? I mean when I remove user from group, it should be working 
> immediately ...
>

-- 

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




[web2py] Re: auth.user_groups are cached? Can't see changes beeing done in admin UI until user logout/login again

2013-07-30 Thread Anthony
On Tuesday, July 30, 2013 10:49:29 AM UTC-4, Massimo Di Pierro wrote:

> Yes they are cached. You can call
>
> auth.update_groups() 
>
> at every request to make sure the groups are updated but this is a lot of 
> extra DB IO.
>

Maybe use the DAL table callbacks to call auth.update_groups() only when 
the membership table is updated (or call it in whatever action you use to 
make the updates).

Anthony

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Anthony
Can you show your code? You say you "return locals()", but locals() 
produces a dictionary, so it should ultimately execute a view. Or are you 
just returning the list directly?

Anthony

On Tuesday, July 30, 2013 10:28:53 AM UTC-4, Matt wrote:
>
>
>
> On Tuesday, July 30, 2013 10:26:45 AM UTC-4, Jonathan Lundell wrote:
>>
>> On 30 Jul 2013, at 12:22 AM, Niphlod  wrote:
>>
>> can you explain better what's going on ? the generic json view (as any 
>> other view) is made to serialize a python object to something (in json's 
>> case, a json string). 
>> If you already return a string because your code encodes it already, than 
>> you don't need any view, because the job the view usually does has been 
>> done already by your code.
>>
>>
>> The explanation isn't quite clear. I believe he's returning a list, 
>> intending that to be serialized as JSON. But web2py serializes anything 
>> that's not a dict as a string, so generic.json (for example) is never used.
>>
>> The question is: what should happen when a controller returns a list? The 
>> JSON serializer is happy to serialize a list. Is there any downside in 
>> doing it? Does it make any sense right now for a controller to return a 
>> list?
>>
>>
> Exactly. Apologies for lack of clarity.
>
> Matt
>
>>
>> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>>>
>>> Hi,
>>> We're running into an issue with our restful api where a certain method 
>>> is returning a json string (eg: " ['one', 'two', 'three'] "), however 
>>> web2py wants to render this as a string even when the request.extension is 
>>> forced to json, and the response.view is forced to generic.json. I've 
>>> tracked the issue down to gluon/main.py:231 where it checks if "page" is a 
>>> dict, and what seems to be happening is that the valid json string above is 
>>> instead being concatenated as a string representation. Adding this below 
>>> the check for dict seems to fix it, but I'm not sure how well it fixes the 
>>> problem:
>>>
>>> elif isinstance(page, list):
>>> response._vars = page
>>> run_view_in(response._view_environment)
>>> page = response.body.getvalue()
>>>
>>> Any suggestions for other ways to go about fixing this? 
>>>
>>> Thanks,
>>> Matt
>>>
>>>
>>
>>

-- 

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




Re: [web2py] Re: How to create a hyperlink from a display field in sqlForm?

2013-07-30 Thread Alex Glaros
can you please map out a descriptions of the parms and where they come from?

What is the "x", "record", "A"?

thanks!

Alex

On Tuesday, July 30, 2013 5:23:50 AM UTC-7, Johann Spies wrote:
>
> Here is an example of what I did yesterday. Maybe that will give you a 
> hint:
>
>  Field("url", represent = lambda x, record: A('click here for website', 
> _target = "_blank",
> _href = x)) ,
>
> In the grid the url column shows a link.
>
> Regards
> Johann
>
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Jonathan Lundell
On 30 Jul 2013, at 8:34 AM, Anthony  wrote:
> Can you show your code? You say you "return locals()", but locals() produces 
> a dictionary, so it should ultimately execute a view. Or are you just 
> returning the list directly?

A list directly (see the code fragment below). 

Since generic.json serializes response._vars, it doesn't care about anything in 
env. You *could* write a view that accepts a dict with a list (or dict) as a 
well-known name and serialize that, but it's not what generic.json does.

> 
> Anthony
> 
> On Tuesday, July 30, 2013 10:28:53 AM UTC-4, Matt wrote:
> 
> 
> On Tuesday, July 30, 2013 10:26:45 AM UTC-4, Jonathan Lundell wrote:
> On 30 Jul 2013, at 12:22 AM, Niphlod  wrote:
>> can you explain better what's going on ? the generic json view (as any other 
>> view) is made to serialize a python object to something (in json's case, a 
>> json string). 
>> If you already return a string because your code encodes it already, than 
>> you don't need any view, because the job the view usually does has been done 
>> already by your code.
> 
> The explanation isn't quite clear. I believe he's returning a list, intending 
> that to be serialized as JSON. But web2py serializes anything that's not a 
> dict as a string, so generic.json (for example) is never used.
> 
> The question is: what should happen when a controller returns a list? The 
> JSON serializer is happy to serialize a list. Is there any downside in doing 
> it? Does it make any sense right now for a controller to return a list?
> 
> 
> Exactly. Apologies for lack of clarity.
> 
> Matt
>> 
>> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>> Hi,
>> We're running into an issue with our restful api where a certain method is 
>> returning a json string (eg: " ['one', 'two', 'three'] "), however web2py 
>> wants to render this as a string even when the request.extension is forced 
>> to json, and the response.view is forced to generic.json. I've tracked the 
>> issue down to gluon/main.py:231 where it checks if "page" is a dict, and 
>> what seems to be happening is that the valid json string above is instead 
>> being concatenated as a string representation. Adding this below the check 
>> for dict seems to fix it, but I'm not sure how well it fixes the problem:
>> 
>> elif isinstance(page, list):
>> response._vars = page
>> run_view_in(response._view_environment)
>> page = response.body.getvalue()
>> 
>> Any suggestions for other ways to go about fixing this? 
>> 
>> Thanks,
>> Matt
> 


-- 

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




Re: [web2py] Re: How to create a hyperlink from a display field in sqlForm?

2013-07-30 Thread Alex Glaros
Okay...I have this so far
db.TaxonomyDetail.objectID.represent =  lambda ObjectSuperType,record
: A(db.TaxonomyDetail.objectID, _target = "_blank", _href =
'manage_object_super_type')

But 

1. record: A(db.TaxonomyDetail.objectID displays literally instead of the 
field contents
2. Link goes to the correct controller but all records are selected.  How 
do I get it to choose the correct record in the table?

thanks,

Alex

On Tuesday, July 30, 2013 8:49:10 AM UTC-7, Alex Glaros wrote:
>
> can you please map out a description of the parms and where they come from?
>
> What is the "x", "record", "A"?
>
> thanks!
>
> Alex
>
> On Tuesday, July 30, 2013 5:23:50 AM UTC-7, Johann Spies wrote:
>>
>> Here is an example of what I did yesterday. Maybe that will give you a 
>> hint:
>>
>>  Field("url", represent = lambda x, record: A('click here for website', 
>> _target = "_blank",
>> _href = x)) ,
>>
>> In the grid the url column shows a link.
>>
>> Regards
>> Johann
>>
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>  
>

-- 

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




[web2py] Re: auth.user_groups are cached? Can't see changes beeing done in admin UI until user logout/login again

2013-07-30 Thread David Marko
But update_groups do update only for just login user so callbacks should do the 
work for every user, and this probably cant be done ...

-- 

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




[web2py] Problem with virtual field

2013-07-30 Thread Loïc
Did you try

 Field.Virtual('area_name', lambda row: db.area(row.area_id).name),

?

-- 

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




[web2py] web2py financing

2013-07-30 Thread Alex
I'm wondering how web2py is financed. Is it somehow financed from the 
University? Or is everyone only working in his spare time? That would be 
hard to believe for such a great framework.
Do you take donations?

regards,
Alex

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt


On Tuesday, July 30, 2013 11:51:08 AM UTC-4, Jonathan Lundell wrote:
>
> On 30 Jul 2013, at 8:34 AM, Anthony > 
> wrote:
>
> Can you show your code? You say you "return locals()", but locals() 
> produces a dictionary, so it should ultimately execute a view. Or are you 
> just returning the list directly?
>
>
>
Here is a snippit of what we are trying to do:



import simplejson 

@request.restful() 
def jsonlisttest():
response.view = 'generic.json' 

def GET(*args, **vars): 

sample_raw_rpc_response = '["one", "two", "three"]' 

sample_rpc_response = simplejson.loads(sample_raw_rpc_response) 

return sample_rpc_response 

def POST(*args, **vars): 

return dict() 

def PUT(*args, **vars): 

return dict() 

def DELETE(*args, **vars): 

return dict() 

return locals()

 

> A list directly (see the code fragment below). 
>
> Since generic.json serializes response._vars, it doesn't care about 
> anything in env. You *could* write a view that accepts a dict with a list 
> (or dict) as a well-known name and serialize that, but it's not what 
> generic.json does.
>
>
> Anthony
>
> On Tuesday, July 30, 2013 10:28:53 AM UTC-4, Matt wrote:
>>
>>
>>
>> On Tuesday, July 30, 2013 10:26:45 AM UTC-4, Jonathan Lundell wrote:
>>>
>>> On 30 Jul 2013, at 12:22 AM, Niphlod  wrote:
>>>
>>> can you explain better what's going on ? the generic json view (as any 
>>> other view) is made to serialize a python object to something (in json's 
>>> case, a json string). 
>>> If you already return a string because your code encodes it already, 
>>> than you don't need any view, because the job the view usually does has 
>>> been done already by your code.
>>>
>>>
>>> The explanation isn't quite clear. I believe he's returning a list, 
>>> intending that to be serialized as JSON. But web2py serializes anything 
>>> that's not a dict as a string, so generic.json (for example) is never used.
>>>
>>> The question is: what should happen when a controller returns a list? 
>>> The JSON serializer is happy to serialize a list. Is there any downside in 
>>> doing it? Does it make any sense right now for a controller to return a 
>>> list?
>>>
>>>
>> Exactly. Apologies for lack of clarity.
>>
>> Matt
>>
>>>
>>> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:

 Hi,
 We're running into an issue with our restful api where a certain method 
 is returning a json string (eg: " ['one', 'two', 'three'] "), however 
 web2py wants to render this as a string even when the request.extension is 
 forced to json, and the response.view is forced to generic.json. I've 
 tracked the issue down to gluon/main.py:231 where it checks if "page" is a 
 dict, and what seems to be happening is that the valid json string above 
 is 
 instead being concatenated as a string representation. Adding this below 
 the check for dict seems to fix it, but I'm not sure how well it fixes the 
 problem:

 elif isinstance(page, list):
 response._vars = page
 run_view_in(response._view_environment)
 page = response.body.getvalue()

 Any suggestions for other ways to go about fixing this? 

 Thanks,
 Matt

>>>
>
>
>

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt Broadstone
On Tue, Jul 30, 2013 at 2:11 PM, Matt  wrote:

>
>
> On Tuesday, July 30, 2013 11:51:08 AM UTC-4, Jonathan Lundell wrote:
>
>> On 30 Jul 2013, at 8:34 AM, Anthony  wrote:
>>
>> Can you show your code? You say you "return locals()", but locals()
>> produces a dictionary, so it should ultimately execute a view. Or are you
>> just returning the list directly?
>>
>>
>>
> Here is a snippit of what we are trying to do:
>
>
>
> import simplejson
>
> @request.restful()
> def jsonlisttest():
> response.view = 'generic.json'
>
> def GET(*args, **vars):
>
> sample_raw_rpc_response = '["one", "two", "three"]'
>
> sample_rpc_response = simplejson.loads(sample_raw_rpc_response)
>
> return sample_rpc_response
>
> def POST(*args, **vars):
>
> return dict()
>
> def PUT(*args, **vars):
>
> return dict()
>
> def DELETE(*args, **vars):
>
> return dict()
>
> return locals()
>
>
Ack, that will teach me for using the google groups interface instead of
email.. anyway, assume that snippit was actually formatted properly. You'll
see that I've added the basic json loading in there, but that is not the
actual issue. The issue is that a python list is returned, instead of a
dict or just a string, therefore bypassing any of the generic views and
auto-concatenating the list into a single string when accessed.

Matt



>
>> A list directly (see the code fragment below).
>>
>> Since generic.json serializes response._vars, it doesn't care about
>> anything in env. You *could* write a view that accepts a dict with a list
>> (or dict) as a well-known name and serialize that, but it's not what
>> generic.json does.
>>
>>
>> Anthony
>>
>> On Tuesday, July 30, 2013 10:28:53 AM UTC-4, Matt wrote:
>>>
>>>
>>>
>>> On Tuesday, July 30, 2013 10:26:45 AM UTC-4, Jonathan Lundell wrote:

 On 30 Jul 2013, at 12:22 AM, Niphlod  wrote:

 can you explain better what's going on ? the generic json view (as any
 other view) is made to serialize a python object to something (in json's
 case, a json string).
 If you already return a string because your code encodes it already,
 than you don't need any view, because the job the view usually does has
 been done already by your code.


 The explanation isn't quite clear. I believe he's returning a list,
 intending that to be serialized as JSON. But web2py serializes anything
 that's not a dict as a string, so generic.json (for example) is never used.

 The question is: what should happen when a controller returns a list?
 The JSON serializer is happy to serialize a list. Is there any downside in
 doing it? Does it make any sense right now for a controller to return a
 list?


>>> Exactly. Apologies for lack of clarity.
>>>
>>> Matt
>>>

 On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
>
> Hi,
> We're running into an issue with our restful api where a certain
> method is returning a json string (eg: " ['one', 'two', 'three'] "),
> however web2py wants to render this as a string even when the
> request.extension is forced to json, and the response.view is forced to
> generic.json. I've tracked the issue down to gluon/main.py:231 where it
> checks if "page" is a dict, and what seems to be happening is that the
> valid json string above is instead being concatenated as a string
> representation. Adding this below the check for dict seems to fix it, but
> I'm not sure how well it fixes the problem:
>
> elif isinstance(page, list):
> response._vars = page
> run_view_in(response._view_**environment)
> page = response.body.getvalue()
>
> Any suggestions for other ways to go about fixing this?
>
> Thanks,
> Matt
>

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

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt Broadstone
On Tue, Jul 30, 2013 at 2:14 PM, Alan Etkin  wrote:

>
>>
>> The question is: what should happen when a controller returns a list? The
>> JSON serializer is happy to serialize a list. Is there any downside in
>> doing it? Does it make any sense right now for a controller to return a
>> list?
>>
>
> It would be inconsistent with this documented part of the workflow
>
> "... If the action returns an iterable, this is used to loop and stream
> the data to the client. ..."
>
> I suppose that the expected way to return json arrays is to add them to a
> dictionary and then process them with a custom view (customize the generic
> view).
>
>
>
So the advice is to make generic-list.json, and force that view, expecting
that the input is in some format we decide upon. e.g. instead of returning
sample_rpc_response, we return dict(result=sample_rpc_response)?

Matt


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

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Alan Etkin
 
>
> The question is: what should happen when a controller returns a list? The 
> JSON serializer is happy to serialize a list. Is there any downside in 
> doing it? Does it make any sense right now for a controller to return a 
> list?
>

It would be inconsistent with this documented part of the workflow

"... If the action returns an iterable, this is used to loop and stream the 
data to the client. ..."

I suppose that the expected way to return json arrays is to add them to a 
dictionary and then process them with a custom view (customize the generic 
view).

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Anthony
@request.restful() 
def jsonlisttest():
response.view = 'generic.json' 
def GET(*args, **vars): 
sample_raw_rpc_response = '["one", "two", "three"]' 
sample_rpc_response = simplejson.loads(sample_raw_rpc_response) 
return sample_rpc_response 

Looks like you're starting with what is already JSON 
(sample_raw_rpc_response), then converting to a Python list (with 
simplejson.loads), and then wanting to send it to the generic.json view to 
be converted back to a JSON string. Why not just deliver the original 
string:

def GET(*args, **vars): 
sample_raw_rpc_response = '["one", "two", "three"]'
return sample_raw_rpc_response

Anthony

-- 

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




[web2py][share] Select2.js

2013-07-30 Thread Richard
Hello,

I just found this (select2.js) : 
http://ivaynberg.github.io/select2/index.html

A kind of chosen on steroïd...

It include a Tagging utility that let insert new tag on the fly like Tag-it 
but don't seem to require jQuery UI.

Enjoy.

Richard

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt Broadstone
On Tue, Jul 30, 2013 at 2:26 PM, Anthony  wrote:

> @request.restful()
> def jsonlisttest():
> response.view = 'generic.json'
> def GET(*args, **vars):
> sample_raw_rpc_response = '["one", "two", "three"]'
> sample_rpc_response = simplejson.loads(sample_raw_rpc_response)
> return sample_rpc_response
>
> Looks like you're starting with what is already JSON
> (sample_raw_rpc_response), then converting to a Python list (with
> simplejson.loads), and then wanting to send it to the generic.json view to
> be converted back to a JSON string. Why not just deliver the original
> string:
>
> def GET(*args, **vars):
> sample_raw_rpc_response = '["one", "two", "three"]'
>
> return sample_raw_rpc_response
>
>
Because in between there is a whole lot of other processing.. I was just
trying to put together a small test case to show that returning a python
list caused a problem.

Matt


> Anthony
>
> --
>
> ---
> 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/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Anthony

>
> So the advice is to make generic-list.json, and force that view, expecting 
> that the input is in some format we decide upon. e.g. instead of returning 
> sample_rpc_response, we return dict(result=sample_rpc_response)?


You could do that, but see my other response.

Anthony

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Matt Broadstone
On Tue, Jul 30, 2013 at 2:31 PM, Anthony  wrote:

> So the advice is to make generic-list.json, and force that view, expecting
>> that the input is in some format we decide upon. e.g. instead of returning
>> sample_rpc_response, we return dict(result=sample_rpc_**response)?
>
>
> You could do that, but see my other response.
>
> Anthony
>
> think of it this way:

import simplejson

@request.restful()
def jsonlisttest():
response.view = 'generic.json'

def GET(*args, **vars):
sample_raw_rpc_response = '["one", "two", "three"]'
sample_rpc_response = simplejson.loads(sample_raw_rpc_response)
result =
someOtherOperationThatCanPOTENTIALLYReturnAList(sample_rpc_response)
return result

def POST(*args, **vars):
return dict()
def PUT(*args, **vars):
return dict()
def DELETE(*args, **vars):
return dict()
return locals()

The problem is that we can't be sure if the operation returns a list or a
dict, but we want to render the result as json. So, the solution where we
create a generic-list.json doesn't work for us in this case either. We
rather unavoidably end up with a list result sometimes, and if that's the
case then it just iterates over it and returns a concatenated string.

Matt

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

-- 

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




[web2py] Re: auth.user_groups are cached? Can't see changes beeing done in admin UI until user logout/login again

2013-07-30 Thread Anthony
Oops, sorry, wasn't thinking. I suppose you could do something more 
sophisticated like store the affected user IDs in cache.ram and do a check 
there on each request.

Anthony

On Tuesday, July 30, 2013 1:28:13 PM UTC-4, David Marko wrote:
>
> But update_groups do update only for just login user so callbacks should 
> do the work for every user, and this probably cant be done ...

-- 

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




Re: [web2py] controller return list instead of string or dict

2013-07-30 Thread Anthony
Why not:

def GET(*args, **vars):
sample_raw_rpc_response = '["one", "two", "three"]' 
sample_rpc_response = simplejson.loads(sample_raw_rpc_response)
result = someOtherOperationThatCanPOTENTIALLYReturnAList(
sample_rpc_response)
return simplejson.dumps(result)

Or if you need the more sophisticated parsing of generic.json:

from gluon.serializers import json
return json(result)

There's not much reason to use a view here -- the view just includes a 
single line that calls a JSON serializer.

Anthony

-- 

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




[web2py] Re: python 3.3.2

2013-07-30 Thread D Dan
Is there a way we could share these things (db.py models and modules across 
applications?)

Currently we share databases across applications. IT is a bit tedious to 
copy schema definitions to many applications.


Thanks 

On Sunday, July 28, 2013 1:54:03 AM UTC-7, Massimo Di Pierro wrote:
>
> About your first question you can read Anthony's answer here:
>
> http://stackoverflow.com/questions/17271938/web2py-is-not-starting-with-python-3-0-3-1
>
> Regarding multiple apps/projects web2py is more flexible than Django but 
> we using a different naming convention.
> We call "app" what they call "project" and we call "plugin" when they call 
> "app".
>
> This is not only a semantic difference. In Django (as far as I understand 
> it), for each installation all the apps share one database (that of the 
> project), the session, etc.
>
> In web2py each app has its own database(s), its own session, cache, 
> authentication, users, groups, etc. In web2py different apps can even use 
> different and incompatible versions of the same modules because they share 
> nothing (unless you want them to). 
>
> In web2py you can plug-and-play install as many apps (projects) as you 
> like even if they are written by different people and are not designed to 
> work with each other.
>
> This is one of the main distinctive features of web2py.
>
> Web2py plugins instead go "under" a web2py app and therefore they are 
> closer to a Django app. They are specifically designed to work together and 
> their use may required some programming or configuration.
>
> Hope I make sense.
>
> Massimo
>
>
> On Saturday, 27 July 2013 21:52:55 UTC-5, Oliver wrote:
>>
>> I'm new to python web framework and stumble upon web2py.
>>
>> Will web2py works with python 3.3.2.  
>>
>> also, can I create multiple apps inside a project like in django?  do I 
>> need some additional plugins to hook it up to my existing mysql db?
>>
>

-- 

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




[web2py] Re: python 3.3.2

2013-07-30 Thread Alan Etkin
You can share the schema across different apps by serving and requesting it 
in json or yaml format:

Is there a way we could share these things (db.py models and modules across 
> applications?)
>
> Currently we share databases across applications. IT is a bit tedious to 
> copy schema definitions to many applications.
>

# sanitize set to False preserves the uri string
data = db.as_json(sanitize=False)

At the client side you can then restore it with

from gluon.serializers import loads_json
schema = loads_json(data)
db = DAL(schema)

The Table class also supports similar methods to export a subset of the 
table definitions

-- 

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




[web2py] New web2pyslices packages content

2013-07-30 Thread Alan Etkin
We have a new feature at web2pyslices.com to share information on public 
web2py projects. If you developed some web2py app, plugin, module, source 
code or tools in general that could be used with web2py, and you want to 
make it publicly available, you can simply add it to web2pyslices packages 
as with any other article. Here's how to do it:

- Login with your registered account. If you don't have a user account, you 
can get a free one at https://www.web2pyslices.com/person/account/register
- Open https://www.web2pyslices.com/slice/new/Package (or go to Create a 
slice -> Package)
- Fill the package information form.

That's it. Now your posted resource will be available so other users can 
browse or search for available web2py tools. This feature can be used in 
next versions of the admin app to browse and add/update diferent resurces 
(i.e. plugins), specially those that use version control systems.

-- 

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




[web2py] Form errors list ... Is there a way how to get field labels?

2013-07-30 Thread David Marko
I would like to disable inline form error messages and put these as a  list 
above the form. Common errors list comtains the field name, which is rather 
technical term. Is there a way how to get a label name for each field name from 
form object?

-- 

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




[web2py] Re: Form errors list ... Is there a way how to get field labels?

2013-07-30 Thread Anthony
form.custom.label[fielname]

Anthony

On Tuesday, July 30, 2013 4:42:13 PM UTC-4, David Marko wrote:
>
> I would like to disable inline form error messages and put these as a 
>  list above the form. Common errors list comtains the field name, which is 
> rather technical term. Is there a way how to get a label name for each 
> field name from form object?

-- 

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




[web2py] Re: Form errors list ... Is there a way how to get field labels?

2013-07-30 Thread Anthony
Or

db.mytable[fieldname].label


On Tuesday, July 30, 2013 4:45:35 PM UTC-4, Anthony wrote:
>
> form.custom.label[fielname]
>
> Anthony
>
> On Tuesday, July 30, 2013 4:42:13 PM UTC-4, David Marko wrote:
>>
>> I would like to disable inline form error messages and put these as a 
>>  list above the form. Common errors list comtains the field name, which is 
>> rather technical term. Is there a way how to get a label name for each 
>> field name from form object?
>
>

-- 

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




[web2py] Re: New web2pyslices packages content

2013-07-30 Thread Anthony
Nice. A few comments:

   - At the very bottom of the form, there is a heading that says "Right 
   Sidebar".
   - In the actual right sidebar, there is an additional "License" dropdown 
   -- presumably this is left over from the recipe/article post types, but 
   seems a bit odd and confusing here given that there is already a "License" 
   dropdown in the main form (with different choices).
   - In the Package Type dropdown, what's the difference between appliance 
   and app? Maybe just stick with app (or otherwise explain the difference).
   - Also, instead of "Python source", "Python module/library" might be 
   more clear.

Great work.

Anthony

On Tuesday, July 30, 2013 4:10:02 PM UTC-4, Alan Etkin wrote:
>
> We have a new feature at web2pyslices.com to share information on public 
> web2py projects. If you developed some web2py app, plugin, module, source 
> code or tools in general that could be used with web2py, and you want to 
> make it publicly available, you can simply add it to web2pyslices packages 
> as with any other article. Here's how to do it:
>
> - Login with your registered account. If you don't have a user account, 
> you can get a free one at 
> https://www.web2pyslices.com/person/account/register
> - Open https://www.web2pyslices.com/slice/new/Package (or go to Create a 
> slice -> Package)
> - Fill the package information form.
>
> That's it. Now your posted resource will be available so other users can 
> browse or search for available web2py tools. This feature can be used in 
> next versions of the admin app to browse and add/update diferent resurces 
> (i.e. plugins), specially those that use version control systems.
>

-- 

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




[web2py] Re: python 3.3.2

2013-07-30 Thread D Dan
Thanks Alan.

Could you give an example how to share db.py and other function under 
models/ folder (say menu.py) across applications?





On Tuesday, July 30, 2013 12:16:17 PM UTC-7, Alan Etkin wrote:
>
> You can share the schema across different apps by serving and requesting 
> it in json or yaml format:
>
> Is there a way we could share these things (db.py models and modules 
>> across applications?)
>>
>> Currently we share databases across applications. IT is a bit tedious to 
>> copy schema definitions to many applications.
>>
>
> # sanitize set to False preserves the uri string
> data = db.as_json(sanitize=False)
>
> At the client side you can then restore it with
>
> from gluon.serializers import loads_json
> schema = loads_json(data)
> db = DAL(schema)
>
> The Table class also supports similar methods to export a subset of the 
> table definitions
>
> EDIT: If your apps share the server, then you could just share a module 
> with the table definitions:
>
>
> http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py
>

-- 

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




[web2py] Re: need help testing app

2013-07-30 Thread greaneym


I fixed some database problems and added more error checking and this seems 
to work fine now. Thanks for the help and tests.

Margaret

-- 

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




[web2py] Re: New web2pyslices packages content

2013-07-30 Thread Alan Etkin

>
>
>- At the very bottom of the form, there is a heading that says "Right 
>Sidebar".
>
> Oops. I will remove it.
 

>
>- In the actual right sidebar, there is an additional "License" 
>dropdown -- presumably this is left over from the recipe/article post 
>types, but seems a bit odd and confusing here given that there is already 
> a 
>"License" dropdown in the main form (with different choices).
>
> I think we have to keep both licenses, one for the project and the normal 
document licence, because the user might want to add some stuff like extra 
documentation on the project or examples. Maybe I can add a note somewhere 
in the form to note the differences and also change the bare "License" to 
"Package license" or similar. Would it be ok?
 

>
>- In the Package Type dropdown, what's the difference between 
>appliance and app? Maybe just stick with app (or otherwise explain the 
>difference).
>
> Ok, but appliances are less general than apps because the former are "... 
Ready-to-use web2py applications ..." (wathever it is). I'm okay with 
leaving just app anyway because the difference seems to be subtle. It seems 
to me that appliances are in some way the app version of plugins, although 
there's not much attention paid on them.

I could some add sort of package term definition help so users can decide 
wether their project fits in one of the package types provided.

>
>- Also, instead of "Python source", "Python module/library" might be 
>more clear.
>
> Ok. I'll change that too.

Thanks!

-- 

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




[web2py] Re: bootstrap 3

2013-07-30 Thread samuel bonilla
graet i like use http://getbootstrap.com and 
http://foundation.zurb.com/ on web2py

El lunes, 29 de julio de 2013 09:01:47 UTC-5, Niphlod escribió:
>
> just to inform everybody that 3.0 is coming out 
> http://twitter.github.io/bootstrap/
>

-- 

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




[web2py] Re: New web2pyslices packages content

2013-07-30 Thread Anthony

>
> I think we have to keep both licenses, one for the project and the normal 
> document licence, because the user might want to add some stuff like extra 
> documentation on the project or examples. Maybe I can add a note somewhere 
> in the form to note the differences and also change the bare "License" to 
> "Package license" or similar. Would it be ok?


Sounds good. 

>
>>- In the Package Type dropdown, what's the difference between 
>>appliance and app? Maybe just stick with app (or otherwise explain the 
>>difference).
>>
>> Ok, but appliances are less general than apps because the former are "... 
> Ready-to-use web2py applications ..." (wathever it is). I'm okay with 
> leaving just app anyway because the difference seems to be subtle. It seems 
> to me that appliances are in some way the app version of plugins, although 
> there's not much attention paid on them.
>

Probably too subtle a difference to be worth making.

Anthony

-- 

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




[web2py] Access web2py app running on a remote server's localhost

2013-07-30 Thread Curiouslearn
Hello,

I have a droplet on digitalocean running Ubuntu precise. I installed web2py
using the source and then I started the server using python web2py.py
command. The message says "please visit: http://127.0.0.1:8000. Is there a
way I can access from my local computer.

Thank you.

-- 

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




[web2py] Re: Web2Py + TurnkeyLinux and Apache

2013-07-30 Thread james c.
Let me clarify the situation. I am using the TKL Web2Py Appliance and 
deploying my Web2Py application through the TKL Hub. My application is 
"myapp". I log in to the TKL Hub with SSL (this works just fine). I access 
the page for my applications server via SSL: 
https://hub.turnkeylinux.org/servers/ (this is all ok).
 Now when I click on the link for my application or the public IP for my 
application I get the following error: ("The site's security certificate is 
not trusted"). I can access this page, but with no SSL. Also, any following 
user logins to my application is in the clear (no SSL).

The Web2Py TurnKey Linux Appliance is supposed to be "out of the box with 
SSL". I'm not sure exactly what that means. Should SSL just work as is, or 
do I need to purchase a certificate and if so where does my applications' 
certificate it go?

thanks, James


On Wednesday, July 24, 2013 1:03:27 PM UTC-7, james c. wrote:
>
> I easily deployed my Web2Py app "with just a few clicks" through the 
> TurnKeyLinux Hub onto Amazon EC2. The Web2Py Admin console shows that the 
> app is running with Apache. However, it seems to still be running on Rocket 
> from an error message related to SSL. Any SSL connection attempt is 
> ignored. The Web2Py deployment recipes provide a length list of commands to 
> deploy Apache, but I expect that the TKL Web2Py appliance has already taken 
> care of that. Is there a web2py configuration parameter that "points" to 
> Rocket Server or Apache?
>
> thanks in advance for any advice, James  
>

-- 

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




[web2py] Re: python 3.3.2

2013-07-30 Thread Alan Etkin


El martes, 30 de julio de 2013 18:19:15 UTC-3, D Dan escribió:
>
> Thanks Alan.
>
> Could you give an example how to share db.py and other function under 
> models/ folder (say menu.py) across applications?
>

If you will share models stored in modules, I suppose you can try something 
similar to what is shown in the web2pyslices recipe list.

(web2py/site-packages/mymodule.py)

# db is the specific database connection for each app.
def define_db_tables(db, args):
db.define_table(...)
...

Then in db.py you can do something like

from mymodule import define_db_tables
define_db_tables(db, args)

-- 

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




[web2py] Re: Problem with virtual field

2013-07-30 Thread Joe Barnhart
I just ran into this one.  It turns out that the row you want may be inside 
the row variable passed, with the table name as its key.  How does this 
happen?  If you have a select that has variables from several tables, for 
instance.

I did come up with a workaround, but it's a little, uh... "idiomatic".

lambda row: db.area(row.get('station',row).area_id).name

The clause "get('station',row)" will test the row variable for an embedded 
row with the table's name as its key.  If no such embedded row is found, it 
defaults to returning the rwo variable itself.  This has the effect of 
trying to look up the table name key and falling back to assuming its just 
a simple row.

-- Joe B.

On Tuesday, July 30, 2013 5:35:38 AM UTC-7, Eduardo Cruz wrote:
>
> Hi, I have this table 
> db.define_table('station',
> dates,
> Field('name', 'string', unique=True),
> Field('average_time', 'integer'),
> Field('area_id', 'reference area', requires=IS_IN_DB(db, '
> area.id', '%(name)s') ,label="Area", represent=lambda value,row: 
> db.area(value).name),
> Field('turn_id', 'reference turn', label="Turno Actual", 
> default=1),
> Field("is_active", 'boolean', default=True),
> Field.Virtual('area_name', lambda row: 
> db.area(row.station.area_id).name),
> Field('turn_is_hold', compute=lambda row: 
> db.turn(row.turn_id).is_hold),
> Field("turn_is_transfer", compute=lambda row: 
> db.turn(row.turn_id).is_transfer),
> )
>
>
> And when I try to register an user web2py gives me this error
>  'Row' object has no attribute 'area_id'
>
>
> If I comment the virtual field it just works but the problem is that I use 
> that virtual field in another controller and it works just fine, I dont 
> know why I does not works when enter to form to register an user.
> any ideas?
>
>

-- 

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




Re: [web2py][share] Select2.js

2013-07-30 Thread Brian M
Nice find!

On Tuesday, July 30, 2013 1:26:53 PM UTC-5, Richard wrote:
>
> Hello,
>
> I just found this (select2.js) : 
> http://ivaynberg.github.io/select2/index.html
>
> A kind of chosen on steroïd...
>
> It include a Tagging utility that let insert new tag on the fly like 
> Tag-it but don't seem to require jQuery UI.
>
> Enjoy.
>
> Richard
>

-- 

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




[web2py] Accessing db from the module

2013-07-30 Thread Mark Finkelstein
I've been using current to access the db in my modules, but I would like to 
modularize my modules a bit so that I don't rely as much on current. I was 
wondering why db seems to not be accessible from the modules when passed by 
a caller and saved through the init statement. In other words, if I were to 
call Module(db) or as in Auth(db), it seems that if the module isnt able to 
commit to the db. Auth clearly is able to do this, and I believe I am 
following the Auth as an example well enough, but I thought there might be 
some peculiarities to modules that I am not aware of as clearly auth 
accesses the environment in a special way as well.

Thank you in advance!

-- 

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




[web2py] Re: I have some questions about Central Authorization Service (CAS)

2013-07-30 Thread Chun-Hung Chen
Hi,

Thanks for the reply. Because I would like to integrate local account with 
social account, people can choose to login with social account or create an 
account on the website. That's the reason I think CAS is needed.

Back to the issues, is it possible for me to pretest the login process 
before rendering a view? Like a menu bar with a function "Login" or 
"Profile". If logged in, it shows "Profile", otherwise if not. In the 
origin scenario, only after I click "Login", "Login" would change to 
"Profile". However I have already login at other domain. This is kind of 
impossible, right? Because session data is not shared between these two 
domains.

Regards,
Chun-Hung

Massimo Di Pierro於 2013年7月30日星期二UTC+8下午5時00分58秒寫道:
>
> When you visit the forum page if the corresponding requires_login() than 
> it would automatically redirect to myapp (check that you are logged in) and 
> back as you expect. But if you visit an action that does not require login, 
> web2py does not assume that you need to be logged in and does not check 
> whether you are logged in into the provider app (myapp). That is why in 
> this case you need to trigger the action by pressing login. If you need to 
> be logged in to use forum, you should add the requires_login() decorators 
> to all the actions.
>
> If the provider app (myapp) uses social login (for example has a 
> private/janrain.key file) CAS should work with social login. In this case 
> the issue is, do you need CAS in this case?
>
> On Monday, 29 July 2013 23:55:59 UTC-5, Chun-Hung Chen wrote:
>>
>> Hi,
>>
>> Let me describe what I want to achieve. There are 2 domains, 
>> myapp.domain.name and forum.domain.name. I want login one domin and 
>> automatically login at another domain. From book and search, CAS could be a 
>> solution. Thus I set up auth.domain.name and setting cas_prodiver=
>> auth.domain.name.
>>
>> However, after I login myapp.domain.name, forum.domain.name is not 
>> automatically login but need to click "login" to accomplish login 
>> process(however, I don't need to input user id and password again). How do 
>> I ensure when I login A.domain.name, I am also automatically login in 
>> B.domain.name.
>>
>> Besides, as auth.domain.name, I also want to add some social login, such 
>> as Facebook and GMail. Is there anyone with experience with multiple login 
>> methods and CAS?
>>
>> Thanks.
>>
>> Regards,
>> Chun-Hung
>>
>

-- 

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