[web2py] Re: field defined as requires IS_IN_SET defaults to blank on sqlform.grid edit

2013-02-07 Thread Tim Richardson
And an espresso later ... the reason is that my table was defined as 
char(50) not varchar(50), so the values where gettings spaces at the end, 
and were therefore failing the validation when trying to display the row.

-- 

--- 
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] field defined as requires IS_IN_SET defaults to blank on sqlform.grid edit

2013-02-07 Thread Tim Richardson
I have a field defined as 
Field('item_type','string',requires=IS_IN_SET(['Procedure','Consultation']))

db1.define_table('com_tier1',Field('item_nbr','string'),Field('doctorID','reference
 
doctor'),
Field('cmsn_pct','decimal(18,4)',requires = IS_DECIMAL_IN_RANGE(-1,1)),
   Field('cmsn_set', 'reference com_general_settings'),
Field('item_type','string',requires=IS_IN_SET(['Procedure',
'Consultation'])),Field('item_desc','string'),migrate=False)



When dispaying this table in SQLFORM.grid and then editing a row, instead 
of displaying the saved value in the field, I get blank in that field.


@auth.requires_login()
def tier1():
grid = SQLFORM.grid(db1.com_tier1,details=True,editable=True,create=True
,deletable=True)
return dict(form=grid)
 


It then fails validation if the user makes a change in another field and 
submits. What I am doing wrong? 




2.3.2 with tables defined in MSSQL. 



-- 

--- 
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] negative ID values in the ID field break use of format in SQLFORM.grid

2013-02-07 Thread Tim Richardson
Using 2.3.2 with MSQL, I have a table T1 where the primary key is ID 
(migrate=false)
Most values have ID > 0 but I have two special cases where the ID is < 0 
T1 uses format to make a friend display of the primary key. 

Then this table is referred to in another table T2 using reference. 
When I use SQLFORM.grid to display T2, in the column for the referring 
field shows the friendly format whenever the ID >0, but for my two rows 
where ID = -1 and ID = -2 the format field is skipped; instead I see "-1" 
or "-2".


-- 

--- 
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: Scheduler Quick question

2013-02-07 Thread Tim Richardson

Well there are definitely some experts here, but this is what I understand:
1) the scheduler should run as a completely detached process.
2) Windows, OS X & linux have ways of doing this via task schedulers or 
startup scripts (often the task scheduler has an option that means run at 
startup).
They are very easy to configure, so you need to learn how to do it or ask 
your host to do it. We're talking one liners. The linux task scheduler is 
called cron, and often shared hosting environments let you add entries to 
cron. A search of webfaction docs for cron indicates that they offer cron.

It may be possible to do it from within web2py. You will need to have 
python code which can spawn a completely detached process. I am certain 
this is a much longer learning curve. 



-- 

--- 
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] Minimum period in web2py Scheduler

2013-02-07 Thread Bernard
I am using the web2py scheduler to run a task periodically, with a single 
worker thread.  The task is configured to run an infinite number of times.
If I set the task period to 1 second, I can verify that the task is being 
run in the scheduler_run table, but the run_time indicates it is running 
every 15 seconds.

35 newtask COMPLETED 2013-02-07 20:48:10 2013-02-07 20:48:11 you passed 
ar... "done!" None Bernard-PC#5816
36 newtask COMPLETED 2013-02-07 20:48:26 2013-02-07 20:48:27 you passed 
ar... "done!" None Bernard-PC#5816
37 newtask COMPLETED 2013-02-07 20:48:39 2013-02-07 20:48:40 you passed 
ar... "done!" None Bernard-PC#5816
38 newtask COMPLETED 2013-02-07 20:48:55 2013-02-07 20:48:56 you passed 
ar... "done!" None Bernard-PC#5816
39 newtask COMPLETED 2013-02-07 20:49:11 2013-02-07 20:49:13 you passed 
ar... "done!" None Bernard-PC#5816
40 newtask COMPLETED 2013-02-07 20:49:25 2013-02-07 20:49:26 you passed 
ar... "done!" None Bernard-PC#5816
41 newtask COMPLETED 2013-02-07 20:49:41 2013-02-07 20:49:42 you passed 
ar... "done!" None Bernard-PC#5816
42 newtask COMPLETED 2013-02-07 20:49:54 2013-02-07 20:49:55 you passed 
ar... "done!" None Bernard-PC#5816
43 newtask COMPLETED 2013-02-07 20:50:10 2013-02-07 20:50:11 you passed 
ar... "done!" None Bernard-PC#5816
44 newtask COMPLETED 2013-02-07 20:50:26 2013-02-07 20:50:27 you passed 
ar... "done!" None Bernard-PC#5816
45 newtask COMPLETED 2013-02-07 20:50:39 2013-02-07 20:50:40 you passed 
ar... "done!" None Bernard-PC#5816

Is this 15 second by design? Is it configurable?

Thanks,
Bernard

-- 

--- 
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 difficult query

2013-02-07 Thread Jake Lowen
Solved:  It was a dumb mistake.. I was trying to group by a field in the 
left join table.. so of course it was eliminating all records not found in 
the second table.  I switched the group by to a first table field and all 
is well.

Final working query was:

foo = db(db.benchmark_targets.benchmark == 
for_benchmark.id).select(db.benchmark_targets.ALL, db.lobby_report.ALL, 
left=db.lobby_report.on(db.lobby_report.KPID == db.benchmark_targets.KPID), 
orderby=~db.lobby_report.datetime, groupby=db.benchmark_targets.KPID)

Hours in front of a screen stumped me, but I go for a drive and the 
solution occurs to me instantly.

-- 

--- 
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] Integrating iPhone device tokens into web2py auth

2013-02-07 Thread chris_g
I'm looking into supporting Apple push notifications in an iPhone app that 
connects to a web2py server.
In order to know which devices to push details to, web2py's auth module 
would presumably need to maintain "Device Tokens".
I'm curious if anyone has implemented a solution that takes care of this. 
I'd like to see how it was integrated with web2py's auth.

Thanks,
Chris

-- 

--- 
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: Example JSON Code

2013-02-07 Thread howesc
"get_days" is not a valid url.  "/get_days" might be depending on your 
routing.  for the purposes of getting things working you should put in the 
fully qualified URL like

http://test.exmaple.com/app/json_test/get_days

cfh

On Thursday, February 7, 2013 2:12:34 PM UTC-8, pal...@gmail.com wrote:
>
> Here's the top of the html file, the Javascript function and the Python 
>> file. Started using the *jsonp-2.4.0.min.js* script because it appears 
>> to handle errors better.  I've just jumped into Web2py so I don't know if 
>> I'm building the URL properly.
>>
>
> This returns:
> *errMsg =Uncaught Error.*
> *undefined*
> *status =error*
> *xhr.status= undefined*
> *xhr.statusText= undefined *
> --
> {{extend 'layout.html'}}
> 
>  type="text/javascript">
> 
>
>  />
> .
> .
> .
> function *getTest3(type)* {
> var $url = "get_days";
> alert("In getTest3 before jsonp call");
> var dbugData = "";
> $('textarea#retarea').val( $('textarea#retarea').val() + dbugData );  
> *$.jsonp({*
> beforeSend: alert("Before jsonp call"),
> url: "get_days",
> datatype: 'json',
> success: function(json, textStatus, xOptions) { 
> alert(json.message);//Undefined Error
> $('textarea#retarea').val( $('textarea#retarea').val() + "\ntextStatus =" 
> + textStatus );
> $('textarea#retarea').val( $('textarea#retarea').val() + "\njson.status= " 
> + json.status );
> },
> error: function(xhr, status) {
> var errMsg;
> if (xhr.status === 0) {
> errMsg ='Not connect.\n Verify Network.';
> } else if (xhr.status == 404) { 
> errMsg ='Requested page not found. [404]';
> } else if (xhr.status == 500) { 
> errMsg ='Internal Server Error [500].';
> } else if (status == 'parsererror') {
> errMsg ='Requested JSON parse failed.';
> } else if (status == 'timeout') {
> errMsg ='Time out error.';
> } else if (status == 'abort') {
> errMsg ='Ajax request aborted.';
> } else {
> errMsg ='Uncaught Error.\n' + xhr.responseText;
> }
> alert(errMsg); 
> $('textarea#retarea').val( $('textarea#retarea').val() + "\nerrMsg =" + 
> errMsg );
> $('textarea#retarea').val( $('textarea#retarea').val() + "\nstatus =" + 
> status );
> $('textarea#retarea').val( $('textarea#retarea').val() + "\nxhr.status= " 
> + xhr.status );
> $('textarea#retarea').val( $('textarea#retarea').val() + 
> "\nxhr.statusText= " + xhr.statusText );
> }
> });  
> } 
>
> Here's the server side code:* json_test.py:*
> # coding: utf8
> # try something like
> def index(): return dict(message="hello from json_test.py")
>
> import sys,subprocess
> import datetime
> import gluon.contrib.simplejson
>
> def call2():
>   session.forget()
>   return service()
> 
> @service.json
> def get_days():
> return ["Sunday", "Monday", "Tuesday", "Wednesday",
>  "Thursday", "Friday", "Saturday"]
>

-- 

--- 
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: Auth with Wordpress

2013-02-07 Thread Derek
I guess you could have wordpress set a cookie of some sort if they have 
access, and then use that cookie in web2py to control access.

On Thursday, February 7, 2013 11:13:41 AM UTC-7, Kenneth wrote:
>
>  Hi Michael,
>
> Am I understanding you solution completly wrong but isn't it so that 
> web2py asks WP if a username and password compination is OK. In my case 
> customer first logs into a WP site, he gets a list of manuals he has paid 
> for. When selecting a manual he wants to read he is sent to a web2py site. 
> Somehow WP has to tell web2py that it is OK to show the site for the user. 
>
>
> Kenneth
>
>  
> Hello Kenneth,
>
>
>> But how do I handle that WP takes care of authentication and somehow 
>> gives the customer rights to view the manual. 
>>
>>  
> I had a similar problem. I added an XMLRPC method to my wordpress instance 
> to check if a given username/password combination is valid and added an 
> auth method to my web2py instance which calls that XMLRPC method.
>
> Wordpress Code:
>
>  # custom remote auth
> add_filter( 'xmlrpc_methods', 'my_add_xml_rpc_methods' );
>
> function my_add_xml_rpc_methods( $methods ) {
>   $methods['mh.testCredentials'] = 'test_credentials';
>   return $methods;
> }
>
>
> function test_credentials( $params ) {
>   
>   global $wp_xmlrpc_server;
>   
>   $blog_id  = (int) $params[0]; // not used, but follow in the form of 
> the wordpress built in XML-RPC actions
>   $username = $params[1];
>   $password = $params[2];
>   $args = $params[3];
>   
>   // verify credentials
>   if ( ! $wp_xmlrpc_server->login( $username, $password ) ) {
> return False;
>   }
>   
>
>   do_action( 'xmlrpc_call', 'mh.testCredentials' ); // patterned on the 
> core XML-RPC actions
>   
>   // return success
>   return True;
> }
>
>  This is one of the tutorials I used when coming up with this: 
> http://www.foxrunsoftware.net/articles/wordpress/extending-the-wordpress-xml-rpc-api/
>
> Now the web2py part - copy to ./gluon/contrib/login_methods/my_auth.py
>
>  from wordpress_xmlrpc import Client
> from wordpress_xmlrpc import AuthenticatedMethod
> from wordpress_xmlrpc import InvalidCredentialsError
>
>
> class GetUserInfo(AuthenticatedMethod):
> method_name = "mh.testCredentials"
>
>
>
> def my_auth(server):
> """
> to use basic login with a different server
> from gluon.contrib.login_methods.basic_auth import basic_auth
> auth.settings.login_methods.append(basic_auth('http://server'))
> """
>
> def basic_login_aux(username,
> password,server=server):
> wp = Client(server, username, password)
> retVal = None
> try:
> retVal = wp.call(GetUserInfo())
> except InvalidCredentialsError:
> return False
> return retVal
> return basic_login_aux
>
>  
>
>  Now, where you configure your auth module, add this:
>  from gluon.contrib.login_methods.my_auth import my_auth
> auth.settings.login_methods=[my_auth("http://mywordpress/xmlrpc.php";
> )] # smart people use https
> auth.settings.actions_disabled.append('register') 
>  
>
>  -- 
>  
> --- 
> 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/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: Problem with difficult query

2013-02-07 Thread Jake Lowen
I'm only talking to myself here, but the notes are helpful...

This is how I get the desired result in web2py using the executesql command:

foo = db.executesql('SELECT * FROM benchmark_targets AS t2 LEFT JOIN 
(SELECT * from lobby_report GROUP BY KPID ORDER BY datetime DESC) AS t1 ON 
t2.KPID = t1.KPID WHERE t2.benchmark = ' + str(request.args(1)))

Now if only someone could guide me to doing it the web2py way!

-- 

--- 
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 difficult query

2013-02-07 Thread Jake Lowen
Forgot the WHERE in my SQL statement. Should be: 

SELECT * FROM benchmark_targets t2 
LEFT JOIN (SELECT * from lobby_report GROUP BY KPID ORDER BY datetime 
DESC)t1 ON t2.KPID = t1.KPID 
WHERE t2.benchmark = 10;

-- 

--- 
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 difficult query

2013-02-07 Thread Jake Lowen
If it helps, here is how I can get the desired result in raw SQL:

SELECT * FROM benchmark_targets t2 LEFT JOIN (SELECT * from lobby_report 
GROUP BY KPID ORDER BY datetime DESC)t1 ON t2.KPID = t1.KPID;

Now how to do it in DAL?


-- 

--- 
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: Example JSON Code

2013-02-07 Thread pal4rp

>
> Here's the top of the html file, the Javascript function and the Python 
> file. Started using the *jsonp-2.4.0.min.js* script because it appears to 
> handle errors better.  I've just jumped into Web2py so I don't know if I'm 
> building the URL properly.
>

This returns:
*errMsg =Uncaught Error.*
*undefined*
*status =error*
*xhr.status= undefined*
*xhr.statusText= undefined *
--
{{extend 'layout.html'}}





.
.
.
function *getTest3(type)* {
var $url = "get_days";
alert("In getTest3 before jsonp call");
var dbugData = "";
$('textarea#retarea').val( $('textarea#retarea').val() + dbugData );  
*$.jsonp({*
beforeSend: alert("Before jsonp call"),
url: "get_days",
datatype: 'json',
success: function(json, textStatus, xOptions) { 
alert(json.message);//Undefined Error
$('textarea#retarea').val( $('textarea#retarea').val() + "\ntextStatus =" + 
textStatus );
$('textarea#retarea').val( $('textarea#retarea').val() + "\njson.status= " 
+ json.status );
},
error: function(xhr, status) {
var errMsg;
if (xhr.status === 0) {
errMsg ='Not connect.\n Verify Network.';
} else if (xhr.status == 404) { 
errMsg ='Requested page not found. [404]';
} else if (xhr.status == 500) { 
errMsg ='Internal Server Error [500].';
} else if (status == 'parsererror') {
errMsg ='Requested JSON parse failed.';
} else if (status == 'timeout') {
errMsg ='Time out error.';
} else if (status == 'abort') {
errMsg ='Ajax request aborted.';
} else {
errMsg ='Uncaught Error.\n' + xhr.responseText;
}
alert(errMsg); 
$('textarea#retarea').val( $('textarea#retarea').val() + "\nerrMsg =" + 
errMsg );
$('textarea#retarea').val( $('textarea#retarea').val() + "\nstatus =" + 
status );
$('textarea#retarea').val( $('textarea#retarea').val() + "\nxhr.status= " + 
xhr.status );
$('textarea#retarea').val( $('textarea#retarea').val() + "\nxhr.statusText= 
" + xhr.statusText );
}
});  
} 

Here's the server side code:* json_test.py:*
# coding: utf8
# try something like
def index(): return dict(message="hello from json_test.py")

import sys,subprocess
import datetime
import gluon.contrib.simplejson

def call2():
  session.forget()
  return service()

@service.json
def get_days():
return ["Sunday", "Monday", "Tuesday", "Wednesday",
 "Thursday", "Friday", "Saturday"]

-- 

--- 
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 difficult query

2013-02-07 Thread Jake Lowen

Thanks for a great framework. I'm loving web2py, but I just encountered a 
difficult query

One query generates a list of people.
Each of those persons has 0 to many reports filed about them.
I wanted to see only the newest report on each person AND I want to see 
Null or None if no reports have been filed.

This query almost works:

foo = db(db.benchmark_targets.benchmark == 
for_benchmark.id).select(left=db.lobby_report.on(db.lobby_report.KPID == 
db.benchmark_targets.KPID), orderby=~db.lobby_report.datetime)

but a person is listed twice if they have multiple reports filed about 
them.  If I add a groupby to the query it shows the right report but only 
people with reports filed (does not show people with 0 matching reports).

How do I see only the newest report Left outer joined to a group of people?

Thanks in advance for your help.

-- 

--- 
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 handle one-to-many relationship with sqlform and checkboxes?

2013-02-07 Thread bracquet
Nevermind, I just figured it out. I had to define the dog table prior to 
the person table. Although I thought this wouldn't be a problem according 
to the web2py book.

However, the form now displays this weird disable input box along with the 
list of dog checkboxes:





On Thursday, February 7, 2013 3:20:19 PM UTC-5, brac...@gmail.com wrote:
>
> I am getting an error when using list:reference and the checkbox widget:
>
> db.define_table('person',
> Field('name', requires=IS_NOT_EMPTY()),
> Field('dogs', 'list:reference dog'))
> db.define_table('dog',
> Field('name', requires=IS_NOT_EMPTY()))
>
>
> db.person.dogs.widget = SQLFORM.widgets.checkboxes.widget
>
> I have also tried to place the widget in the Field:
>
> Field('dogs', 'list:reference dog', 
> widget=SQLFORM.widgets.checkboxes.widget)
>
> But I get the same error:
>
>  widget cannot determine options of 
> person.dogs
> I am using (2012-10-21) stable version of web2py, if it helps.
>
> On Wednesday, February 6, 2013 4:26:26 PM UTC-5, Derek wrote:
>>
>> It's a list:reference field then, look at the reference in chapter 6: the 
>> database abstraction layer
>>
>> On Wednesday, February 6, 2013 2:09:50 PM UTC-7, brac...@gmail.com wrote:
>>>
>>> Hello, I was reading about the "Links to referencing 
>>> records"  
>>> part in the online guide, but was confused how I would deal with custom 
>>> logic of inserting it to the database. The guide seems to already have the 
>>> values in the database to pull from. 
>>>
>>> If we take the person and dog database in the example, a person can own 
>>> many dogs, but a dog can only have one owner. 
>>>
>>> If we take the example one step further and say we're running an animal 
>>> shelter, we would have a list of people and a list of dogs, but we don't 
>>> have the connection between the two. If a person wants to adopt a dog, 
>>> they'll use a form which will have the following elements:
>>>
>>> Textfield for the person's name. 
>>> A list of checkboxes with the dog's name.
>>>
>>> Then upon successful form submission, the selected dogs are linked to a 
>>> person.
>>>
>>> I don't quite understand how the form is built using "form = 
>>> SQLFORM(db.person)" in this scenario. 
>>>
>>> Since SQLFORM builds its own html, how would web2py handle the dog 
>>> object? By default, it will probably use a textfield because the dog has a 
>>> String name, but what about the owner reference? Furthermore, the dog has 
>>> to be treated as a boolean since we are simply asking if this dog should 
>>> belong to the human listed on the form or not. I can't quite picture how 
>>> "SQLFORM.widgets.boolean.widget" 
>>> since a dog isn't a boolean value tied to a person. It's its own entity 
>>> with a name and an owner.
>>>
>>> The only way I can think of to solve this is to NOT use SQLFORM, but 
>>> rather SQLFORM.factory(). Then I would use "{{=form.custom.begin/end}}" to 
>>> manually format the form, create the Textfield for the person name, and 
>>> generate the checkboxes in a for loop given the list of dog names. When the 
>>> form passes basic validation with form.accepted, I would grab the person's 
>>> id and update the entry for all dogs that are returned checked. 
>>>
>>> Do I have the right idea or am I misunderstanding web2py design? Is 
>>> there an easier way to handle one-to-many relationships through a form?
>>>
>>>

-- 

--- 
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: Auth with Wordpress

2013-02-07 Thread Michael Haas



Am Donnerstag, 7. Februar 2013 19:13:41 UTC+1 schrieb Kenneth: 
>
> Am I understanding you solution completly wrong but isn't it so that 
> web2py asks WP if a username and password compination is OK. In my case 
> customer first logs into a WP site, he gets a list of manuals he has paid 
> for. When selecting a manual he wants to read he is sent to a web2py site. 
> Somehow WP has to tell web2py that it is OK to show the site for the user. 
>
>
> Kenneth
>
>
> Hi Kenneth,

you are right, my solution won't do that. I was basically facing a similar 
problem and decided to just make the user log in again. Some kind of single 
log-in scheme or session sharing would be nice, but that's out of my depth.

-- 

--- 
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 handle one-to-many relationship with sqlform and checkboxes?

2013-02-07 Thread bracquet
I am getting an error when using list:reference and the checkbox widget:

db.define_table('person',
Field('name', requires=IS_NOT_EMPTY()),
Field('dogs', 'list:reference dog'))
db.define_table('dog',
Field('name', requires=IS_NOT_EMPTY()))


db.person.dogs.widget = SQLFORM.widgets.checkboxes.widget

I have also tried to place the widget in the Field:

Field('dogs', 'list:reference dog', 
widget=SQLFORM.widgets.checkboxes.widget)

But I get the same error:

 widget cannot determine options of 
person.dogs
I am using (2012-10-21) stable version of web2py, if it helps.

On Wednesday, February 6, 2013 4:26:26 PM UTC-5, Derek wrote:
>
> It's a list:reference field then, look at the reference in chapter 6: the 
> database abstraction layer
>
> On Wednesday, February 6, 2013 2:09:50 PM UTC-7, brac...@gmail.com wrote:
>>
>> Hello, I was reading about the "Links to referencing 
>> records"  
>> part in the online guide, but was confused how I would deal with custom 
>> logic of inserting it to the database. The guide seems to already have the 
>> values in the database to pull from. 
>>
>> If we take the person and dog database in the example, a person can own 
>> many dogs, but a dog can only have one owner. 
>>
>> If we take the example one step further and say we're running an animal 
>> shelter, we would have a list of people and a list of dogs, but we don't 
>> have the connection between the two. If a person wants to adopt a dog, 
>> they'll use a form which will have the following elements:
>>
>> Textfield for the person's name. 
>> A list of checkboxes with the dog's name.
>>
>> Then upon successful form submission, the selected dogs are linked to a 
>> person.
>>
>> I don't quite understand how the form is built using "form = 
>> SQLFORM(db.person)" in this scenario. 
>>
>> Since SQLFORM builds its own html, how would web2py handle the dog 
>> object? By default, it will probably use a textfield because the dog has a 
>> String name, but what about the owner reference? Furthermore, the dog has 
>> to be treated as a boolean since we are simply asking if this dog should 
>> belong to the human listed on the form or not. I can't quite picture how 
>> "SQLFORM.widgets.boolean.widget" 
>> since a dog isn't a boolean value tied to a person. It's its own entity 
>> with a name and an owner.
>>
>> The only way I can think of to solve this is to NOT use SQLFORM, but 
>> rather SQLFORM.factory(). Then I would use "{{=form.custom.begin/end}}" to 
>> manually format the form, create the Textfield for the person name, and 
>> generate the checkboxes in a for loop given the list of dog names. When the 
>> form passes basic validation with form.accepted, I would grab the person's 
>> id and update the entry for all dogs that are returned checked. 
>>
>> Do I have the right idea or am I misunderstanding web2py design? Is there 
>> an easier way to handle one-to-many relationships through a form?
>>
>>

-- 

--- 
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] Upgrading web2py 1.99.7 to 2.3.2 on ubuntu

2013-02-07 Thread Niphlod
ideally you should have 2 locations (your choice for them to be 
domain-related or "folder" related , i.e. domain.com/domain2.com vs 
domain.com/first/ domain.com/second) and have separate wsgiscriptaliase 
directives, one pointing to "old" and the other pointing to "new" web2py 
folders.

On Thursday, February 7, 2013 7:59:15 PM UTC+1, at wrote:
>
>
> Thanks for your reply.
>
> Actually we want to keep apache+ssl+mod_wsgi+postgres installations as 
> they are. Keeping them unchanged what should be the right approach to run 
> same applications side-by-side on both old and new versions of web2py?
> Our servers are in amazon cloud.
>
> Thanks & Regards
>
>
> On Thursday, 7 February 2013 19:37:16 UTC+5, Richard wrote:
>>
>> Do you have a limitation, why would you put 2 version of web2py on the 
>> same machine... I would create an other VM with the new stuff!
>>
>> You could use the same database if you want pointing the postgres of the 
>> old version of web2py...
>>
>> Richard
>>
>>
>> On Thu, Feb 7, 2013 at 4:06 AM, at  wrote:
>>
>>> Hi,
>>>
>>> Currenty we are usnig web2py (1.99.7) + apache + ssl + mod_wsgi + 
>>> postgresql on ubuntu on production and development servers.
>>> Before we upgrade to latest stable version i.e. 2.3.2 on production, we 
>>> want to run both old and latest versions side-by-side on development 
>>> servers. What should be the best and clean way to accomplish it?
>>>
>>> Thanks,
>>> AT
>>>
>>>  -- 
>>>  
>>> --- 
>>> 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/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] Re: how to support video in an app

2013-02-07 Thread Tito Garrido
How to set the width and height of the embed video using expand_one?


On Sat, Feb 2, 2013 at 12:00 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Sorry my bad:
>
> {{=XML(expand_one('http://www.**youtube.com/watch?v=**
> 7yvt2Pt6LRA',cache.ram('**mycache',lambda:dict(),3600))
> )}**}
>
> expand one converts to HTML but then is must be wrapped into XML else it
> gets escaped.
>
>
> On Friday, 1 February 2013 19:10:12 UTC-6, sasogeek wrote:
>>
>> when the page loads and i click on view page source, here's what's
>> there...
>>
>>