[web2py] Getting error: DLL load failed: The operating system cannot run %1

2012-07-26 Thread Amit
 

I Have installed python 2.7.2 and M2Crypto-0.21.1-py2.7.egg-info in my 
Windows XP SP3 machine and wherever i am using import statement:

from M2Crypto import X509,ASN1,Rand,EVP,RSA its throwing error 

* DLL load failed: The operating system cannot run %1.*

it seems like M2Crypto version is not supported with Python2.7.2 and 
windows XP SP3. In addition to that I am using 
pyOpenSSL-0.13.winxp32-py2.7.msi for openSSL.

Can anybody help me resolve this problem?

-- 





[web2py] Can't run web2py because of socket.gethostbyname problem

2012-07-26 Thread pbreit
This change is preventing me from starting web2py because of a problem 
with socket.gethostbyname():
http://code.google.com/p/web2py/source/detail?r=36139e7a6c9c14983e0d09f626959beb8fcf9320

I'm on a Mac where I'm not exactly sure how hostnaming 
works. socket.getfqdn() is returning some weird stuff, possibly IPv6 
addresses.

Right now, socket.getfqdn() returns 'pb-dev' which socket.gethostbyname_ex 
is choking on. I tried changing the HostName with scutil but got an even 
weirded 
hostname: 
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

Note, this is on Mountain Lion with Xcode 4.4 installed.


Traceback (most recent call last):
  File "web2py.py", line 25, in 
gluon.widget.start(cron=True)
  File "/Users/pbreit/web2py/gluon/widget.py", line 895, in start
(options, args) = console()
  File "/Users/pbreit/web2py/gluon/widget.py", line 803, in console
options.ips = [ip for ip in socket.gethostbyname_ex(socket.getfqdn())[2]
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

-- 





[web2py] Re: Referencing user results in syntax-error?

2012-07-26 Thread Alec Taylor
On Friday, July 27, 2012 6:45:04 AM UTC+10, Massimo Di Pierro wrote:
>
> Person cannot be not null and default to auth.user_id which likely is null.
>
> It also cannot defaul to auth.user.
>
> Use the second line and remove notnull
>
Thanks, but that gave me the same error.

Full ticket: http://jsfiddle.net/FG4pC/show/light/ 

-- 





Re: [web2py] Re: Visit Plugow on FISL13

2012-07-26 Thread Annet
Hi Vinicius,

Thanks for your reply. I hope your presentation went well. 

Keep in touch. 
>

I will, thanks.


Annet

-- 





[web2py] Re: field of type upload exceptions.UnboundLocalError

2012-07-26 Thread Annet
Massimo,

elif field.type == 'upload':
f = self.vars[fieldname]
print f
fd = '%s__delete' % fieldname
...
newfilename = field.store(source_file, original_filename, 
field.uploadfolder)

When I submit the form with the upload field left empty, nothing is being 
written to the shell.

I also tried adding print 'myName', but that isn't being written to the 
shell either, not even when
I make it the first statement in the accepts function.

The first time 'myName' is written to the shell is when I add the print 
statement in appadmin.py
at line 128 right after form = SQLFORM(db[table], ignore_rw=ignore_rw)

What else can I do to help you debug this issue?


Annet.

-- 





Re: [web2py] Accessing static file with consecutive hypens in filename.

2012-07-26 Thread Jonathan Lundell
On 26 Jul 2012, at 8:50 PM, Mark Li  wrote:
> I have a static file named 

> 
> person---dog-3.jpg
> 
> When I try to access the file through 
> http://127.0.0.1:8000/myapp/static/pets/person---dog-3.jpg
> I get an "invalid request" error.
> 
> However, if I rename the file to person-dog-3.jpg, it works fine.
> I have a very large number of files named this way (with consecutive 
> hyphens), and it worked fine on other sites, just not working for web2py. Any 
> idea how I can make this work without renaming all the files?

It's a legacy web2py thing. If you use the parametric router, you can redefine 
the relevant regex in your app's router, changing

file_match = r'(\w+[-=./]?)+$',# legal file (path) name

to

file_match = r'([-=\w]+[./]?)+$',# legal file (path) name

or something like it.

-- 





[web2py] Accessing static file with consecutive hypens in filename.

2012-07-26 Thread Mark Li
I have a static file named 

person---dog-3.jpg

When I try to access the file through 
http://127.0.0.1:8000/myapp/static/pets/person---dog-3.jpg
I get an "invalid request" error.

However, if I rename the file to person-dog-3.jpg, it works fine.
I have a very large number of files named this way (with consecutive 
hyphens), and it worked fine on other sites, just not working for web2py. 
Any idea how I can make this work without renaming all the files?

-- 





[web2py] web2py on appfog

2012-07-26 Thread Joel Carrier
Has anyone tried running web2py on appfog ( www.appfog.com ) and cares to 
comment on their experience?

-- 





Re: [web2py] Re: JSON output with referencing data

2012-07-26 Thread Jaymin Oh
Oh my... u r right. I just forgot about JOIN.

Or... only to retrive tag name when request, is it good idea to store
tag.name with tag.id to reduce JOIN overhead? (I ONLY need tag name)
On Jul 27, 2012 7:59 AM, "Michele Comitini" 
wrote:

> Why not doing a join on team, auth_user and tags with DAL and then put
> the needed field as arg of the .select() method?
>   The overhead would be minimal.
>
> mic
>
>
> 2012/7/27 Jaymin Oh :
> > Thanks, Massimo!
> >
> > On Thu, Jul 26, 2012 at 6:34 PM, Massimo Di Pierro
> >  wrote:
> >>
> >> before you serialize rows in json, you can do:
> >>
> >> for row in rows: row.tag_names = [db.tag[id].name for is in row.tags]
> >>
> >> This will be not efficient. depends on how many rows. Perhaps you can
> find
> >> a faster way to do the conversion.
> >>
> >>
> >> On Wednesday, 25 July 2012 23:32:58 UTC-5, Jaymin Oh wrote:
> >>>
> >>> Hi, I'm Korean Web2py user.
> >>>
> >>>
> >>> I'm returning output of DB select like 'return dict(teams=teams)'.
> >>>
> >>>
> >>> {"teams": [{"status": "active", "updated_by": 1, "tags": [12], "max":
> 4,
> >>> "created_by": 1, }]}
> >>>
> >>>
> >>> The above output is my output of 'teams' controller.
> >>>
> >>>
> >>> I have several referencing column, 'tags' and 'created_by'.
> >>>
> >>>
> >>> 'tags' references tag table and created_by references auth table.
> >>>
> >>>
> >>> But I want to add name for 'tags' which exists in 'tag table' and email
> >>> for 'created_by' with ID which is already revealed in output.
> >>>
> >>>
> >>> Any help?
> >>>
> >>>
> >>> Thanks for your help in advance.
> >>>
> >>>
> >>> J.Min Oh.
> >>>
> >>>
> >>>
> >> --
> >>
> >>
> >>
> >
> >
> >
> >
> > --
> > J.Min, Oh,
> > M.S Candidate in Department of Knowledge Service Engineering,
> > Korea Advanced Institute of Science and Technology
> > +82-10-2711-1357 / +82-70-7529-8904
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Re: JSON output with referencing data

2012-07-26 Thread Michele Comitini
Why not doing a join on team, auth_user and tags with DAL and then put
the needed field as arg of the .select() method?
  The overhead would be minimal.

mic


2012/7/27 Jaymin Oh :
> Thanks, Massimo!
>
> On Thu, Jul 26, 2012 at 6:34 PM, Massimo Di Pierro
>  wrote:
>>
>> before you serialize rows in json, you can do:
>>
>> for row in rows: row.tag_names = [db.tag[id].name for is in row.tags]
>>
>> This will be not efficient. depends on how many rows. Perhaps you can find
>> a faster way to do the conversion.
>>
>>
>> On Wednesday, 25 July 2012 23:32:58 UTC-5, Jaymin Oh wrote:
>>>
>>> Hi, I'm Korean Web2py user.
>>>
>>>
>>> I'm returning output of DB select like 'return dict(teams=teams)'.
>>>
>>>
>>> {"teams": [{"status": "active", "updated_by": 1, "tags": [12], "max": 4,
>>> "created_by": 1, }]}
>>>
>>>
>>> The above output is my output of 'teams' controller.
>>>
>>>
>>> I have several referencing column, 'tags' and 'created_by'.
>>>
>>>
>>> 'tags' references tag table and created_by references auth table.
>>>
>>>
>>> But I want to add name for 'tags' which exists in 'tag table' and email
>>> for 'created_by' with ID which is already revealed in output.
>>>
>>>
>>> Any help?
>>>
>>>
>>> Thanks for your help in advance.
>>>
>>>
>>> J.Min Oh.
>>>
>>>
>>>
>> --
>>
>>
>>
>
>
>
>
> --
> J.Min, Oh,
> M.S Candidate in Department of Knowledge Service Engineering,
> Korea Advanced Institute of Science and Technology
> +82-10-2711-1357 / +82-70-7529-8904
>
> --
>
>
>

-- 





Re: [web2py] Re: JSON output with referencing data

2012-07-26 Thread Jaymin Oh
Thanks, Massimo!

On Thu, Jul 26, 2012 at 6:34 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> before you serialize rows in json, you can do:
>
> for row in rows: row.tag_names = [db.tag[id].name for is in row.tags]
>
> This will be not efficient. depends on how many rows. Perhaps you can find
> a faster way to do the conversion.
>
>
> On Wednesday, 25 July 2012 23:32:58 UTC-5, Jaymin Oh wrote:
>>
>> Hi, I'm Korean Web2py user.
>>
>>
>> I'm returning output of DB select like 'return dict(teams=teams)'.
>>
>>
>> {"teams": [{"status": "active", "updated_by": 1, "tags": [12], "max": 4, 
>> "created_by": 1, }]}
>>
>>
>> The above output is my output of 'teams' controller.
>>
>>
>> I have several referencing column, 'tags' and 'created_by'.
>>
>>
>> 'tags' references *tag table* and created_by references *auth table.*
>>
>> *
>> *
>>
>> But I want to add name for 'tags' which exists in 'tag table' and email for 
>> 'created_by' with ID which is already revealed in output.
>>
>>
>> Any help?
>>
>>
>> Thanks for your help in advance.
>>
>>
>> J.Min Oh.
>>
>>
>>
>>  --
>
>
>
>



-- 
J.Min, Oh,
M.S Candidate in Department of Knowledge Service Engineering,
*Korea Advanced Institute of Science and Technology*
+82-10-2711-1357 / +82-70-7529-8904

-- 





[web2py] Re: Select Distinct for more than 1 distinct value

2012-07-26 Thread Derek
Usually, when you are asking these kind of questions, you come to realize 
you are asking the wrong question.

On Monday, July 23, 2012 3:15:14 PM UTC-7, Mark Li wrote:
>
> I have a database setup with id and 'dogname.' I would like to retrieve 
> distinct values of dogname, but allow for 2 of each dogname. So instead of 
> limiting it to one distinct value, there could be 2 identical dognames that 
> are retrieved, but no more than that.
>
> Is there a way to set this kind of limit for distinct?
>

-- 





Re: [web2py] markmin embed:http://... not work trunk version

2012-07-26 Thread Massimo Di Pierro
Before you change it, let me think about this some more...

On Thursday, 26 July 2012 17:03:35 UTC-5, dbdeveloper wrote:
>
>  well, give me an example of correct iframe and embed output and I'll 
> change markmin. ok?
>
> Vladyslav Kozlovskyy (Ukraine)
>
> 26.07.12 16:40, Jose написав(ла):
>  
>
>
> El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió: 
>>
>>  Hi, Jose!
>>
>> try 'iframe' instead of 'embed':
>>
>> iframe:http://www.youtube.com/embed/x1w8hKTJ2Co
>>  
>
>  Ok Vladyslav, but I think the same as Massimo, this breaks backwards 
> compatibility.
>
>  Jose
> -- 
>  
>  
>  
>
>
>
>
> 

-- 





[web2py] import_from_csv_file with validation

2012-07-26 Thread Mark Li
Is there something like validate_and_insert()  for import_from_csv_file()? 
I would like to update my database with csv files, but have the form 
validators fired to ensure that the data inserted is of the correct type.

-- 





[web2py] Re: Changing a function variable from a view

2012-07-26 Thread adohertyd
Thank you very much Anthony that's a great help. Do you know where in the 
manual/other documentation this kind of thing is? I couldn't find it 
anywhere. All I could find on the net was jQuery and ajax stuff 

On Thursday, 26 July 2012 23:11:16 UTC+1, Anthony wrote:
>
> When you build the links, do something like:
>
> {{for suggestion in suggestions:}}
> {{=LI(A(suggestion, _href=URL('default', 'resultsDisplay', vars=dict(
> userQuery=suggestion}}
> {{pass}}
>
> That will give you URLs like 
> /yourapp/default/resultsDisplay?userQuery=suggestion. The suggestion will 
> then be accessible as request.vars.userQuery in the resultsDisplay function.
>
> Anthony
>
> On Thursday, July 26, 2012 5:52:34 PM UTC-4, adohertyd wrote:
>>
>> How do I assign the query value to the request.vars? I'm ok with checking 
>> for it in the function, but how do I pass the request.vars to the function 
>> first??
>>
>> On Thursday, 26 July 2012 22:31:54 UTC+1, Anthony wrote:
>>>
>>> Construct the links so they contain a query string with the new 
>>> userQuery. In the resultsDisplay function, check for a userQuery in 
>>> request.vars, and if present, process that value instead of processing 
>>> session.userQuery.
>>>
>>> Anthony
>>>
>>> On Thursday, July 26, 2012 4:21:22 PM UTC-4, adohertyd wrote:

 I posted a related question earlier but given the response I don't 
 think my question was clear. My index page contains a form and the index() 
 function assigns the user input in this form to a variable: 
 session.userQuery

 session.userquery is then processed in resultsDisplay() and sent to a 
 number of API's. The data returned from these API's is processed and 
 displayed on resultsDisplay.html. On results.html the user is given 
 suggestions for an alternative term. This is where my query lies.

 I want the generated suggestions to be clickable links that will 
 restart the resultsDisplay() function with the clicked term as the new 
 session.userQuery value. The results generated will then be relative to 
 the 
 new term. I hope this makes sense. As I've said, it's like when a user 
 misspells a word in Google and they ask "Did you mean" and when you 
 click the suggested term, the suggested term replaces the user's original 
 input.

 *def index():*
   
   #assigns user input to session.userQuery


 *def resultsDisplay():*

  #processes session.userQuery
 #sends processed string to number of API's
 #processes API returns
 #returns data


 *resultsDisplay.html: *  
  
  Results:

  results 
   

  Suggestions:

 >>> "suggestion"> suggestions 




-- 





[web2py] Re: Changing a function variable from a view

2012-07-26 Thread Anthony
When you build the links, do something like:

{{for suggestion in suggestions:}}
{{=LI(A(suggestion, _href=URL('default', 'resultsDisplay', 
vars=dict(userQuery=suggestion}}
{{pass}}

That will give you URLs like 
/yourapp/default/resultsDisplay?userQuery=suggestion. The suggestion will 
then be accessible as request.vars.userQuery in the resultsDisplay function.

Anthony

On Thursday, July 26, 2012 5:52:34 PM UTC-4, adohertyd wrote:
>
> How do I assign the query value to the request.vars? I'm ok with checking 
> for it in the function, but how do I pass the request.vars to the function 
> first??
>
> On Thursday, 26 July 2012 22:31:54 UTC+1, Anthony wrote:
>>
>> Construct the links so they contain a query string with the new 
>> userQuery. In the resultsDisplay function, check for a userQuery in 
>> request.vars, and if present, process that value instead of processing 
>> session.userQuery.
>>
>> Anthony
>>
>> On Thursday, July 26, 2012 4:21:22 PM UTC-4, adohertyd wrote:
>>>
>>> I posted a related question earlier but given the response I don't think 
>>> my question was clear. My index page contains a form and the index() 
>>> function assigns the user input in this form to a variable: 
>>> session.userQuery
>>>
>>> session.userquery is then processed in resultsDisplay() and sent to a 
>>> number of API's. The data returned from these API's is processed and 
>>> displayed on resultsDisplay.html. On results.html the user is given 
>>> suggestions for an alternative term. This is where my query lies.
>>>
>>> I want the generated suggestions to be clickable links that will restart 
>>> the resultsDisplay() function with the clicked term as the new 
>>> session.userQuery value. The results generated will then be relative to the 
>>> new term. I hope this makes sense. As I've said, it's like when a user 
>>> misspells a word in Google and they ask "Did you mean" and when you 
>>> click the suggested term, the suggested term replaces the user's original 
>>> input.
>>>
>>> *def index():*
>>>   
>>>   #assigns user input to session.userQuery
>>>
>>>
>>> *def resultsDisplay():*
>>>
>>>  #processes session.userQuery
>>> #sends processed string to number of API's
>>> #processes API returns
>>> #returns data
>>>
>>>
>>> *resultsDisplay.html: *  
>>>  
>>>  Results:
>>>
>>>  results 
>>>   
>>>
>>>  Suggestions:
>>>
>>> >> "suggestion"> suggestions 
>>>
>>>
>>>

-- 





Re: [web2py] markmin embed:http://... not work trunk version

2012-07-26 Thread Vladyslav Kozlovskyy
well, give me an example of correct iframe and embed output and I'll change 
markmin. ok?


Vladyslav Kozlovskyy (Ukraine)

26.07.12 16:40, Jose ???(??):



El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió:

Hi, Jose!

try 'iframe' instead of 'embed':

iframe:http://www.youtube.com/embed/x1w8hKTJ2Co



Ok Vladyslav, but I think the same as Massimo, this breaks backwards 
compatibility.


Jose
--







--





[web2py] Re: Changing a function variable from a view

2012-07-26 Thread adohertyd
How do I assign the query value to the request.vars? I'm ok with checking 
for it in the function, but how do I pass the request.vars to the function 
first??

On Thursday, 26 July 2012 22:31:54 UTC+1, Anthony wrote:
>
> Construct the links so they contain a query string with the new userQuery. 
> In the resultsDisplay function, check for a userQuery in request.vars, and 
> if present, process that value instead of processing session.userQuery.
>
> Anthony
>
> On Thursday, July 26, 2012 4:21:22 PM UTC-4, adohertyd wrote:
>>
>> I posted a related question earlier but given the response I don't think 
>> my question was clear. My index page contains a form and the index() 
>> function assigns the user input in this form to a variable: 
>> session.userQuery
>>
>> session.userquery is then processed in resultsDisplay() and sent to a 
>> number of API's. The data returned from these API's is processed and 
>> displayed on resultsDisplay.html. On results.html the user is given 
>> suggestions for an alternative term. This is where my query lies.
>>
>> I want the generated suggestions to be clickable links that will restart 
>> the resultsDisplay() function with the clicked term as the new 
>> session.userQuery value. The results generated will then be relative to the 
>> new term. I hope this makes sense. As I've said, it's like when a user 
>> misspells a word in Google and they ask "Did you mean" and when you 
>> click the suggested term, the suggested term replaces the user's original 
>> input.
>>
>> *def index():*
>>   
>>   #assigns user input to session.userQuery
>>
>>
>> *def resultsDisplay():*
>>
>>  #processes session.userQuery
>> #sends processed string to number of API's
>> #processes API returns
>> #returns data
>>
>>
>> *resultsDisplay.html: *  
>>  
>>  Results:
>>
>>  results 
>>   
>>
>>  Suggestions:
>>
>> > "suggestion"> suggestions 
>>
>>
>>

-- 





Re: [web2py] prettydate question

2012-07-26 Thread Vladyslav Kozlovskyy

25.07.12 16:52, ctrlSoft написав(ла):
browser is set up to english, but in model i do T.force('ro'). without forced 
translation result is the same --






please do these steps and post the result here:

1. add test() function into applicatons/welcome/controllers/default.py:

def test():
import datetime
d=datetime.datetime.strptime('2012-07-18 10:00:00', '%Y-%m-%d %H:%M:%S')
T.force('ro')
return locals()

2. copy test.html (see attachment) into 
applications/welcome/views/default/test.html

3. open page http://127.0.0.1:8000/welcome/default/test and post the output here

Vladyslav Kozlovskyy

--



{{extend 'layout.html'}}
Prettydate test

now:{{=prettydate(datetime.datetime.now(),T)}}

{{=prettydate(d,T)}}



{{for year in xrange(2000,2013):}}
  {{dd=datetime.datetime.strptime('%s-07-01 10:00:00'%year, '%Y-%m-%d %H:%M:%S')}}
  {{=prettydate(dd,T)}}
{{pass}}



{{for month in xrange(1,8):}}
  {{dd=datetime.datetime.strptime('2012-%s-01 10:00:00'%month, '%Y-%m-%d %H:%M:%S')}}
  {{=prettydate(dd,T)}}
{{pass}}



{{for day in xrange(1,31):}}
  {{dd=datetime.datetime.strptime('2012-07-%s 10:00:00'%day, '%Y-%m-%d %H:%M:%S')}}
  {{=prettydate(dd,T)}}
{{pass}}



{{=BEAUTIFY(response._vars)}}


[web2py] Re: Changing a function variable from a view

2012-07-26 Thread Anthony
Construct the links so they contain a query string with the new userQuery. 
In the resultsDisplay function, check for a userQuery in request.vars, and 
if present, process that value instead of processing session.userQuery.

Anthony

On Thursday, July 26, 2012 4:21:22 PM UTC-4, adohertyd wrote:
>
> I posted a related question earlier but given the response I don't think 
> my question was clear. My index page contains a form and the index() 
> function assigns the user input in this form to a variable: 
> session.userQuery
>
> session.userquery is then processed in resultsDisplay() and sent to a 
> number of API's. The data returned from these API's is processed and 
> displayed on resultsDisplay.html. On results.html the user is given 
> suggestions for an alternative term. This is where my query lies.
>
> I want the generated suggestions to be clickable links that will restart 
> the resultsDisplay() function with the clicked term as the new 
> session.userQuery value. The results generated will then be relative to the 
> new term. I hope this makes sense. As I've said, it's like when a user 
> misspells a word in Google and they ask "Did you mean" and when you 
> click the suggested term, the suggested term replaces the user's original 
> input.
>
> *def index():*
>   
>   #assigns user input to session.userQuery
>
>
> *def resultsDisplay():*
>
>  #processes session.userQuery
> #sends processed string to number of API's
> #processes API returns
> #returns data
>
>
> *resultsDisplay.html: *  
>  
>  Results:
>
>  results 
>   
>
>  Suggestions:
>
>  "suggestion"> suggestions 
>
>
>

-- 





[web2py] Re: bootstrap and user panel

2012-07-26 Thread Omi Chiba
+1

On Monday, July 23, 2012 7:02:47 PM UTC-5, Martin.Mulone wrote:
>
> I want to share this two applications*
>
> Bootstrap welcome application*
>
> I made my own welcome scatfold app, using twitter bootstrap template. My 
> version is more like from the example template. 
> Download: https://bitbucket.org/mulonemartin/bootstrap/overview also you 
> can test here .
>
> *User Panel Admin*
>
> An application to administer the auth_user table. You can add, remove, 
> activate users/ add groups, also add users to groups and so on. 
> https://bitbucket.org/mulonemartin/usersadmin
>
>
>
>

-- 





[web2py] Referencing user results in syntax-error?

2012-07-26 Thread Massimo Di Pierro
Person cannot be not null and default to auth.user_id which likely is null.

It also cannot defaul to auth.user.

Use the second line and remove notnull

-- 





[web2py] Referencing user results in syntax-error?

2012-07-26 Thread Alec Taylor
I checked the documentation to make sure, and either one of the commented 
out lines works, but I keep getting this:
 near ".": syntax errorIt one (well both) 
of the commented out lines that give this error, because commenting them 
out makes the error go away.

db.define_table(
'rsvp_list',
Field('rsvp', notnull=True, requires=IS_IN_SET('Yes', 'Maybe', 'No')),
Field('event_id', 'reference db.event', notnull=True, requires=IS_IN_DB(db, 
db.event, '%(event_name)s [%(id)%]')),
#Field("person", db.auth_user, default=auth.user if auth.user else None)
#Field('person', db.auth_user, notnull=True, default=auth.user_id))


How can I get this working?

Thanks for all suggestions,

Alec Taylor

-- 





[web2py] Re: installing mssql drivers

2012-07-26 Thread Derek
It should work just fine if you are using the source build. Don't use the 
win32 version of web2py.

On Thursday, July 26, 2012 12:32:37 PM UTC-7, jcrowe wrote:
>
> Are there any docs on how to install pyodbc to work with web2py. I have it 
> installed in my windows python installation, but that doesn't seem to work 
> with web2py.
>
> Any pointers would be greatly appreciated. :)
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Derek
ah, nevermind. yes, please implement it.

On Thursday, July 26, 2012 1:22:46 PM UTC-7, Derek wrote:
>
> Well, since BR is a subclass of DIV, and DIV overrides the __add__ as 
> "%s%s" self, other - it should work without modification, no?
>
> On Thursday, July 26, 2012 12:43:35 PM UTC-7, Massimo Di Pierro wrote:
>>
>> We can also implement BR()+BR().  how about DIV(...)-BR()? What do you 
>> think it should do?
>>
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Derek
Well, since BR is a subclass of DIV, and DIV overrides the __add__ as 
"%s%s" self, other - it should work without modification, no?

On Thursday, July 26, 2012 12:43:35 PM UTC-7, Massimo Di Pierro wrote:
>
> We can also implement BR()+BR().  how about DIV(...)-BR()? What do you 
> think it should do?
>

-- 





[web2py] Changing a function variable from a view

2012-07-26 Thread adohertyd
I posted a related question earlier but given the response I don't think my 
question was clear. My index page contains a form and the index() function 
assigns the user input in this form to a variable: session.userQuery

session.userquery is then processed in resultsDisplay() and sent to a 
number of API's. The data returned from these API's is processed and 
displayed on resultsDisplay.html. On results.html the user is given 
suggestions for an alternative term. This is where my query lies.

I want the generated suggestions to be clickable links that will restart 
the resultsDisplay() function with the clicked term as the new 
session.userQuery value. The results generated will then be relative to the 
new term. I hope this makes sense. As I've said, it's like when a user 
misspells a word in Google and they ask "Did you mean" and when you 
click the suggested term, the suggested term replaces the user's original 
input.

*def index():*
  
  #assigns user input to session.userQuery


*def resultsDisplay():*
   
 #processes session.userQuery
#sends processed string to number of API's
#processes API returns
#returns data


*resultsDisplay.html: *  
 
 Results:
   
 results 
  

 Suggestions:
   
 suggestions 
   

-- 





Re: [web2py] Re: bootstrap and user panel

2012-07-26 Thread Martín Mulone
It's a bug I think, but it's related to windows perhaps.

have to be:

from gluon.sqlhtml import SQLFORM

the strange that this is working in linux:

from sqlhtml import SQLFORM

fixed in trunk.

2012/7/26 Nomad 

>
>
> On Monday, July 23, 2012 7:02:47 PM UTC-5, Martin.Mulone wrote:
>
>> I want to share this two applications*
>>
>> Bootstrap welcome application*
>>
>> I made my own welcome scatfold app, using twitter bootstrap template. My
>> version is more like from the example template.
>> Download: 
>> https://bitbucket.org/**mulonemartin/bootstrap/**overviewalso
>>  you can test
>> here .
>>
>> *User Panel Admin*
>>
>> An application to administer the auth_user table. You can add, remove,
>> activate users/ add groups, also add users to groups and so on.
>> https://bitbucket.org/**mulonemartin/usersadmin
>>
>>
>>
>>  --
>
>
>
>



-- 
 http://www.tecnodoc.com.ar

-- 





[web2py] Re: bootstrap and user panel

2012-07-26 Thread Nomad


On Monday, July 23, 2012 7:02:47 PM UTC-5, Martin.Mulone wrote:
>
> I want to share this two applications*
>
> Bootstrap welcome application*
>
> I made my own welcome scatfold app, using twitter bootstrap template. My 
> version is more like from the example template. 
> Download: https://bitbucket.org/mulonemartin/bootstrap/overview also you 
> can test here .
>
> *User Panel Admin*
>
> An application to administer the auth_user table. You can add, remove, 
> activate users/ add groups, also add users to groups and so on. 
> https://bitbucket.org/mulonemartin/usersadmin
>
>
>
>

-- 





[web2py] Re: bootstrap and user panel

2012-07-26 Thread Nomad
I am trying this with the nightly build (since it didnt work in stable) and 
get the following exception
Is this just related to the windows build ? please advise. 

web2py™(2, 0, 0, datetime.datetime(2012, 7, 26, 13, 52, 14), 'dev')PythonPython 
2.7: C:\web2py\web2pynew\web2py\web2py.exeTRACEBACK

1.
2.
3.
4.
5.
6.

Traceback (most recent call last):
  File "gluon/restricted.py", line 205, in restricted
  File 
"C:/web2py/web2pynew/web2py/applications/tsowelcometest/models/00main.py" 
, 
line 10, in 
  File "gluon/custom_import.py", line 295, in __call__
ImportError: No module named sqlhtml

ERROR SNAPSHOT [image: help]

(No module named sqlhtml)

On Thursday, July 26, 2012 2:56:10 PM UTC-5, Nomad wrote:
>
>
>
> On Monday, July 23, 2012 7:02:47 PM UTC-5, Martin.Mulone wrote:
>>
>> I want to share this two applications*
>>
>> Bootstrap welcome application*
>>
>> I made my own welcome scatfold app, using twitter bootstrap template. My 
>> version is more like from the example template. 
>> Download: https://bitbucket.org/mulonemartin/bootstrap/overview also you 
>> can test here .
>>
>> *User Panel Admin*
>>
>> An application to administer the auth_user table. You can add, remove, 
>> activate users/ add groups, also add users to groups and so on. 
>> https://bitbucket.org/mulonemartin/usersadmin
>>
>>
>>
>>

-- 





Re: [web2py] web2py windows build broken in nightly

2012-07-26 Thread Massimo Di Pierro
Many thanks to niphlod and marin for their help with windows. Anyway please 
test it since we switched from 2.5 to 2.7

-- 





[web2py] Re: bootstrap and user panel

2012-07-26 Thread Nomad


On Monday, July 23, 2012 7:02:47 PM UTC-5, Martin.Mulone wrote:
>
> I want to share this two applications*
>
> Bootstrap welcome application*
>
> I made my own welcome scatfold app, using twitter bootstrap template. My 
> version is more like from the example template. 
> Download: https://bitbucket.org/mulonemartin/bootstrap/overview also you 
> can test here .
>
> *User Panel Admin*
>
> An application to administer the auth_user table. You can add, remove, 
> activate users/ add groups, also add users to groups and so on. 
> https://bitbucket.org/mulonemartin/usersadmin
>
>
>
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Anthony
I'd really like to see DIV() % BR().  ;-)

On Thursday, July 26, 2012 3:43:35 PM UTC-4, Massimo Di Pierro wrote:
>
> We can also implement BR()+BR().  how about DIV(...)-BR()? What do you 
> think it should do?
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Massimo Di Pierro
We can also implement BR()+BR().  how about DIV(...)-BR()? What do you think it 
should do?

-- 





[web2py] installing mssql drivers

2012-07-26 Thread jcrowe
Are there any docs on how to install pyodbc to work with web2py. I have it 
installed in my windows python installation, but that doesn't seem to work 
with web2py.

Any pointers would be greatly appreciated. :)

-- 





Re: [web2py] web2py windows build broken in nightly

2012-07-26 Thread Nomad
working now. thanks again

On Thursday, July 26, 2012 1:53:30 PM UTC-5, Nomad wrote:
>
> I downloaded it about 4 hours ago.. 11:00am CST. ill try it again shortly.
>
> On Thursday, July 26, 2012 12:23:43 PM UTC-5, Marin Pranjić wrote:
>>
>> When did you download nightly build? Can you please try again, it was 
>> fixed 6 hours ago.
>>
>> Marin
>>
>> On Jul 26, 2012 7:14 PM, "Nomad"  wrote:
>>
>>
>> error on start up
>>
>> C:\web2py\web2py>web2py.exe
>> Traceback (most recent call last):
>>   File "web2py.py", line 16, in 
>> zipimport.ZipImportError: can't find module 'gluon'
>>
>> the source check out seems to be ok (?)
>>
>> -- 
>>  
>>  
>>  
>>
>>

-- 





[web2py] Re: Complex query with left outer join

2012-07-26 Thread Niphlod
no probl.
To elaborate this further for others having the same issue

People (programmers, often) tend to forget that db engines are programs. 
They have their own algorithms too (and they take time). 
It's true that they have pretty rock-solid algos and do their work very 
fast, but having python filtering rows objects sometimes is even faster 
than specifying some super-duper "where" filters in the query itself. 
When the "super-duper" where is going to cut out the 90% of 1 rows 
returned it can be safer to look into the database algos, but if you're 
going to fetch a (relatively small) set and cut it out (with filter() or 
search()) by the 20%, it's generally a good advice to do that in plain 
python.
As a general "rule of thumb", condition based on a function like yours (the 
db should have been forced to calculate the date whose difference is now - 
the number of days in another column, always variable) is the best scenario 
where this kind of things is high valuable, i.e. probably faster in python 
than the db (assuming that you're able to write that in plain T-SQL).

I actually had this kind of problem and (I'm a professional db developer 
and not a python programmer) tried to write a super-optimized query (was a 
scoring system based on pretty complicated combined averages).

When I implemented the same logic in plain python, other than being far 
more readable and maintainable, I cut off execution times from ~25 min to 
~47 sec.

On Thursday, July 26, 2012 6:03:24 PM UTC+2, jw wrote:
>
> cards2learn.exclude(lambda row: row.userCard.lastTimeLearned > date.today
> () - timedelta(days=row.userCard.stage))   
>
> Niphlod, you made my day!! Thank you so much! And thank you all for the 
> advices!
>
>
> On Thursday, July 26, 2012 5:52:29 PM UTC+2, Niphlod wrote:
>>
>> Currently you'd have to code a view in the database (or simply a "string" 
>> condition to pass on) to achieve that. 
>>
>> date.today() - timedelta(something) is a python "fixed" value that 
>> doesn't get re-evaluated at runtime by the database substituting the 
>> "something" for each value of every row.
>>
>> If you need the structure to be portable and absolutely need to have a 
>> single query fetching all of this, you need to change your db structure.
>>
>> If you're going to run always on a "fixed" db engine you could write 
>> something exploiting the functionalities of that db engine.
>>
>> Remember that most of the times is easier (and the resources negligible) 
>> to fetch rows from the db and filter them with python.
>>
>> cards2learn = db((db.groupCards.card_id == db.card.id) \
>> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
>> & (session.chosenSubject_id == db.card.subject_id) \
>> & (db.userCard.card_id == db.card.id)
>> & (db.userCard.stage <= 5) \
>> #& (db.userCard.lastTimeLearned < (date.today() - 
>> timedelta(days=(1
>> ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, left=db.
>> userCard.on((db.userCard.card_id == db.card.id)))
>>
>> cards2learn.exclude(lambda row: row.usercard.lasttimelearned < request.now 
>> - timedelta(days=row.usercard.stage))
>>
>>
>>
>>
>>
>>  should work. (totally untested)
>>
>> On Thursday, July 26, 2012 5:23:51 PM UTC+2, jw wrote:
>>>
>>> Ok guys... I did step for step and now the query works for the stage 
>>> (progress).
>>> The second thing (stage is multiplicator for time) I have no glue how to 
>>> move on.
>>>
>>> cards2learn = db((db.groupCards.card_id == db.card.id) \
>>> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
>>> & (session.chosenSubject_id == db.card.subject_id) \
>>> & (db.userCard.card_id == db.card.id)
>>> & (db.userCard.stage <= 5) \
>>> & (db.userCard.lastTimeLearned < (date.today() - 
>>> timedelta(days=(1
>>> ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, 
>>> left=db.userCard.on((db.userCard.card_id == db.card.id)))
>>>
>>> timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it 
>>> says:
>>>  unsupported type for timedelta days 
>>> component: Field
>>> How do I use the db.userCard.stage in timedelta (stage is an integer 
>>> field in the table)?
>>>
>>> Many thanks for the previous answers!
>>>
>>

-- 





Re: [web2py] web2py windows build broken in nightly

2012-07-26 Thread Nomad
I downloaded it about 4 hours ago.. 11:00am CST. ill try it again shortly.

On Thursday, July 26, 2012 12:23:43 PM UTC-5, Marin Pranjić wrote:
>
> When did you download nightly build? Can you please try again, it was 
> fixed 6 hours ago.
>
> Marin
>
> On Jul 26, 2012 7:14 PM, "Nomad"  wrote:
>
>
> error on start up
>
> C:\web2py\web2py>web2py.exe
> Traceback (most recent call last):
>   File "web2py.py", line 16, in 
> zipimport.ZipImportError: can't find module 'gluon'
>
> the source check out seems to be ok (?)
>
> -- 
>  
>  
>  
>
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Derek
Ah, cool. I was going to modify the div class to support that, but it looks 
like now that would be a waste of time. 


On Thursday, July 26, 2012 11:24:24 AM UTC-7, Jonathan Lundell wrote:
>
> On 26 Jul 2012, at 11:22 AM, Derek wrote:
>
> Massimo, that doesn't work, as we already explained.
>
>
> It's new in the trunk.
>
>
> Traceback (most recent call last):
>   File "C:\Temp\web2py\gluon\restricted.py", line 205, in restricted
> exec ccode in environment
>   File "C:\Temp\web2py\applications\customers2\views\default/index.html", 
> line 88, in 
> TypeError: unsupported operand type(s) for *: 'BR' and 'int'
>
>
> On Thursday, July 26, 2012 2:20:38 AM UTC-7, Massimo Di Pierro wrote:
>>
>> {{=BR()**how_many_times}}*
>>
>> On Wednesday, 25 July 2012 22:51:03 UTC-5, rochacbruno wrote:
>>>
>>> On Thu, Jul 26, 2012 at 12:39 AM, pbreit  wrote:
>>>
 Wow, you would write that instead of ??
>>>
>>>
>>> Sometimes the repetition is a variable
>>>
>>> {{=CAT(*[BR() for i in xrange(*how_many_times*)])}} 
>>>
>>
>
>
>
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Jonathan Lundell
On 26 Jul 2012, at 11:22 AM, Derek wrote:
> Massimo, that doesn't work, as we already explained.

It's new in the trunk.

> 
> Traceback (most recent call last):
>   File "C:\Temp\web2py\gluon\restricted.py", line 205, in restricted
> exec ccode in environment
>   File "C:\Temp\web2py\applications\customers2\views\default/index.html", 
> line 88, in 
> TypeError: unsupported operand type(s) for *: 'BR' and 'int'
> 
> 
> On Thursday, July 26, 2012 2:20:38 AM UTC-7, Massimo Di Pierro wrote:
> {{=BR()*how_many_times}}
> 
> On Wednesday, 25 July 2012 22:51:03 UTC-5, rochacbruno wrote:
> On Thu, Jul 26, 2012 at 12:39 AM, pbreit  wrote:
> Wow, you would write that instead of ??
> 
> Sometimes the repetition is a variable
> 
> {{=CAT(*[BR() for i in xrange(how_many_times)])}} 
> 
> 


-- 





Re: [web2py] BR()

2012-07-26 Thread Derek
Massimo, that doesn't work, as we already explained.

Traceback (most recent call last):
  File "C:\Temp\web2py\gluon\restricted.py", line 205, in restricted
exec ccode in environment
  File "C:\Temp\web2py\applications\customers2\views\default/index.html", line 
88, in 
TypeError: unsupported operand type(s) for *: 'BR' and 'int'


On Thursday, July 26, 2012 2:20:38 AM UTC-7, Massimo Di Pierro wrote:
>
> {{=BR()**how_many_times}}*
>
> On Wednesday, 25 July 2012 22:51:03 UTC-5, rochacbruno wrote:
>>
>> On Thu, Jul 26, 2012 at 12:39 AM, pbreit  wrote:
>>
>>> Wow, you would write that instead of ??
>>
>>
>> Sometimes the repetition is a variable
>>
>> {{=CAT(*[BR() for i in xrange(*how_many_times*)])}} 
>>  
>

-- 





[web2py] Re: digital data store

2012-07-26 Thread Derek
I like the work these guys do.

http://www.scorpiondesign.com/ 



On Wednesday, July 25, 2012 11:05:49 PM UTC-7, Richard Penman wrote:
>
> Hello,
>
> I made this web2py app for selling digital data via PayPal:
> http://sitescraper.net/data
>
> Would appreciate feedback. If you are interested it is hosted on 
> webfaction with nginx for the static content and uwsgi for web2py.
> Blog was generated with jekyll.
>
> If there is enough interest I can clean it up and open source it.
>
> I have made a few sales so far, so seems to technically work well but I am 
> not a designer so looks crude.
> Anyone here good at design or can recommend someone? 
>
> Richard
>

-- 





Re: [web2py] web2py windows build broken in nightly

2012-07-26 Thread Marin Pranjić
When did you download nightly build? Can you please try again, it was fixed
6 hours ago.

Marin

On Jul 26, 2012 7:14 PM, "Nomad"  wrote:


error on start up

C:\web2py\web2py>web2py.exe
Traceback (most recent call last):
  File "web2py.py", line 16, in 
zipimport.ZipImportError: can't find module 'gluon'

the source check out seems to be ok (?)

--

-- 





[web2py] web2py windows build broken in nightly

2012-07-26 Thread Nomad

error on start up

C:\web2py\web2py>web2py.exe
Traceback (most recent call last):
  File "web2py.py", line 16, in 
zipimport.ZipImportError: can't find module 'gluon'

the source check out seems to be ok (?)

-- 





[web2py] Re: mysql migration 5.0 to 5.5 - migrate=False, getting auth_users already exists

2012-07-26 Thread wdtatenh
Thanks so much.  

On Thursday, July 26, 2012 11:59:24 AM UTC-4, Niphlod wrote:
>
> yep. migrate=False in DAL set migrate=False for table definitions.
>
> the auth.define_table() needs to be set to migrate=False explicitely.
>
>
>
> On Thursday, July 26, 2012 5:48:23 PM UTC+2, wdtatenh wrote:
>>
>> I had to migrate to mysql 5.5. for another application I have.  I did not 
>> attempt to migrate things through that administrative interface.  Just did 
>> a RESTORE from a mysql dump to file.
>>
>> I have migrate=False in the DAL() statement.
>>
>> Am I missing something here?  
>>
>> Appreciate any input on this.
>>
>>

-- 





[web2py] Re: Left outer join in a compex select

2012-07-26 Thread jw
Thank you Massimo. The second problem is solved by Niphlod: 
https://groups.google.com/d/msg/web2py/zryvpiFwWgI/RvmphEN7VzAJ

On Wednesday, July 25, 2012 3:43:01 PM UTC+2, jw wrote:
>
> Hi!
>
> I'm trying to develop a E-Learning-System. The idea is to give the student 
> a bunch of cards to learn every day.
> Therefore I have a table 'cards' which includes only the answer.
> Table 'userCard' includes the date when the user learnt the card the last 
> time and in which stage (multiplier for the timedelta) the card is for this 
> special user.
> Table 'subject' holds the name of the subject and table 'studyGroup' hold 
> the name of the studyGroup of the student.
>
> To get the cards for the day for this student in a special subject with 
> the answers for his studyGroup and with only the cards he didnt learn the 
> last days I tried the following select:
>
> groupCards = db((db.groupCards.card_id == db.card.id) \
> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
> & (session.chosenSubject_id == db.card.subject_id) 
> & (db.userCard.stage <= 5) \
> & (db.userCard.lastTimeLearned < (datetime.date.today() - datetime
> .timedelta(days=(1
> & ((datetime.date.today()) <= db.userCard.lastTimeLearned) 
> ).select(db.userCard.ALL, left=db.userCard.on((db.userCard.card_id 
> == db.card.id))) 
>
>
> I used the left outer join to include the cards, he never learned before. 
> The userCards are created later if they don't exist.
>
> Now I have the problem, that I have userCard before and in the select. In 
> the select, it seems, that I can't do the both querys and without them 
> before select, there is no card selected at all.
>
> The other problem is, that in timedelta, I would like to change the '1' 
> with db.userCard.stage, but I only get the exception, that I can't use a 
> field in timedelta.
>
> Any idea?
>
> P.S.: Sorry for my english ;o) 
>

-- 





[web2py] Re: Complex query with left outer join

2012-07-26 Thread jw
cards2learn.exclude(lambda row: row.userCard.lastTimeLearned > date.today() 
- timedelta(days=row.userCard.stage))   

Niphlod, you made my day!! Thank you so much! And thank you all for the 
advices!


On Thursday, July 26, 2012 5:52:29 PM UTC+2, Niphlod wrote:
>
> Currently you'd have to code a view in the database (or simply a "string" 
> condition to pass on) to achieve that. 
>
> date.today() - timedelta(something) is a python "fixed" value that doesn't 
> get re-evaluated at runtime by the database substituting the "something" 
> for each value of every row.
>
> If you need the structure to be portable and absolutely need to have a 
> single query fetching all of this, you need to change your db structure.
>
> If you're going to run always on a "fixed" db engine you could write 
> something exploiting the functionalities of that db engine.
>
> Remember that most of the times is easier (and the resources negligible) 
> to fetch rows from the db and filter them with python.
>
> cards2learn = db((db.groupCards.card_id == db.card.id) \
> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
> & (session.chosenSubject_id == db.card.subject_id) \
> & (db.userCard.card_id == db.card.id)
> & (db.userCard.stage <= 5) \
> #& (db.userCard.lastTimeLearned < (date.today() - 
> timedelta(days=(1
> ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, left=db.
> userCard.on((db.userCard.card_id == db.card.id)))
>
> cards2learn.exclude(lambda row: row.usercard.lasttimelearned < request.now 
> - timedelta(days=row.usercard.stage))
>
>
>
>
>
>  should work. (totally untested)
>
> On Thursday, July 26, 2012 5:23:51 PM UTC+2, jw wrote:
>>
>> Ok guys... I did step for step and now the query works for the stage 
>> (progress).
>> The second thing (stage is multiplicator for time) I have no glue how to 
>> move on.
>>
>> cards2learn = db((db.groupCards.card_id == db.card.id) \
>> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
>> & (session.chosenSubject_id == db.card.subject_id) \
>> & (db.userCard.card_id == db.card.id)
>> & (db.userCard.stage <= 5) \
>> & (db.userCard.lastTimeLearned < (date.today() - 
>> timedelta(days=(1
>> ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, 
>> left=db.userCard.on((db.userCard.card_id == db.card.id)))
>>
>> timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it 
>> says:
>>  unsupported type for timedelta days 
>> component: Field
>> How do I use the db.userCard.stage in timedelta (stage is an integer 
>> field in the table)?
>>
>> Many thanks for the previous answers!
>>
>

-- 





[web2py] unordered list in markmin and no bullets

2012-07-26 Thread Martin Weissenboeck
I have tried the "buletted list" (unorder list)  of markmin:

- one
- two
- three

These lines look like

one
two
three

without any bullets. The reason seems to be the line

   ul { list-style-type: none; margin: 0px; padding: 0px; }

in the file web2py.css. I have deleted this line and now the bullet came
back:

   - one
   - two
   - three

What is the reason for this line?

Regards, Martin

-- 





[web2py] Re: mysql migration 5.0 to 5.5 - migrate=False, getting auth_users already exists

2012-07-26 Thread Niphlod
yep. migrate=False in DAL set migrate=False for table definitions.

the auth.define_table() needs to be set to migrate=False explicitely.



On Thursday, July 26, 2012 5:48:23 PM UTC+2, wdtatenh wrote:
>
> I had to migrate to mysql 5.5. for another application I have.  I did not 
> attempt to migrate things through that administrative interface.  Just did 
> a RESTORE from a mysql dump to file.
>
> I have migrate=False in the DAL() statement.
>
> Am I missing something here?  
>
> Appreciate any input on this.
>
>

-- 





Re: [web2py] Re: Complex query with left outer join

2012-07-26 Thread vinicius...@gmail.com

I think you're right, @Niphlod.

I didn't note this.

@jw, tell us how you solved it, ok?

--
Vinicius Assef



On 07/26/2012 12:52 PM, Niphlod wrote:

Currently you'd have to code a view in the database (or simply a
"string" condition to pass on) to achieve that.

date.today() - timedelta(something) is a python "fixed" value that
doesn't get re-evaluated at runtime by the database substituting the
"something" for each value of every row.

If you need the structure to be portable and absolutely need to have a
single query fetching all of this, you need to change your db structure.

If you're going to run always on a "fixed" db engine you could write
something exploiting the functionalities of that db engine.

Remember that most of the times is easier (and the resources negligible)
to fetch rows from the db and filter them with python.

|
cards2learn =db((db.groupCards.card_id ==db.card.id )\
&(db.groupCards.studyGroup_id ==auth.user.studyGroup_id)\
&(session.chosenSubject_id ==db.card.subject_id)\
&(db.userCard.card_id ==db.card.id )
&(db.userCard.stage <=5)\
#& (db.userCard.lastTimeLearned < (date.today() - timedelta(days=(1
).select(db.userCard.ALL,db.

card.ALL,db.groupCards.ALL,left=db.userCard.on((db.userCard.card_id
==db.card.id )))

cards2learn.exclude(lambdarow:row.usercard.lasttimelearned
http://db.card.id>) \
 & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
 & (session.chosenSubject_id == db.card.subject_id) \
 & (db.userCard.card_id == db.card.id )
 & (db.userCard.stage <= 5) \
 & (db.userCard.lastTimeLearned < (date.today() -
timedelta(days=(1
 ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL,
left=db.userCard.on((db.userCard.card_id == db.card.id
)))

timedelta(days=(1)) should be timedelta(days=(db.userCard.stage))
but it says:


 unsupported type for timedelta
days component: Field


How do I use the db.userCard.stage in timedelta (stage is an integer
field in the table)?

Many thanks for the previous answers!

--





--





[web2py] Re: table auth_user already exists

2012-07-26 Thread Niphlod
all of this instead of

migrate=False

where you know a table already exist ?

On Thursday, July 26, 2012 5:23:50 PM UTC+2, Chris wrote:
>
> I've found what seems a simple way to let multiple apps share a DB and 
> create the same table definitions without conflict.  Chris, you may find 
> this useful and also I'd love to hear from the true experts if there are 
> problems with this approach.  (It works for me but maybe there are other 
> implications).
>
> Step 1, be sure that each application is applying the exact same table 
> definition / structure (by defining in a module that all apps import or 
> whatnot).  There isn't any table-sharing approach that will work right if 
> two different applications are competing violently to change the schema 
> over and over.
>
> Step 2, have all the subsystems share a single directory where the *.table 
> files are stored.  The usual behavior is that each app has its own store of 
> *.table files in its own app-local ./databases directory.  The problem with 
> conflicting table creates happens, as far as I can tell, when a table 
> already exists but there is no corresponding table-definition file in the 
> app's own local ./databases directory.  In web2py / gluon / dal.py / 
> BaseAdapter / create_table(), the logic that determines the location and 
> name of the table-definition file looks like this (in web2py version 
> 1.99.7):
>
> ## at line 697
> dbpath = self.folder
> ## e.g. /path/to/web2py/applications/appname/databases
>
> ## at line 706
> table._dbt = os.path.join(dbpath, '%s_%s.table' % 
> (table._db._uri_hash,tablename
> ))
> ## e.g. 
> /path/to/web2py/applications/appname/databases/51bd584ac1754de09bdf0aac5438df72_tablename.table
>
> In other words, the path is derived from the app name (and is below the 
> app directory), and the file name is derived from the DB URI + table name.
>
> To allow multiple apps to share table-definition files, you could either 
> change DAL code to point to a different folder that doesn't differ per app 
> (maybe under web2py or web2py/private), or you could leave DAL alone and 
> use symbolic links to make all the ./databases folders point to the same 
> place.
>
> What I've done is create a web2py / applications / databases folder that 
> isn't really an app (isn't mentioned in routes.py and so on), then for each 
> app:
>
> ## on OSX 10.7.3, may differ on other OS's
> ln -s /path/to/web2py/applications/databases /path/to/web2py/applications/
> someapp/databases
>
>
> (Note no trailing "/" on either of the paths.)  This allows DAL to 
> continue as usual, but all apps are reading & writing the same set of table 
> definition files.
>
> There are some tradeoffs between doing this in DAL and doing via 
> symlinks.  If you do it via DAL, then there are no additional steps to 
> configuring your app other than deploying the right source files, and you 
> don't rely on having an OS that supports symlinks -- although that's a 
> smaller issue than it used to be now that Windows Vista supports symlinks; 
> however this approach does mean a source code change, that you would need 
> to keep track of over web2py releases, and might obligate you to publish 
> the code and so on for licensing reasons.  Also if you do it via DAL, if 
> you want different subsets of  apps in a single web2py instance to share 
> DBs differently (i.e. it's not all-or-none), you would have to add logica 
> saying which shared directories are for which apps, via a configuration 
> file or whatever.  If you do it via symlinks, then you don't have to change 
> source code, you can decide which apps share table definitions or not by 
> which app directories you point to which shared directories -- but you have 
> to know how to make these changes as you move code between machines, 
> changing deployment from a "drop the files in" approach to "... then run 
> these scripts", which is probably a matter of taste.
>
> In any case, once I have apps sharing a folder for table-definition files, 
> this problem goes away.
>
>
>
> On Monday, June 27, 2011 2:22:57 PM UTC-4, Christopher Baron wrote:
>>
>> Hi web2py users, 
>>
>> Just upgraded to Version 1.97.1 
>>
>> I checked my code out into the new directory, opened my browser, and 
>> received and error stating 'auth_cas' already exists. 
>>
>> I removed all files from the databases folder and tried again 
>> receiving an error that 'auth_user' already exists. 
>>
>> I'm using a private/config file that points to some mysql database on 
>> another server. 
>>
>> What can I do ? 
>>
>> I'd be happy to share more information needed to help solve the 
>> problem. 
>>
>> Thanks in advance, 
>>
>> Chris
>
>

-- 





Re: [web2py] Re: Complex query with left outer join

2012-07-26 Thread jw


On Thursday, July 26, 2012 5:41:40 PM UTC+2, viniciusban wrote:
>
> Some suggestions, but I've not tested any of them: 
>
> 1) Use timedelta(days=int(db.userCard.stage)) to convert your Field to 
> int. 
>

The typecast brings the following exception:
 int() argument must be a string or a number, 
not 'Field'I think the problem is, that in this case it is not the 
particalur db.userCard.stage selected which correspond to itself in 
db.userCard.lastTimeLearned. Could that be?
 

>
> 2) Split your query in 2 parts. The 2nd should use find() or exclude(). 
>

I'll try that after reading the qeb2py manual.
 

>
> 3) Use db.executesql() to insert your SQL statement. 
>

I haven't heard about this opportunity. I'll look it up

Thank you!
 

>
>
> -- 
> Vinicius Assef 
>
>
>
> On 07/26/2012 12:23 PM, jw wrote: 
> > Ok guys... I did step for step and now the query works for the stage 
> > (progress). 
> > The second thing (stage is multiplicator for time) I have no glue how to 
> > move on. 
> > 
> > cards2learn = db((db.groupCards.card_id == db.card.id) \ 
> >  & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \ 
> >  & (session.chosenSubject_id == db.card.subject_id) \ 
> >  & (db.userCard.card_id == db.card.id) 
> >  & (db.userCard.stage <= 5) \ 
> >  & (db.userCard.lastTimeLearned < (date.today() - 
> > timedelta(days=(1 
> >  ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, 
> > left=db.userCard.on((db.userCard.card_id == db.card.id))) 
> > 
> > timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it 
> > says: 
> > 
> > 
> >  unsupported type for timedelta 
> > days component: Field 
> > 
> > 
> > How do I use the db.userCard.stage in timedelta (stage is an integer 
> > field in the table)? 
> > 
> > Many thanks for the previous answers! 
> > 
> > -- 
> > 
> > 
> > 
>
>

-- 





[web2py] Re: Complex query with left outer join

2012-07-26 Thread Niphlod
Currently you'd have to code a view in the database (or simply a "string" 
condition to pass on) to achieve that. 

date.today() - timedelta(something) is a python "fixed" value that doesn't 
get re-evaluated at runtime by the database substituting the "something" 
for each value of every row.

If you need the structure to be portable and absolutely need to have a 
single query fetching all of this, you need to change your db structure.

If you're going to run always on a "fixed" db engine you could write 
something exploiting the functionalities of that db engine.

Remember that most of the times is easier (and the resources negligible) to 
fetch rows from the db and filter them with python.

cards2learn = db((db.groupCards.card_id == db.card.id) \
& (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
& (session.chosenSubject_id == db.card.subject_id) \
& (db.userCard.card_id == db.card.id)
& (db.userCard.stage <= 5) \
#& (db.userCard.lastTimeLearned < (date.today() - 
timedelta(days=(1
).select(db.userCard.ALL,db.
>
> card.ALL,db.groupCards.ALL, left=db.userCard.on((db.userCard.card_id == db
> .card.id)))
>
> cards2learn.exclude(lambda row: row.usercard.lasttimelearned < request.now 
> - timedelta(days=row.usercard.stage))
>





 should work. (totally untested)

On Thursday, July 26, 2012 5:23:51 PM UTC+2, jw wrote:
>
> Ok guys... I did step for step and now the query works for the stage 
> (progress).
> The second thing (stage is multiplicator for time) I have no glue how to 
> move on.
>
> cards2learn = db((db.groupCards.card_id == db.card.id) \
> & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
> & (session.chosenSubject_id == db.card.subject_id) \
> & (db.userCard.card_id == db.card.id)
> & (db.userCard.stage <= 5) \
> & (db.userCard.lastTimeLearned < (date.today() - 
> timedelta(days=(1
> ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, 
> left=db.userCard.on((db.userCard.card_id == db.card.id)))
>
> timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it 
> says:
>  unsupported type for timedelta days 
> component: Field
> How do I use the db.userCard.stage in timedelta (stage is an integer field 
> in the table)?
>
> Many thanks for the previous answers!
>

-- 





[web2py] mysql migration 5.0 to 5.5 - migrate=False, getting auth_users already exists

2012-07-26 Thread wdtatenh
I had to migrate to mysql 5.5. for another application I have.  I did not 
attempt to migrate things through that administrative interface.  Just did 
a RESTORE from a mysql dump to file.

I have migrate=False in the DAL() statement.

Am I missing something here?  

Appreciate any input on this.

-- 





Re: [web2py] Re: Complex query with left outer join

2012-07-26 Thread vinicius...@gmail.com

Some suggestions, but I've not tested any of them:

1) Use timedelta(days=int(db.userCard.stage)) to convert your Field to int.

2) Split your query in 2 parts. The 2nd should use find() or exclude().

3) Use db.executesql() to insert your SQL statement.


--
Vinicius Assef



On 07/26/2012 12:23 PM, jw wrote:

Ok guys... I did step for step and now the query works for the stage
(progress).
The second thing (stage is multiplicator for time) I have no glue how to
move on.

cards2learn = db((db.groupCards.card_id == db.card.id) \
 & (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
 & (session.chosenSubject_id == db.card.subject_id) \
 & (db.userCard.card_id == db.card.id)
 & (db.userCard.stage <= 5) \
 & (db.userCard.lastTimeLearned < (date.today() -
timedelta(days=(1
 ).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL,
left=db.userCard.on((db.userCard.card_id == db.card.id)))

timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it
says:


 unsupported type for timedelta
days component: Field


How do I use the db.userCard.stage in timedelta (stage is an integer
field in the table)?

Many thanks for the previous answers!

--





--





[web2py] Re: Replacing session.var with another value

2012-07-26 Thread adohertyd
Cliff you are correct that was a typo in my original question. If you look 
at my code you can see that I am using session.variable_name in all other 
cases. This is how I want to do it. But my original question still remains.

On Thursday, 26 July 2012 16:15:56 UTC+1, Cliff Kachinske wrote:
>
> The dot notation for session.vars.a is not going to work.  
>
> It's true that session is a Python object and you can assign attributes to 
> it, but vars is not a Python object.  Thus you cannot assign attributes to 
> it.
>
> For this case, it would be simpler to just use something like 
> session.user_input
>
> If for some reason you want to assign multiple values to session.vars, it 
> could by a Python list or a dictionary.  But first you have to initialize 
> it, something like
>
> if 'vars' not in session:
>   session.vars = {} # for a dictionary
>
>
>
> On Thursday, July 26, 2012 8:43:33 AM UTC-4, adohertyd wrote:
>>
>> Hope you guys can give me a hand here. I have two central functions in my 
>> controller: index() and resultsDisplay()
>>
>> In index() the user enters a string into a form and it is assigned to 
>> session.var.a
>>
>> session.var.a is passed to resultsDisplay() and it is processed. In the 
>> resultsDisplay() view, I want the form from index() to be shown with the 
>> user's string in it. I also will have a number of alternative suggestions 
>> for the user. What I want is that if the user enters another term in the 
>> form on the results page, or if the user clicks one of the supplied 
>> suggestions, the resultsDisplay() function will restart, except that 
>> instead of session.var.a being the form data from the index(), it will be 
>> whatever the new value is. A great example of this is Google. If you type a 
>> query in the main bar it gives you results. You notice that you've spelt 
>> the query incorrectly. Google offers a suggestion, or the user has the 
>> option of re-typing the query in the box and getting a new set of results. 
>> How would I do this? Also, on a side note, how do I give the radio buttons 
>> in my form a default value?
>>
>> *def index():*
>>
>>  form = SQLFORM.factory(
>>  Field('field_1','string', widget=SQLFORM.widgets.string.widget,
>> requires=IS_NOT_EMPTY()),
>>  Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM
>> .widgets.radio.widget),
>>submit_button='Go!')  
>> if form.process().accepted:
>> session.term=request.vars.field_1
>> session.aggregate=request.vars.field_2
>> redirect(URL('resultsDisplay'))
>> else:
>> response.flash = 'please fill the form'
>> return dict(form=form)
>>
>>
>> *def resultsDisplay():*
>>  
>>__function_1(session.term)
>> do some processing
>> __function_2(session.term)
>> do some processing
>> __function_3(session.term)
>>
>>
>> return locals()
>>
>>
>> *index.html:*
>>
>> {{=form.custom.begin}}
>>   {{=form.custom.widget.field_1}}
>>   {{=form.custom.submit}}
>>   
>>   Choice:
>>   {{=form.custom.widget.field_2}}
>>   {{=form.custom.end}}
>>
>>
>> *resultsDisplay.html:*
>> *
>> *
>> #I want to put the form from index.html here
>> {{=DisplayResults_as per resultsDisplay function}}
>> #I want to put suggestions that, when clicked, will reload this page with 
>> new result set.
>>
>>

-- 





[web2py] Re: table auth_user already exists

2012-07-26 Thread Chris
I've found what seems a simple way to let multiple apps share a DB and 
create the same table definitions without conflict.  Chris, you may find 
this useful and also I'd love to hear from the true experts if there are 
problems with this approach.  (It works for me but maybe there are other 
implications).

Step 1, be sure that each application is applying the exact same table 
definition / structure (by defining in a module that all apps import or 
whatnot).  There isn't any table-sharing approach that will work right if 
two different applications are competing violently to change the schema 
over and over.

Step 2, have all the subsystems share a single directory where the *.table 
files are stored.  The usual behavior is that each app has its own store of 
*.table files in its own app-local ./databases directory.  The problem with 
conflicting table creates happens, as far as I can tell, when a table 
already exists but there is no corresponding table-definition file in the 
app's own local ./databases directory.  In web2py / gluon / dal.py / 
BaseAdapter / create_table(), the logic that determines the location and 
name of the table-definition file looks like this (in web2py version 
1.99.7):

## at line 697
dbpath = self.folder
## e.g. /path/to/web2py/applications/appname/databases

## at line 706
table._dbt = os.path.join(dbpath, '%s_%s.table' % (table._db._uri_hash,tablename
))
## e.g. 
/path/to/web2py/applications/appname/databases/51bd584ac1754de09bdf0aac5438df72_tablename.table

In other words, the path is derived from the app name (and is below the app 
directory), and the file name is derived from the DB URI + table name.

To allow multiple apps to share table-definition files, you could either 
change DAL code to point to a different folder that doesn't differ per app 
(maybe under web2py or web2py/private), or you could leave DAL alone and 
use symbolic links to make all the ./databases folders point to the same 
place.

What I've done is create a web2py / applications / databases folder that 
isn't really an app (isn't mentioned in routes.py and so on), then for each 
app:

## on OSX 10.7.3, may differ on other OS's
ln -s /path/to/web2py/applications/databases /path/to/web2py/applications/
someapp/databases


(Note no trailing "/" on either of the paths.)  This allows DAL to continue 
as usual, but all apps are reading & writing the same set of table 
definition files.

There are some tradeoffs between doing this in DAL and doing via symlinks.  
If you do it via DAL, then there are no additional steps to configuring 
your app other than deploying the right source files, and you don't rely on 
having an OS that supports symlinks -- although that's a smaller issue than 
it used to be now that Windows Vista supports symlinks; however this 
approach does mean a source code change, that you would need to keep track 
of over web2py releases, and might obligate you to publish the code and so 
on for licensing reasons.  Also if you do it via DAL, if you want different 
subsets of  apps in a single web2py instance to share DBs differently (i.e. 
it's not all-or-none), you would have to add logica saying which shared 
directories are for which apps, via a configuration file or whatever.  If 
you do it via symlinks, then you don't have to change source code, you can 
decide which apps share table definitions or not by which app directories 
you point to which shared directories -- but you have to know how to make 
these changes as you move code between machines, changing deployment from a 
"drop the files in" approach to "... then run these scripts", which is 
probably a matter of taste.

In any case, once I have apps sharing a folder for table-definition files, 
this problem goes away.



On Monday, June 27, 2011 2:22:57 PM UTC-4, Christopher Baron wrote:
>
> Hi web2py users, 
>
> Just upgraded to Version 1.97.1 
>
> I checked my code out into the new directory, opened my browser, and 
> received and error stating 'auth_cas' already exists. 
>
> I removed all files from the databases folder and tried again 
> receiving an error that 'auth_user' already exists. 
>
> I'm using a private/config file that points to some mysql database on 
> another server. 
>
> What can I do ? 
>
> I'd be happy to share more information needed to help solve the 
> problem. 
>
> Thanks in advance, 
>
> Chris

-- 





[web2py] Re: Complex query with left outer join

2012-07-26 Thread jw
Ok guys... I did step for step and now the query works for the stage 
(progress).
The second thing (stage is multiplicator for time) I have no glue how to 
move on.

cards2learn = db((db.groupCards.card_id == db.card.id) \
& (db.groupCards.studyGroup_id == auth.user.studyGroup_id) \
& (session.chosenSubject_id == db.card.subject_id) \
& (db.userCard.card_id == db.card.id)
& (db.userCard.stage <= 5) \
& (db.userCard.lastTimeLearned < (date.today() - 
timedelta(days=(1
).select(db.userCard.ALL,db.card.ALL,db.groupCards.ALL, 
left=db.userCard.on((db.userCard.card_id == db.card.id)))

timedelta(days=(1)) should be timedelta(days=(db.userCard.stage)) but it 
says:
 unsupported type for timedelta days 
component: Field
How do I use the db.userCard.stage in timedelta (stage is an integer field 
in the table)?

Many thanks for the previous answers!

-- 





[web2py] Re: Replacing session.var with another value

2012-07-26 Thread Cliff Kachinske
The dot notation for session.vars.a is not going to work.  

It's true that session is a Python object and you can assign attributes to 
it, but vars is not a Python object.  Thus you cannot assign attributes to 
it.

For this case, it would be simpler to just use something like 
session.user_input

If for some reason you want to assign multiple values to session.vars, it 
could by a Python list or a dictionary.  But first you have to initialize 
it, something like

if 'vars' not in session:
  session.vars = {} # for a dictionary



On Thursday, July 26, 2012 8:43:33 AM UTC-4, adohertyd wrote:
>
> Hope you guys can give me a hand here. I have two central functions in my 
> controller: index() and resultsDisplay()
>
> In index() the user enters a string into a form and it is assigned to 
> session.var.a
>
> session.var.a is passed to resultsDisplay() and it is processed. In the 
> resultsDisplay() view, I want the form from index() to be shown with the 
> user's string in it. I also will have a number of alternative suggestions 
> for the user. What I want is that if the user enters another term in the 
> form on the results page, or if the user clicks one of the supplied 
> suggestions, the resultsDisplay() function will restart, except that 
> instead of session.var.a being the form data from the index(), it will be 
> whatever the new value is. A great example of this is Google. If you type a 
> query in the main bar it gives you results. You notice that you've spelt 
> the query incorrectly. Google offers a suggestion, or the user has the 
> option of re-typing the query in the box and getting a new set of results. 
> How would I do this? Also, on a side note, how do I give the radio buttons 
> in my form a default value?
>
> *def index():*
>
>  form = SQLFORM.factory(
>  Field('field_1','string', widget=SQLFORM.widgets.string.widget,
> requires=IS_NOT_EMPTY()),
>  Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM.
> widgets.radio.widget),
>submit_button='Go!')  
> if form.process().accepted:
> session.term=request.vars.field_1
> session.aggregate=request.vars.field_2
> redirect(URL('resultsDisplay'))
> else:
> response.flash = 'please fill the form'
> return dict(form=form)
>
>
> *def resultsDisplay():*
>  
>__function_1(session.term)
> do some processing
> __function_2(session.term)
> do some processing
> __function_3(session.term)
>
>
> return locals()
>
>
> *index.html:*
>
> {{=form.custom.begin}}
>   {{=form.custom.widget.field_1}}
>   {{=form.custom.submit}}
>   
>   Choice:
>   {{=form.custom.widget.field_2}}
>   {{=form.custom.end}}
>
>
> *resultsDisplay.html:*
> *
> *
> #I want to put the form from index.html here
> {{=DisplayResults_as per resultsDisplay function}}
> #I want to put suggestions that, when clicked, will reload this page with 
> new result set.
>
>

-- 





[web2py] Re: Puzzle: reference table not working?

2012-07-26 Thread Anthony

>
> db.define_table('person', 
> Field('name','string',length=255,requires=IS_NOT_EMPTY()),
> Field('location_id','reference location',default=location.id),
> )
>

There is no "location" object defined anywhere, so location.id raises an 
exception. Perhaps you meant db.location.id, but that refers to the "id" 
Field object of the "location" table, so is not appropriate to specify as a 
default value (which must be an integer). From your code, it's not clear 
what an appropriate default woud be, if any.

Anthony

>

-- 





Re: [web2py] markmin embed:http://... not work trunk version

2012-07-26 Thread Jose


El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió:
>
>  Hi, Jose!
>
> try 'iframe' instead of 'embed':
>
> iframe:http://www.youtube.com/embed/x1w8hKTJ2Co
>

Ok Vladyslav, but I think the same as Massimo, this breaks backwards 
compatibility.

Jose

-- 





Re: [web2py] Replacing session.var with another value

2012-07-26 Thread adohertyd
It's not the auto complete function that I'm looking for. I just want the 
form to be populated with the original search term, and to be able to 
submit a new search term from the results page

On Thursday, 26 July 2012 14:34:05 UTC+1, Johann Spies wrote:
>
> On 26 July 2012 14:43, adohertyd wrote:
>
>> . A great example of this is Google. If you type a query in the main bar 
>> it gives you results. You notice that you've spelt the query incorrectly. 
>> Google offers a suggestion, or the user has the option of re-typing the 
>> query in the box and getting a new set of results. How would I do this? 
>
>
> Maybe the autocomplete widget (or suggest plugin (
> http://dev.s-cubism.com/plugin_suggest_widget).
>  
>
>> Also, on a side note, how do I give the radio buttons in my form a 
>> default value?
>
>
> What I have done, was this:
>
> Field('option', requires = IS_IN_SET([(1,'Search all terms (like 
> Google search)'),
>   (2,'Search any of the 
> terms'),
>   (3,'Advanced')]),
>   default = 1,
>   widget = 
> SQLFORM.widgets.radio.widget)
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





[web2py] Re: Replacing session.var with another value

2012-07-26 Thread adohertyd
My problem is I don't know how to put it all in one function. Would be be 
able to give me some pointers please? Would really appreciate it.

On Thursday, 26 July 2012 14:29:00 UTC+1, Anthony wrote:
>
> It will probably be easier if you do it all in one function, and in the 
> view, conditionally show results if there are any.
>
> Anthony
>
> On Thursday, July 26, 2012 8:43:33 AM UTC-4, adohertyd wrote:
>>
>> Hope you guys can give me a hand here. I have two central functions in my 
>> controller: index() and resultsDisplay()
>>
>> In index() the user enters a string into a form and it is assigned to 
>> session.var.a
>>
>> session.var.a is passed to resultsDisplay() and it is processed. In the 
>> resultsDisplay() view, I want the form from index() to be shown with the 
>> user's string in it. I also will have a number of alternative suggestions 
>> for the user. What I want is that if the user enters another term in the 
>> form on the results page, or if the user clicks one of the supplied 
>> suggestions, the resultsDisplay() function will restart, except that 
>> instead of session.var.a being the form data from the index(), it will be 
>> whatever the new value is. A great example of this is Google. If you type a 
>> query in the main bar it gives you results. You notice that you've spelt 
>> the query incorrectly. Google offers a suggestion, or the user has the 
>> option of re-typing the query in the box and getting a new set of results. 
>> How would I do this? Also, on a side note, how do I give the radio buttons 
>> in my form a default value?
>>
>> *def index():*
>>
>>  form = SQLFORM.factory(
>>  Field('field_1','string', widget=SQLFORM.widgets.string.widget,
>> requires=IS_NOT_EMPTY()),
>>  Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM
>> .widgets.radio.widget),
>>submit_button='Go!')  
>> if form.process().accepted:
>> session.term=request.vars.field_1
>> session.aggregate=request.vars.field_2
>> redirect(URL('resultsDisplay'))
>> else:
>> response.flash = 'please fill the form'
>> return dict(form=form)
>>
>>
>> *def resultsDisplay():*
>>  
>>__function_1(session.term)
>> do some processing
>> __function_2(session.term)
>> do some processing
>> __function_3(session.term)
>>
>>
>> return locals()
>>
>>
>> *index.html:*
>>
>> {{=form.custom.begin}}
>>   {{=form.custom.widget.field_1}}
>>   {{=form.custom.submit}}
>>   
>>   Choice:
>>   {{=form.custom.widget.field_2}}
>>   {{=form.custom.end}}
>>
>>
>> *resultsDisplay.html:*
>> *
>> *
>> #I want to put the form from index.html here
>> {{=DisplayResults_as per resultsDisplay function}}
>> #I want to put suggestions that, when clicked, will reload this page with 
>> new result set.
>>
>>

-- 





Re: [web2py] Replacing session.var with another value

2012-07-26 Thread Johann Spies
On 26 July 2012 14:43, adohertyd  wrote:

> . A great example of this is Google. If you type a query in the main bar
> it gives you results. You notice that you've spelt the query incorrectly.
> Google offers a suggestion, or the user has the option of re-typing the
> query in the box and getting a new set of results. How would I do this?


Maybe the autocomplete widget (or suggest plugin (
http://dev.s-cubism.com/plugin_suggest_widget).


> Also, on a side note, how do I give the radio buttons in my form a default
> value?


What I have done, was this:

Field('option', requires = IS_IN_SET([(1,'Search all terms (like
Google search)'),
  (2,'Search any of the terms'),
  (3,'Advanced')]),
  default = 1,
  widget =
SQLFORM.widgets.radio.widget)

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

-- 





Re: [web2py] is there any trick in this PaaS hosting?

2012-07-26 Thread Tito Garrido
Seems good... Did you manage to install web2py there?

On Thu, Jul 26, 2012 at 5:52 AM, José Luis Redrejo Rodríguez <
jredr...@debian.org> wrote:

> https://console.appfog.com/pricing
> Free up to 2 Gb RAM , it costs more than 50$ per month in most providers
> ...
>
> I'm still looking for the trick, without success ;)
>
> Regards
> José L.
>
> --
>
>
>
>


-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] Re: Replacing session.var with another value

2012-07-26 Thread Anthony
It will probably be easier if you do it all in one function, and in the 
view, conditionally show results if there are any.

Anthony

On Thursday, July 26, 2012 8:43:33 AM UTC-4, adohertyd wrote:
>
> Hope you guys can give me a hand here. I have two central functions in my 
> controller: index() and resultsDisplay()
>
> In index() the user enters a string into a form and it is assigned to 
> session.var.a
>
> session.var.a is passed to resultsDisplay() and it is processed. In the 
> resultsDisplay() view, I want the form from index() to be shown with the 
> user's string in it. I also will have a number of alternative suggestions 
> for the user. What I want is that if the user enters another term in the 
> form on the results page, or if the user clicks one of the supplied 
> suggestions, the resultsDisplay() function will restart, except that 
> instead of session.var.a being the form data from the index(), it will be 
> whatever the new value is. A great example of this is Google. If you type a 
> query in the main bar it gives you results. You notice that you've spelt 
> the query incorrectly. Google offers a suggestion, or the user has the 
> option of re-typing the query in the box and getting a new set of results. 
> How would I do this? Also, on a side note, how do I give the radio buttons 
> in my form a default value?
>
> *def index():*
>
>  form = SQLFORM.factory(
>  Field('field_1','string', widget=SQLFORM.widgets.string.widget,
> requires=IS_NOT_EMPTY()),
>  Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM.
> widgets.radio.widget),
>submit_button='Go!')  
> if form.process().accepted:
> session.term=request.vars.field_1
> session.aggregate=request.vars.field_2
> redirect(URL('resultsDisplay'))
> else:
> response.flash = 'please fill the form'
> return dict(form=form)
>
>
> *def resultsDisplay():*
>  
>__function_1(session.term)
> do some processing
> __function_2(session.term)
> do some processing
> __function_3(session.term)
>
>
> return locals()
>
>
> *index.html:*
>
> {{=form.custom.begin}}
>   {{=form.custom.widget.field_1}}
>   {{=form.custom.submit}}
>   
>   Choice:
>   {{=form.custom.widget.field_2}}
>   {{=form.custom.end}}
>
>
> *resultsDisplay.html:*
> *
> *
> #I want to put the form from index.html here
> {{=DisplayResults_as per resultsDisplay function}}
> #I want to put suggestions that, when clicked, will reload this page with 
> new result set.
>
>

-- 





Re: [web2py] User accessed site without logging in

2012-07-26 Thread Massimo Di Pierro
Added validation for request.client in trunk

On Wednesday, 25 July 2012 16:29:45 UTC-5, Massimo Di Pierro wrote:
>
> Hello Neil,
>
> thank you for this thread and for how you handled the issue. This was a 
> tricky one to debug and a very important issue for the community. We can 
> all rejoice this is a uwsgi issue and not a web2py one.
>
> There is nothing web2py can do if the web server injects the wrong headers 
> but I will add some client_addr validation and raise HTTP(xxx) if the 
> client_addr is "unknown".
>
> massimo
>
> On Wednesday, 25 July 2012 11:54:07 UTC-5, Neil wrote:
>>
>> I got to the point where I could reproduce this locally using incognito 
>> mode. Looks like it is a known uwsgi bug that was just patched 3 days ago:
>>
>>
>> http://stackoverflow.com/questions/11598935/uwsgi-resends-headers-in-async-mode
>>  
>>
>> To anyone else using a recent version of uwsgi - you might want to turn 
>> off async, or you could get some very undesirable behaviour (and angry 
>> users)!
>>
>> On Wednesday, July 25, 2012 2:49:48 PM UTC+1, Massimo Di Pierro wrote:
>>>
>>> The author of the post below says:
>>> "These are 2 distinct clients. I opened an incognito session, confirmed 
>>> that no cookie was sent in the headers, and the uwsgi log shows that it 
>>> received the same HTTP_COOKIE."
>>>
>>> This could very much be the problem. It would definitively cause the 
>>> behavior you see.
>>> I still do not understand what uwsgi is doing. Is it proxing cookies? 
>>> And what does facebooks and iDevices have to do with this? 
>>>
>>> I have a theory. the problems where from iDevices. Probably they are 
>>> going over phone networks. Perhaps they have IPv6 addresses. Perhaps uWSGI 
>>> gets confused by this or by some other weird parameter in the HTTP_HEADER 
>>> coming from these devices. One symptom is that it assigns cliend_addr = 
>>> "unknown" as we have seen before. It is possible that uWSGI by default 
>>> caches cookies from the same client addr. I do not understand why it would 
>>> do that but it could be. Perhaps uWSGI is as fast as it is because it skips 
>>> some proper header parsing.
>>>
>>> Massimo
>>>
>>

-- 





[web2py] Re: Error using Scheduler with CouchDB

2012-07-26 Thread Niphlod


> Hot  to activate SQLite WAL when using DAL?
>

you need to have a sqlite3 (or pysqlite2) linked to a sqlite version >= 
3.7.0.

There are two version number: the module itself and the linked static 
library (.so on unix and .dll on Windows)

>>> import sqlite3 #or from pysqlite2 import dbapi2 as sqlite3
>>> sqlite3.version
'2.4.1'
>>> sqlite3.sqlite_version
'3.6.22'

Fastest way to update pysqlite2 now on unix (for windows there are standard 
.exe installers) is (assuming pip, python-dev and make are available)

sudo pip install 
http://pysqlite.googlecode.com/files/pysqlite-2.6.3.tar.gz--global-option 
build_static

sqlite3.sqlite_version is the value that needs to be >= 3.7.0 .

If this is True, just issue (one-time-only) this command to the db

PRAGMA journal_mode=WAL;


>From then on, that db will work with WAL activated. 

For a complete review of pros and cons, see 
http://www.sqlite.org/draft/wal.html

Thanks. I'll try using SQLite and WAL - that having been said I'd still be 
> vote for getting the scheduler working with NoSQL (couchDB) at some stage.
>

First things first: having CouchDB exiting from the "experimental" phase on 
the DAL.

-- 





[web2py] Replacing session.var with another value

2012-07-26 Thread adohertyd
Hope you guys can give me a hand here. I have two central functions in my 
controller: index() and resultsDisplay()

In index() the user enters a string into a form and it is assigned to 
session.var.a

session.var.a is passed to resultsDisplay() and it is processed. In the 
resultsDisplay() view, I want the form from index() to be shown with the 
user's string in it. I also will have a number of alternative suggestions 
for the user. What I want is that if the user enters another term in the 
form on the results page, or if the user clicks one of the supplied 
suggestions, the resultsDisplay() function will restart, except that 
instead of session.var.a being the form data from the index(), it will be 
whatever the new value is. A great example of this is Google. If you type a 
query in the main bar it gives you results. You notice that you've spelt 
the query incorrectly. Google offers a suggestion, or the user has the 
option of re-typing the query in the box and getting a new set of results. 
How would I do this? Also, on a side note, how do I give the radio buttons 
in my form a default value?

*def index():*
   
 form = SQLFORM.factory(
 Field('field_1','string', widget=SQLFORM.widgets.string.widget,
requires=IS_NOT_EMPTY()),
 Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM.
widgets.radio.widget),
   submit_button='Go!')  
if form.process().accepted:
session.term=request.vars.field_1
session.aggregate=request.vars.field_2
redirect(URL('resultsDisplay'))
else:
response.flash = 'please fill the form'
return dict(form=form)


*def resultsDisplay():*
 
   __function_1(session.term)
do some processing
__function_2(session.term)
do some processing
__function_3(session.term)


return locals()


*index.html:*

{{=form.custom.begin}}
  {{=form.custom.widget.field_1}}
  {{=form.custom.submit}}
  
  Choice:
  {{=form.custom.widget.field_2}}
  {{=form.custom.end}}


*resultsDisplay.html:*
*
*
#I want to put the form from index.html here
{{=DisplayResults_as per resultsDisplay function}}
#I want to put suggestions that, when clicked, will reload this page with 
new result set.

-- 





[web2py] Re: Error using Scheduler with CouchDB

2012-07-26 Thread David Marko
Hot  to activate SQLite WAL when using DAL?

Dne čtvrtek, 26. července 2012 10:04:23 UTC+2 Niphlod napsal(a):
>
> Couchdb support is still experimental in web2py. If auth is not working 
> you'd likely to wait (or help Massimo with) a better implementation of the 
> DAL.
>
> If you need ultra-fast tasks you'd want to use celery (or pyres, or rq). 
> The current scheduler with SQLite can process ~5 tasks per second per 
> single worker (YMMV for complex apps or functions). Multiple workers with 
> SQLite and WAL archiving disabled is not recommended. Anyway, with WAL 
> activated, I tested with no problems 8 concurrent workers with a great deal 
> of tasks (~6000) with a semi-linear scalability.
> With Mysql or postgres it's possible to process tasks with even more 
> concurrent workers (I'd still keep them 50 at most). The only downside of 
> SQLite instead of a "full relational db" is that you can't share the db 
> among different machines.
>
>
>
> On Thursday, July 26, 2012 7:03:44 AM UTC+2, Ted wrote:
>>
>> Hi Niphlod,
>>
>> Since the usecase for a Scheduler often needs concurrent fast write/reads 
>> and updates (from multiple clients) with information that is largely 
>> temporary I think a Nosql DB is a great way to handle scheduler data.
>>
>> In my case I don't want the overhead of installing a full relational db 
>> and I'm sure that the SQLite adapter will not perform well under load with 
>> multiple scheduler tasks.
>>
>> Since I posted I have tried CouchDB as my Auth db and am getting similar 
>> errors (at the same code point as above) about the encoding. I am using 
>> Python 2.6, web2py Version 2.00.0 (2012-07-18 21:46:56) dev and CouchDB 
>> 1.0.1.
>>
>> Ted
>>  
>>
>> On Thursday, July 26, 2012 2:07:17 AM UTC+7, Niphlod wrote:
>>>
>>> Scheduler was meant to run on relational dbs. Actually, I think noone 
>>> ever tested it on Nosql adapters, but if this is a popular requirement I 
>>> could see into it.
>>>
>>> BTW, I posted an app to test the scheduler in trunk for this kind of 
>>> tests.
>>>
>>> https://groups.google.com/d/topic/web2py/E_mASrZIpvw/discussion
>>>
>>>
>>>
>>> On Wednesday, July 25, 2012 1:42:50 PM UTC+2, Ted wrote:

 Hi Web2pyers,

 Has anyone sucessfully used the new scheduler functionality with *
 CouchDB? *(I'm assuming this is feasible)

 I'm currently trying to use the scheduler on *Windows 7* with *CouchDB 
 *as the DAL source.
 My code works fine with sqlite but seems to silently fail using *
 CouchDB*- although the tables are correctly created.

 e.g.

 scheduler_db = DAL('couchdb://127.0.0.1:5984')
 scheduler = 
 Scheduler(scheduler_db,dict(demo1=demo1,demo2=demo2),heartbeat=1) 


 (The *CouchDB* scheduler_worker table seems to mysteriously keep 
 growing.)

 When I try to manually add a task through the Admin (
 http://127.0.0.1:8000/init/appadmin/insert/scheduler_db/scheduler_task)

 I get the following error:

 Traceback (most recent call last):
   File "C:\Users\ted\dev\web2py\gluon\restricted.py", line 205, in 
 restricted
 exec ccode in environment
   File "C:/Users/ted/dev/Px/applications/init/controllers/appadmin.py" 
 , 
 line 270, in 
   File "C:\Users\ted\dev\web2py\gluon\globals.py", line 182, in 
 self._caller = lambda f: f()
   File "C:/Users/ted/dev/Px/applications/init/controllers/appadmin.py" 
 , 
 line 103, in insert
 if form.accepts(request.vars, session):
   File "C:\Users\ted\dev\web2py\gluon\sqlhtml.py", line 1307, in accepts
 self.vars.id = self.table.insert(**fields)
   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 7422, in insert
 ret =  self._db._adapter.insert(self,self._listify(fields))
   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4432, in insert
 values = dict((k.name,self.represent(v,k.type)) for k,v in fields)
   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4432, in 
 values = dict((k.name,self.represent(v,k.type)) for k,v in fields)
   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4402, in represent
 return repr(not isinstance(value,unicode) and value or 
 value.encode('utf8'))
 AttributeError: 'long' object has no attribute 'encode'

 Any suggestions on what is going wrong?

 Thanks,
 Ted




-- 





Re: [web2py] digital data store

2012-07-26 Thread José Ricardo Borba
Hi, Richard,

Is an interesting work, congratulations. I will be glad if you open
source-it.

Best regards,

José Ricardo Borba
Porto Alegre - RS - Brasil

2012/7/26 Richard Penman 

> Hello,
>
> I made this web2py app for selling digital data via PayPal:
> http://sitescraper.net/data
>
> Would appreciate feedback. If you are interested it is hosted on
> webfaction with nginx for the static content and uwsgi for web2py.
> Blog was generated with jekyll.
>
> If there is enough interest I can clean it up and open source it.
>
> I have made a few sales so far, so seems to technically work well but I am
> not a designer so looks crude.
> Anyone here good at design or can recommend someone?
>
> Richard
>
> --
>
>
>
>



-- 
José Ricardo Borba

UFRGS - Instituto de Física
L3FNano - 43173 room 101
Lab:55-51-3308-6457 / Office: 55-51-3308-6530
Mobile:55-51-8184-7649 / Fax:   55-51-3308-7286

-- 





Re: [web2py] Re: Visit Plugow on FISL13

2012-07-26 Thread vinicius...@gmail.com

We generate them using a Google API and read them using ZBar.

There are different modules in this totem. One of them is the Web2py 
part. Another is the ZBar thing.

They can be all in one machine or distributed among several ones.

But I'm not authorized to detail this implementation right now.
We'll have a presentation today on FISL, in Brazil. Maybe, after that I 
could tell you in deep details.


Keep in touch.

--
Vinicius Assef



On 07/26/2012 02:52 AM, Annet wrote:

Hi Vinicius,

I don't understand Portuguese, but it sounds like a interesting application.

I had a look at several ways to generate QRcodes, how do you generate them?
How exactly do you interact with them?

Kind regards,

Annet.

--





--





Re: [web2py] Re: Error using Scheduler with CouchDB

2012-07-26 Thread Ted Dunstone
Thanks. I'll try using SQLite and WAL - that having been said I'd still be
vote for getting the scheduler working with NoSQL (couchDB) at some stage.

Ted

On Thursday, 26 July 2012, Niphlod wrote:

> Couchdb support is still experimental in web2py. If auth is not working
> you'd likely to wait (or help Massimo with) a better implementation of the
> DAL.
>
> If you need ultra-fast tasks you'd want to use celery (or pyres, or rq).
> The current scheduler with SQLite can process ~5 tasks per second per
> single worker (YMMV for complex apps or functions). Multiple workers with
> SQLite and WAL archiving disabled is not recommended. Anyway, with WAL
> activated, I tested with no problems 8 concurrent workers with a great deal
> of tasks (~6000) with a semi-linear scalability.
> With Mysql or postgres it's possible to process tasks with even more
> concurrent workers (I'd still keep them 50 at most). The only downside of
> SQLite instead of a "full relational db" is that you can't share the db
> among different machines.
>
>
>
> On Thursday, July 26, 2012 7:03:44 AM UTC+2, Ted wrote:
>
> Hi Niphlod,
>
> Since the usecase for a Scheduler often needs concurrent fast write/reads
> and updates (from multiple clients) with information that is largely
> temporary I think a Nosql DB is a great way to handle scheduler data.
>
> In my case I don't want the overhead of installing a full relational db
> and I'm sure that the SQLite adapter will not perform well under load with
> multiple scheduler tasks.
>
> Since I posted I have tried CouchDB as my Auth db and am getting similar
> errors (at the same code point as above) about the encoding. I am using
> Python 2.6, web2py Version 2.00.0 (2012-07-18 21:46:56) dev and CouchDB
> 1.0.1.
>
> Ted
>
>
> On Thursday, July 26, 2012 2:07:17 AM UTC+7, Niphlod wrote:
>
> Scheduler was meant to run on relational dbs. Actually, I think noone ever
> tested it on Nosql adapters, but if this is a popular requirement I could
> see into it.
>
> BTW, I posted an app to test the scheduler in trunk for this kind of tests.
>
> https://groups.google.com/d/**topic/web2py/E_mASrZIpvw/**discussion
>
>
>
> On Wednesday, July 25, 2012 1:42:50 PM UTC+2, Ted wrote:
>
> Hi Web2pyers,
>
> Has anyone sucessfully used the new scheduler functionality with *
> CouchDB? *(I'm assuming this is feasible)
>
> I'm currently trying to use the scheduler on *Windows 7* with *CouchDB *as
> the DAL source.
> My code works fine with sqlite but seems to silently fail using *CouchDB*-
> although the tables are correctly created.
>
> e.g.
>
> scheduler_db = DAL('couchdb://127.0.0.1:5984'**)
> scheduler = Scheduler(scheduler_db,dict(**demo1=demo1,demo2=demo2),**
> heartbeat=1)
>
>
> (The *CouchDB* scheduler_worker table seems to mysteriously keep growing.)
>
> When I try to manually add a task through the Admin (
> http://127.0.0.1:8000/init/**appadmin/insert/scheduler_db/**scheduler_task
> )
>
> I get the following error:
>
>
> Traceback (most recent call last):
>   File "C:\Users\ted\dev\web2py\**gluon\restricted.py", line 205, in 
> restricted
>
>
> exec ccode in environment
>   File "C:/Users/ted/dev/Px/**applications/init/controllers/**appadmin.py" 
> , line 
> 270, in 
>
>
>   File "C:\Users\ted\dev\web2py\**gluon\globals.py", line 182, in 
>
>
> self._caller = lambda f:
>
>

-- 





Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-26 Thread Amit
Michele,
I tried to use simpatica, but getting error :
 DLL load failed: The operating system
cannot run %1.what i observed is this error coming wherever M2Crypto import
statement is there:

 File 
"D:/Softwares/Python2.7/web2py_src/web2py/applications/simpatica/controllers/ca.py"
,
line 27, in 
from M2Crypto import X509, RSA, EVP

File 
"D:/Softwares/Python2.7/web2py_src/web2py/applications/simpatica/controllers/public.py"
,
line 28, in 
from M2Crypto import X509, ASN1, Rand, EVP, RSA

So not able to execute it :(. I have installed
M2Crypto-0.21.1-py2.7.egg-info for windows .

I couldn't able to identify what is the exact problem, so can you
please help me to resolve it?

Thanks,
Amit



On Thu, Jul 26, 2012 at 10:50 AM, Amit  wrote:

> Thanks Michele,I am going to generate keys using simpatica, I will let you
> know if i face any problem.
>
> Thanks,
> Amit
>
>
> On Wed, Jul 25, 2012 at 7:01 PM, Michele Comitini <
> michele.comit...@gmail.com> wrote:
>
>> 2012/7/25 Amit :
>> > Michele,
>> >
>> > I have gone through the X509_Auth class and its methods :
>> >
>> > login_form
>> >
>> > login_url
>> > get_user
>> >
>> > But not able to visualize how to use this class in my model/controller,
>> I
>> > just write below what I understood, please confirm
>> > whether I understood correctly or not.
>> >
>> >
>> > My requirement is : I have one web service method add() in controller
>> > default.py , I just want to enable x509 authentication
>> > so for that purpose i will use simpatica to generate keys and
>> certificates
>> > then in model class db.py I will use below code:
>> >
>> >
>> > """
>> > Login using x509 cert from client.
>> >
>> > from gluon.contrib.login_methods.x509_auth import X509Account
>> > auth.settings.actions_disabled=['register','change_password',
>> >
>> > 'request_reset_password','profile']
>> > auth.settings.login_form = X509Account()
>> >
>> > """
>> >
>> >
>> > and then in add method I will put @auth.requires_login() annotation .
>> >
>> > My doubt:
>> > 1. how to configure certificate with Rocket and apache server?
>> > 2. how to make call of web service method with private keys from the
>> client?
>> >
>> > 3. I din't find X509Account class instead of that I found X509Auth
>> class, so
>> > is it the same, if yes then I need to create
>> >
>>
>> 1 rocket:
>>  python web2py.py  --ssl_certificate=
>> --ssl_private_key= --ca-cert=> certificate pem encoded file>
>>  apache see mod_ssl config:
>>  http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
>>
>> You can use a single file pem encoded containing: server cert, server
>> key, CA cert.  Pass it to all the options.
>>
>> 2 What is the client?  With curl:
>> curl --cert   ...
>>
>> With python:
>> you can use pycurl or httplib
>> (http://docs.python.org/library/httplib.html) see their docs.
>>
>>
>> 3 You did the right thing using X509_Auth.  The error in the comment
>> is corrected in trunk.
>>The interesting part that you may want to override in a child class
>> is the get_user() method.  Look how certificate properties are mapped
>> to the auth.user record (the profile variable that).  You may override
>> those to fit your needs.
>>
>> mic
>>
>>
>>
>> >
>> >  auth.settings.login_form = X509Auth() instance ?
>> >
>> >
>> >
>> > Thanks,
>> > Amit
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Wed, Jul 25, 2012 at 2:28 PM, Michele Comitini
>> >  wrote:
>> >>
>> >> 
>> >> simpatica
>> >>
>> >> - generate ca priv key + self signed certificate
>> >> - generate server priv keys +  certificates signed by the above ca
>> >> certificate
>> >> - generate client priv keys + certificates signed by the above ca
>> >> certificate
>> >>
>> >> The client and server certificate are generated after compilation of a
>> >> form that requires the user to assign a password to protect the
>> >> private key.
>> >> The certificate + private keys are encoded in pkcs12 format
>> >> downloadable to a browser or to be unpacked with openssl or similar
>> >> tools after providing the above password.  Remeber that if you loose
>> >> the password you cannot open the pkcs12.  There is a recovery
>> >> mechanism in simpatica since the private keys are also encoded with a
>> >> randomly generated secret that is crypted with the ca private key.
>> >> It also send emails to email associated with the client informing that
>> >> a certificate is ready to download.
>> >>
>> >> -
>> >> Sample code
>> >>
>> >>  Just look at gluon/contrib/login_methods/x509_auth.py. Look at the
>> >> docstring in the X509_Auth class and put that code in your model to
>> >> configure authentication with x509.
>> >>
>> >> Use the @auth.requires_login() annotation as you would with any action
>> >> requiring authentication. It is explained in:

[web2py] running scheduler as a windows service or background process

2012-07-26 Thread Tim Richardson
I'm confused about this topic. 
I want to run the scheduler in the background, as a windows service. web2py 
is running as a windows service.
>From reading this group, it seems that web2py's built in cron is not a 
reliable way to start the scheduler if web2py is a service. 

I know little about windows services. I see there are a few python recipes 
for making a script into a service, but I'm starting to feel like I'm 
reinventing wheels. 

-- 





Re: [web2py] markmin embed:http://... not work trunk version

2012-07-26 Thread Massimo Di Pierro
This may be considered a breaking of backward compatibility and we need to 
think about it.

Originally the emebed:... attribute was supposed to check if the link 
supports the oembed protocol and determine what to do (iframe or not) 
automatically. There is actually code in web2py 
(gluon/contrib/autolinks.py) to do this automatically but it not yet used 
by markmin.




On Thursday, 26 July 2012 00:04:21 UTC-5, dbdeveloper wrote:
>
>  Hi, Jose!
>
> try 'iframe' instead of 'embed':
>
> iframe:http://www.youtube.com/embed/x1w8hKTJ2Co
>
>
> In 1.99.7 embed looks like iframe, and iframe is not used at all (it's a 
> new feature):
>
> *>>> markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')*
> ' src="http://www.youtube.com/embed/x1w8hKTJ2Co";frameborder="0"
>  allowfullscreen>'
>
> *>>> markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')*
> 'iframe: href="http://www.youtube.com/embed/x1w8hKTJ2Co";
> >http://www.youtube.com/embed/x1w8hKTJ2Co
>
>
> in the trunk embed is simply a link with class='embed'. We need css rule 
> to make this link works:
>
> *>>> markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')*
> ' href="http://www.youtube.com/embed/x1w8hKTJ2Co";class="embed">
> http://www.youtube.com/embed/x1w8hKTJ2Co'
>
> *>>> markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')*
> ' src="http://www.youtube.com/embed/x1w8hKTJ2Co";frameborder="0"
>  allowfullscreen>'
>
>
> Vladyslav Kozlovskyy (Ukraine)
>
>
> 26.07.12 05:07, Jose написав(ла):
>  
> Hi all
>  
>  From the book:
> https://web2py.com/books/default/chapter/29/5
>  
>  The following is not working
>  
> embed:http://www.youtube.com/embed/x1w8hKTJ2Co
>
>  show me the url and not the video
>
>  I'm using the trunk version, in version 1.99.7 works well.
>
> José
>
>  -- 
>  
>  
>  
>
>
> 

-- 





[web2py] Re: field of type upload exceptions.UnboundLocalError

2012-07-26 Thread Massimo Di Pierro
yes but

elif field.type == 'upload':
f = self.vars[fieldname]
fd = '%s__delete' % fieldname
if f == '' or f is None:
...
continue

so if the user does not upload a file, the continue statement should 
prevent web2py from execute the line where you get the error. Try add a 
print f immediately after f=self.vars[fieldname].

On Thursday, 26 July 2012 01:19:07 UTC-5, Annet wrote:
>
> Massimo,
>
> It would help if you could help debug as suggested below.
>
>
> As mentioned in issue 906, I did add a print statement at line 1206:
>
> elif field.type == 'upload':
> f = self.vars[fieldname]
> fd = '%s__delete' % fieldname
>...
> print f
> newfilename = field.store(source_file, original_filename, 
> field.uploadfolder)
>
> ..., however, nothing was written to the shell when I submitted a form 
> with the field of type upload left empty. I just got the same error?
> If adding print f  and submitting the form, isn't the correct way to 
> debug, please let me know.
>
>
>  How it is possible that source_file is None?
>
> In table Person the field of type upload is optional, the error occurs 
> when the user doesn't upload a file.
>
>
> What is the value of the variable f when this happens?
>
> I don't know, the default of an empty upload field in web2py?
>
>
> It should accept any character in the original filename. If it does not, 
> where does it fail?
>
> After restarting web2py, this no longer fails.
>
>
> Kind regards,
>
> Annet
>

-- 





[web2py] Re: JSON output with referencing data

2012-07-26 Thread Massimo Di Pierro
before you serialize rows in json, you can do:

for row in rows: row.tag_names = [db.tag[id].name for is in row.tags]

This will be not efficient. depends on how many rows. Perhaps you can find 
a faster way to do the conversion.

On Wednesday, 25 July 2012 23:32:58 UTC-5, Jaymin Oh wrote:
>
> Hi, I'm Korean Web2py user.
>
>
> I'm returning output of DB select like 'return dict(teams=teams)'.
>
>
> {"teams": [{"status": "active", "updated_by": 1, "tags": [12], "max": 4, 
> "created_by": 1, }]}
>
>
> The above output is my output of 'teams' controller.
>
>
> I have several referencing column, 'tags' and 'created_by'.
>
>
> 'tags' references *tag table* and created_by references *auth table.*
>
> *
> *
>
> But I want to add name for 'tags' which exists in 'tag table' and email for 
> 'created_by' with ID which is already revealed in output.
>
>
> Any help?
>
>
> Thanks for your help in advance.
>
>
> J.Min Oh.
>
>
>
>

-- 





Re: [web2py] BR()

2012-07-26 Thread Massimo Di Pierro
{{=BR()**how_many_times}}*

On Wednesday, 25 July 2012 22:51:03 UTC-5, rochacbruno wrote:
>
> On Thu, Jul 26, 2012 at 12:39 AM, pbreit  wrote:
>
>> Wow, you would write that instead of ??
>
>
> Sometimes the repetition is a variable
>
> {{=CAT(*[BR() for i in xrange(*how_many_times*)])}} 
>  

-- 





[web2py] Re: Question on using legacy tables

2012-07-26 Thread Massimo Di Pierro
I do not know how well that works. Please let us know if there is any 
problem.

On Wednesday, 25 July 2012 22:42:39 UTC-5, tomt wrote:
>
> More good news. I discovered that this fix now allows me to use 
> SQLFORM.grid on legacy tables that don't have an 'id' field!
>
> On Wednesday, July 25, 2012 9:10:38 PM UTC-6, tomt wrote:
>>
>> I tried the latest trunk, and it solves the problem I described.  This is 
>> great and it will make it much easier for me to interact with my legacy 
>> tables.
>> I also have to thank you for the amazingly fast fix!!!
>> Thanks a lot - Tom
>>
>> On Wednesday, July 25, 2012 8:14:14 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> There is a solution in trunk. Please give it a try.
>>>
>>> On Wednesday, 25 July 2012 20:36:07 UTC-5, tomt wrote:

 Hi,
 I was using a version of trunk.  I downloaded today's version and got 
 the same error.  I opened a ticket as suggested. (Issue 908)

 On Wednesday, July 25, 2012 7:38:47 AM UTC-6, Massimo Di Pierro wrote:
>
> Please open a ticket. This can be fixed if not fixed already. Using 
> trunk or stable?
>
> On Tuesday, 24 July 2012 23:28:29 UTC-5, tomt wrote:
>>
>> I use several legacy tables in my web2py applications
>> A typical definition that I use is:
>> db2.define_table('analogpoint',
>>  Field('pointnumber','integer',writable=False),
>>  Field('pointname','string',writable=False),
>>  primarykey=['pointnumber'],
>>  migrate=False
>> )
>>
>> I can access this table with DAL:
>> info = db2(db2.analogpoint.pointnumber == point) \
>>   .select(db2.analogpoint.pointnumber,db2.analogpoint.pointname)
>>
>> but the following method generates an error:
>> temp = db2.analogpoint[1].pointname
>> KeyError: '_id'
>>
>> Is there a way to use this method on a table that doesn't have an 
>> 'id' field
>>
>> I have had success when I generate a view that includes an 'id' field
>> for every legacy table, but I would like to avoid this if possible.
>>
>> - Tom
>>
>

-- 





[web2py] is there any trick in this PaaS hosting?

2012-07-26 Thread José Luis Redrejo Rodríguez
https://console.appfog.com/pricing
Free up to 2 Gb RAM , it costs more than 50$ per month in most providers ...

I'm still looking for the trick, without success ;)

Regards
José L.

-- 





[web2py] Re: trying to use movu

2012-07-26 Thread Daniel Gonzalez
Take a look at the controllers. They are somehow disabled (they have an 
spurious x as argument, which causes them to fail). I do not know why is 
that.

On Wednesday, July 25, 2012 10:38:17 AM UTC+2, Hassan Alnatour wrote:
>
> Dear ALL , 
>
> I am Trying TO use movu from http://movu.ca and i installed PyCrypto and 
> PIL and web2py  , and did this - http://localhost:8000/demo/setup/install:
>
> but i keep getting 
> invalid function (setup/install)
>
> Why is that ??
>

-- 





Re: [web2py] Re: Suggestion - a pickled DAL field

2012-07-26 Thread Omri
I use the pickled field to store a dictionary. Since dictionary
is not defined as a serializable type for the as_dict function,
it is not returned when calling to as_dict.
Adding it (dal.py line 6183) solved my problem, but I would
like to keep this change when I update my web2py next. Is
there a different way (without changing the dal) to achieve this?
Could you add it to the dal.py? Is it without risks?

Thanks,
Omri

On Thu, Jul 26, 2012 at 9:46 AM, Omri  wrote:

> So I tried it out, and it works great, except for one thing - when I try
> to use record.as_dict() to get
> the structure which I can return to a JSON-RPC call which I normally use
> to communicate with my
> client, it simply does not return the field.
> I tried to print it out and I see very clearly that as long as it is a Row
> object there is no problem, but
> as soon as I run .as_dict() it disappears.
> My definitions are as follows:
>
> from gluon.dal import SQLCustomType
> pickled = SQLCustomType(
> type = 'text',
> native = 'text',
> encoder = (lambda x: pickle.dumps(x)),
> decoder = (lambda x: pickle.loads(x))
> )
>
> then I use
> db.define_table("my_table",
> Field("pickled_field", type=pickled)
> )
>
> but when I fetch the record it does not go to as_dict() (actually I use
> as_list() but both don't work).
>
> Any suggestions? Is there a way to teach as_dict to interpret this field
> type?
>
> Best wishes,
> Omri
>
>
> On Wed, Jul 25, 2012 at 9:20 PM, howesc  wrote:
>
>> For what it is worth i have used custom fields for this type of thing
>> with great success!
>>
>>
>> On Tuesday, July 24, 2012 8:20:03 AM UTC-7, Anthony wrote:
>>>
>>> You could use a SQLCustomType field: http://web2py.com/**
>>> books/default/chapter/29/6#**Custom-Field-types-(**experimental)
>>> .
>>>
>>> Anthony
>>>
>>> On Tuesday, July 24, 2012 8:34:07 AM UTC-4, Omri Har-Shemesh wrote:


 Hi web2pyers,

 very often, I have a field in the table which has to hold a complicated
 value (most often numpy arrays). The way I implement it is that I use
 "text" as the type of field, and then simply pickle.dumps(my_value) when
 I save the field, and then pickle.loads(value_from_db) to access the
 field
 again.

 My suggestion is simple - create field that automatically pickles the
 values
 it gets and unpickles them on extraction. Is this already implemented?
 Do you have other suggestions on how to implement this so that I won't
 need
 to pickle every time I access the table?

 Best wishes,
 Omri

>>>  --
>>
>>
>>
>>
>
>

-- 





[web2py] Re: Error using Scheduler with CouchDB

2012-07-26 Thread Niphlod
Couchdb support is still experimental in web2py. If auth is not working 
you'd likely to wait (or help Massimo with) a better implementation of the 
DAL.

If you need ultra-fast tasks you'd want to use celery (or pyres, or rq). 
The current scheduler with SQLite can process ~5 tasks per second per 
single worker (YMMV for complex apps or functions). Multiple workers with 
SQLite and WAL archiving disabled is not recommended. Anyway, with WAL 
activated, I tested with no problems 8 concurrent workers with a great deal 
of tasks (~6000) with a semi-linear scalability.
With Mysql or postgres it's possible to process tasks with even more 
concurrent workers (I'd still keep them 50 at most). The only downside of 
SQLite instead of a "full relational db" is that you can't share the db 
among different machines.



On Thursday, July 26, 2012 7:03:44 AM UTC+2, Ted wrote:
>
> Hi Niphlod,
>
> Since the usecase for a Scheduler often needs concurrent fast write/reads 
> and updates (from multiple clients) with information that is largely 
> temporary I think a Nosql DB is a great way to handle scheduler data.
>
> In my case I don't want the overhead of installing a full relational db 
> and I'm sure that the SQLite adapter will not perform well under load with 
> multiple scheduler tasks.
>
> Since I posted I have tried CouchDB as my Auth db and am getting similar 
> errors (at the same code point as above) about the encoding. I am using 
> Python 2.6, web2py Version 2.00.0 (2012-07-18 21:46:56) dev and CouchDB 
> 1.0.1.
>
> Ted
>  
>
> On Thursday, July 26, 2012 2:07:17 AM UTC+7, Niphlod wrote:
>>
>> Scheduler was meant to run on relational dbs. Actually, I think noone 
>> ever tested it on Nosql adapters, but if this is a popular requirement I 
>> could see into it.
>>
>> BTW, I posted an app to test the scheduler in trunk for this kind of 
>> tests.
>>
>> https://groups.google.com/d/topic/web2py/E_mASrZIpvw/discussion
>>
>>
>>
>> On Wednesday, July 25, 2012 1:42:50 PM UTC+2, Ted wrote:
>>>
>>> Hi Web2pyers,
>>>
>>> Has anyone sucessfully used the new scheduler functionality with *
>>> CouchDB? *(I'm assuming this is feasible)
>>>
>>> I'm currently trying to use the scheduler on *Windows 7* with *CouchDB *as 
>>> the DAL source.
>>> My code works fine with sqlite but seems to silently fail using *CouchDB
>>> *- although the tables are correctly created.
>>>
>>> e.g.
>>>
>>> scheduler_db = DAL('couchdb://127.0.0.1:5984')
>>> scheduler = 
>>> Scheduler(scheduler_db,dict(demo1=demo1,demo2=demo2),heartbeat=1) 
>>>
>>>
>>> (The *CouchDB* scheduler_worker table seems to mysteriously keep 
>>> growing.)
>>>
>>> When I try to manually add a task through the Admin (
>>> http://127.0.0.1:8000/init/appadmin/insert/scheduler_db/scheduler_task)
>>>
>>> I get the following error:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\Users\ted\dev\web2py\gluon\restricted.py", line 205, in 
>>> restricted
>>> exec ccode in environment
>>>   File "C:/Users/ted/dev/Px/applications/init/controllers/appadmin.py" 
>>> , 
>>> line 270, in 
>>>   File "C:\Users\ted\dev\web2py\gluon\globals.py", line 182, in 
>>> self._caller = lambda f: f()
>>>   File "C:/Users/ted/dev/Px/applications/init/controllers/appadmin.py" 
>>> , 
>>> line 103, in insert
>>> if form.accepts(request.vars, session):
>>>   File "C:\Users\ted\dev\web2py\gluon\sqlhtml.py", line 1307, in accepts
>>> self.vars.id = self.table.insert(**fields)
>>>   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 7422, in insert
>>> ret =  self._db._adapter.insert(self,self._listify(fields))
>>>   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4432, in insert
>>> values = dict((k.name,self.represent(v,k.type)) for k,v in fields)
>>>   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4432, in 
>>> values = dict((k.name,self.represent(v,k.type)) for k,v in fields)
>>>   File "C:\Users\ted\dev\web2py\gluon\dal.py", line 4402, in represent
>>> return repr(not isinstance(value,unicode) and value or 
>>> value.encode('utf8'))
>>> AttributeError: 'long' object has no attribute 'encode'
>>>
>>> Any suggestions on what is going wrong?
>>>
>>> Thanks,
>>> Ted
>>>
>>>
>>>

-- 





[web2py] Re: Puzzle: reference table not working?

2012-07-26 Thread David Marko

>
> Th e problem is in line default=location.id . You should set default value in 
> some controller as I expect the location id is going to be taken from some 
> request vars ...
>
>

-- 





Re: [web2py] Re: Suggestion - a pickled DAL field

2012-07-26 Thread Omri
So I tried it out, and it works great, except for one thing - when I try to
use record.as_dict() to get
the structure which I can return to a JSON-RPC call which I normally use to
communicate with my
client, it simply does not return the field.
I tried to print it out and I see very clearly that as long as it is a Row
object there is no problem, but
as soon as I run .as_dict() it disappears.
My definitions are as follows:

from gluon.dal import SQLCustomType
pickled = SQLCustomType(
type = 'text',
native = 'text',
encoder = (lambda x: pickle.dumps(x)),
decoder = (lambda x: pickle.loads(x))
)

then I use
db.define_table("my_table",
Field("pickled_field", type=pickled)
)

but when I fetch the record it does not go to as_dict() (actually I use
as_list() but both don't work).

Any suggestions? Is there a way to teach as_dict to interpret this field
type?

Best wishes,
Omri


On Wed, Jul 25, 2012 at 9:20 PM, howesc  wrote:

> For what it is worth i have used custom fields for this type of thing with
> great success!
>
>
> On Tuesday, July 24, 2012 8:20:03 AM UTC-7, Anthony wrote:
>>
>> You could use a SQLCustomType field: http://web2py.com/**
>> books/default/chapter/29/6#**Custom-Field-types-(**experimental)
>> .
>>
>> Anthony
>>
>> On Tuesday, July 24, 2012 8:34:07 AM UTC-4, Omri Har-Shemesh wrote:
>>>
>>>
>>> Hi web2pyers,
>>>
>>> very often, I have a field in the table which has to hold a complicated
>>> value (most often numpy arrays). The way I implement it is that I use
>>> "text" as the type of field, and then simply pickle.dumps(my_value) when
>>> I save the field, and then pickle.loads(value_from_db) to access the
>>> field
>>> again.
>>>
>>> My suggestion is simple - create field that automatically pickles the
>>> values
>>> it gets and unpickles them on extraction. Is this already implemented?
>>> Do you have other suggestions on how to implement this so that I won't
>>> need
>>> to pickle every time I access the table?
>>>
>>> Best wishes,
>>> Omri
>>>
>>  --
>
>
>
>

--