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

2012-07-25 Thread Michele Comitini
Amit
If you need advice with simpatica don't worry to ask.  I never had time to 
write some documentation so you have to look at the code and/or ask...

mic


Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
>
> Thanks Michele and Derek..nice post , i am looking exactly the same :)
>
> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini <
> michele.comit...@gmail.com> wrote:
>
>>
>> This is very similar to what TSL accomplishes with x509 certificates. 
>>  There is a slight difference, the server does not own a public key for 
>> each client: it verifies that the  client owns an x509 certificate signed 
>> by the correct certification authority. So no need to store public keys. 
>>  in any case AFAIK in public/private key algorithms the private key always 
>> allows generation of the corresponding public key, not the contrary of 
>> course.
>>
>> To accomplish what you need in the simplest way you have to:
>>
>> - create a certification authority with self signed certificate
>> - create certificate for you webserver signed with the private key of the 
>> certification authority above.
>> - configure your webserver to require a client certificate (with rocket 
>> look at --ca-cert option)
>> - In case you need to know some infos about the connecting client as 
>> reported in its certificate you can use x509_auth.py to use x509 
>> authentication and configure your REST action with @auth.requires_login(). 
>>  This will give you access to  information contained in the certificate 
>> such common name or serial id.  To customize you can extend the X509_Auth 
>> class. 
>>
>> To generate test certificates fast you can use simpatica as Derek 
>> correctly suggests.
>>
>> mic
>>
>> Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
>>
>>> Hi,
>>> I have to provide public/private key authentication for accessing web 
>>> service (REST) from client in my web2py application.How to achieve it?
>>>
>>> Scenario: 
>>> 1.Each client will have unique private key which will be sent to the 
>>> server alongwith request.
>>> 2. Server has to authenticate private key using public key(unique for 
>>> each client) and then allow to access the web service method. For e.g. 
>>> suppose one client say X has requested for web service "add()" so server 
>>> has to first validate the public key with client's private key and if 
>>> validation is successful then allow to access the web service "add()".
>>>
>>> Challenges:
>>> where to store public key of each client?we can't store it in the db 
>>> because server can't access db before validation of web service method.So 
>>> will it be store somewhere in PC(where server is running)?if yes then how 
>>> and which format? 
>>>
>>>
>>> NOTE: Here Server will be completely written in web2py and client is 
>>> separate application running on the hardware device.
>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
Quick update: 

-* I had another report of this happening during the night*. I have 
disabled everything past the main page until I can get to the bottom of this
- Waiting for more information from the user. i.e. to get their platform 
and the link they clicked
- I know that the user they were erroneously logged in as had been active 
on the site around the time.
- I rolled back to stable before this happened, so it isn't a problem with 
trunk
- Using webfaction/nginx/uwsgi (ver 1.2.4)

Neil


On Tuesday, July 24, 2012 11:53:26 PM UTC+1, Craig Younkins wrote:
>
> What is the deployment configuration? What wsgi server and what web server?
>
> Craig Younkins
>
>
> On Tue, Jul 24, 2012 at 5:55 PM, Massimo Di Pierro  wrote:
>
>> Is there an open issue about this? If not, can you open one with more 
>> details?
>>
>>
>> On Tuesday, 24 July 2012 16:31:52 UTC-5, howesc wrote:
>>
>>> one other scenario..
>>>
>>> i reported a few months back that running web2py on GAE with python2.7 
>>> and multi-threading had odd behaviors with the globals (request, response, 
>>> session).  i have yet tracked down the issues i was having (might have been 
>>> a coding error on my part).but if you are using GAE + multithreading 
>>> i'd be interested to know that.
>>>
>>> cfh
>>>
>>> On Tuesday, July 24, 2012 1:26:21 PM UTC-7, Massimo Di Pierro wrote:

 Perhaps it would be safe to block access to the site if request.client 
 is "unknown".
 I think we should change web2py to block access to any web2py app if 
 request.client does not validate as an IP address.

 Massimo

 On Tuesday, 24 July 2012 15:24:06 UTC-5, Massimo Di Pierro wrote:
>
> Here is a possible cause of the problem although I am not sure.
> There are two possible issues which may conspire to create this 
> problem.
>
> Issue #1
> ===
>
> There is a session file in the app you sent me called:
>
> unknown-c4571a37...
>
> session files should be
>
> -.
>
> This means that one of the HEADERS http_x_forwarded_for or remote_addr 
> has a value "unknown". 
>
> A first google search retuned:
> http://nixforums.org/**about154671-Hacking-X-**Forwarded-For.html
> which opens the possibility the the web server, in your case nginx, is 
> not finding the client ip address (how is that possible) and setting it 
> to 
> unknown. This should never happen. The client_addr is a required field 
> for 
> WSGI.
>
> This could be the result of a hacking attempt but it would required 
> both parties doing the hacking for the sessions to be mixed up.
>
> Issue #2
> ===
>
> There is a bug with may prevent urandom from working:
>
> http://community.webfaction.**com/questions/9333/**
> importerror-cannot-import-**name-urandom
> http://stackoverflow.com/**questions/10776797/error-when-**
> importing-wsgihandler-with-**django
>
> Can you check if you can import urandom on your version of python on 
> webfaction?
>
>
> It is therefore theoretically possible that, given the concurrency 
> model of nginx, if two users visit the site very close to each other, 
> with 
> urandom missing, both declaring the same incorrect client ip (unknown), 
> they get assigned the same session id. This is because web2py has no way 
> of 
> distinguishing the two users and lacks a proper random number generator.
>
> TODO:
>
> 1) check if you can import urandom
> 2) try understand how it possible to have an "unkown" client_addr in 
> the http headers. 
>
> My google search returned nothing about 2. Has anybody ever seen this 
> before?
> Please let us know.
>
>
>
>
>
>
>
>
>
> On Tuesday, 24 July 2012 14:50:04 UTC-5, Massimo Di Pierro wrote:
>>
>> Nothing stands out from your code. It is very good code. You have 
>> changed to gluon/tools.py but I do not think they can be causing this 
>> problem.
>>
>> On Tuesday, 24 July 2012 14:48:16 UTC-5, Massimo Di Pierro wrote:
>>>
>>> I should add that the conflict I mentioned below is not possible 
>>> unless there is a proxy in between. That is because the session id 
>>> includes 
>>> the client IP.
>>>
>>> I really do not see how this problem can be possible. Are you sure 
>>> they are not playing a prank on you? If they share a facebook page 
>>> perhaps 
>>> they know each other. I have to ask but we will keep investigating the 
>>> issue very seriously nevertheless.
>>>
>>> For now I suggest you add this to your c

[web2py] Re: SQLFORM.grid pagination refresh

2012-07-25 Thread dave
ok so this is what I have for the view


 $('#input4').keyup(function(){
 input_value = $("#input4").val();
 web2py_component('{{=URL("default", "ajaxTable3.load")}}' + '?count=' 
+ input_value, 'grid');
 });


and this is the controller function

def ajaxTable3():
query = (db.applicant.id > 0) & (db.applicant.id < request.vars.count')
grid = SQLFORM.grid(query, searchable=False, csv=False)
return grid

now if I replace request.vars.count with just a number, like say 60 the 
page works fine and it pulls the records, and no problem with the pagination
but with request.vars.count, when I click the pagination, I get this error 
--> 
 Cannot compare applicant.id < None

which I think is because of request.vars.count is not set when the 
pagination is clicked I guess? 

-- 





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

2012-07-25 Thread Amit
sure Michele, let me go through the code,If i am not wrong simpatica is to
generate the certificate file for the client and if you are having any
sample code to use x509 in case of web service then please do share with me.

Thanks,
Amit

On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> Amit
> If you need advice with simpatica don't worry to ask.  I never had time to
> write some documentation so you have to look at the code and/or ask...
>
> mic
>
>
> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
>
>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
>>
>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini <
>> michele.comit...@gmail.com> wrote:
>>
>>>
>>> This is very similar to what TSL accomplishes with x509 certificates.
>>>  There is a slight difference, the server does not own a public key for
>>> each client: it verifies that the  client owns an x509 certificate signed
>>> by the correct certification authority. So no need to store public keys.
>>>  in any case AFAIK in public/private key algorithms the private key always
>>> allows generation of the corresponding public key, not the contrary of
>>> course.
>>>
>>> To accomplish what you need in the simplest way you have to:
>>>
>>> - create a certification authority with self signed certificate
>>> - create certificate for you webserver signed with the private key of
>>> the certification authority above.
>>> - configure your webserver to require a client certificate (with rocket
>>> look at --ca-cert option)
>>> - In case you need to know some infos about the connecting client as
>>> reported in its certificate you can use x509_auth.py to use x509
>>> authentication and configure your REST action with @auth.requires_login().
>>>  This will give you access to  information contained in the certificate
>>> such common name or serial id.  To customize you can extend the X509_Auth
>>> class.
>>>
>>> To generate test certificates fast you can use simpatica as Derek
>>> correctly suggests.
>>>
>>> mic
>>>
>>> Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
>>>
 Hi,
 I have to provide public/private key authentication for accessing web
 service (REST) from client in my web2py application.How to achieve it?

 Scenario:
 1.Each client will have unique private key which will be sent to the
 server alongwith request.
 2. Server has to authenticate private key using public key(unique for
 each client) and then allow to access the web service method. For e.g.
 suppose one client say X has requested for web service "add()" so server
 has to first validate the public key with client's private key and if
 validation is successful then allow to access the web service "add()".

 Challenges:
 where to store public key of each client?we can't store it in the db
 because server can't access db before validation of web service method.So
 will it be store somewhere in PC(where server is running)?if yes then how
 and which format?


 NOTE: Here Server will be completely written in web2py and client is
 separate application running on the hardware device.

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

-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
Incidentally, no problems importing urandom.

On Wednesday, July 25, 2012 8:10:53 AM UTC+1, Neil wrote:
>
>
>> Issue #2
>> ===
>>
>> There is a bug with may prevent urandom from working:
>>
>> http://community.webfaction.**com/questions/9333/**
>> importerror-cannot-import-**name-urandom
>> http://stackoverflow.com/**questions/10776797/error-when-**
>> importing-wsgihandler-with-**django
>>
>> Can you check if you can import urandom on your version of python on 
>> webfaction?
>>
>>
>>

-- 





[web2py] trying to use movu

2012-07-25 Thread Hassan Alnatour
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] prettydate question

2012-07-25 Thread ctrlSoft


On Tuesday, July 24, 2012 5:58:16 PM UTC+3, dbdeveloper wrote:
>
>  ctrlSoft, is issue still present ?
>
> Vladyslav Kozlovskyy (Ukraine)
>
> 23.07.12 13:32, ctrlSoft написав(ла):
>  
> datetime format is: 2012-07-18 10:00:00  
>  
>  hi in view i have following code:
> {{=prettydate(row.deadline,T)}}
>
>  but result is :
> %d days ago 
>  %d days ago  
> %d days ago   
>  %d days ago   
>  ...
> 1 week ago
> 1 week ago
> ...
> %d weeks ago 
>  %d weeks ago 
>  %d weeks ago 
>  
>  how to display 
> 4 days ago
> 5 days ago
> ...
> 2 weeks ago
> 3 weeks ago
> ... 
> ...
>
>  -- 
>  
>  
> ( web2py version is from trunk.) i tried Bruno solution 
> {{=prettydate(row.deadline, lambda x: x)}}  and it works...
>
>  
 

-- 





Re: [web2py] Re: SQLFORM.grid pagination refresh

2012-07-25 Thread Alec Taylor
query = (db.applicant.id > 0) & (db.applicant.id < (request.vars.count
or 60)')

On Wed, Jul 25, 2012 at 5:13 PM, dave  wrote:

> ok so this is what I have for the view
>
> 
>  $('#input4').keyup(function(){
>  input_value = $("#input4").val();
>  web2py_component('{{=URL("default", "ajaxTable3.load")}}' + '?count='
> + input_value, 'grid');
>  });
> 
>
> and this is the controller function
>
> def ajaxTable3():
> query = (db.applicant.id > 0) & (db.applicant.id <
> request.vars.count')
> grid = SQLFORM.grid(query, searchable=False, csv=False)
> return grid
>
> now if I replace request.vars.count with just a number, like say 60 the
> page works fine and it pulls the records, and no problem with the pagination
> but with request.vars.count, when I click the pagination, I get this error
> -->
>  Cannot compare applicant.id < None
>
> which I think is because of request.vars.count is not set when the
> pagination is clicked I guess?
>
> --
>
>
>
>

-- 





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

2012-07-25 Thread Michele Comitini

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:

http://web2py.com/books/default/chapter/29/10?search=rest#Access-Control


mic


2012/7/25 Amit :
> sure Michele, let me go through the code,If i am not wrong simpatica is to
> generate the certificate file for the client and if you are having any
> sample code to use x509 in case of web service then please do share with me.
>
> Thanks,
> Amit
>
>
> On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini
>  wrote:
>>
>> Amit
>> If you need advice with simpatica don't worry to ask.  I never had time to
>> write some documentation so you have to look at the code and/or ask...
>>
>> mic
>>
>>
>> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
>>>
>>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
>>>
>>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini
>>>  wrote:


 This is very similar to what TSL accomplishes with x509 certificates.
 There is a slight difference, the server does not own a public key for each
 client: it verifies that the  client owns an x509 certificate signed by the
 correct certification authority. So no need to store public keys.  in any
 case AFAIK in public/private key algorithms the private key always allows
 generation of the corresponding public key, not the contrary of course.

 To accomplish what you need in the simplest way you have to:

 - create a certification authority with self signed certificate
 - create certificate for you webserver signed with the private key of
 the certification authority above.
 - configure your webserver to require a client certificate (with rocket
 look at --ca-cert option)
 - In case you need to know some infos about the connecting client as
 reported in its certificate you can use x509_auth.py to use x509
 authentication and configure your REST action with @auth.requires_login().
 This will give you access to  information contained in the certificate such
 common name or serial id.  To customize you can extend the X509_Auth class.

 To generate test certificates fast you can use simpatica as Derek
 correctly suggests.

 mic

 Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
>
> Hi,
> I have to provide public/private key authentication for accessing web
> service (REST) from client in my web2py application.How to achieve it?
>
> Scenario:
> 1.Each client will have unique private key which will be sent to the
> server alongwith request.
> 2. Server has to authenticate private key using public key(unique for
> each client) and then allow to access the web service method. For e.g.
> suppose one client say X has requested for web service "add()" so server 
> has
> to first validate the public key with client's private key and if 
> validation
> is successful then allow to access the web service "add()".
>
> Challenges:
> where to store public key of each client?we can't store it in the db
> because server can't access db before validation of web service method.So
> will it be store somewhere in PC(where server is running)?if yes then how
> and which format?
>
>
> NOTE: Here Server will be completely written in web2py and client is
> separate application running on the hardware device.
>
 --



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

-- 





[web2py] Re: Best way to mix people and organizations on the same view? Opinions, please.

2012-07-25 Thread Annet
Hi Cliff,

Sorry for my late reply and incomplete first answer:

Table node contains a computed field. See manual: Notice that the computed 
value is stored in the db and it is not computed on retrieval, as in the 
case of virtual fields, described later. A typical application of computed 
fields is: for searching, to compute normalized values for a field, to be 
used for searching.

In the query I left join organization, person an connector with node and 
sort by db.node.computedName. In the view organization and person details 
are treated differently, therefore I use row.organization.name, 
row.person.first_name and row.person.last_name and row.connector.name.

When a user updates organization, person or connector, the node computed 
field is updated by calling updateComptedName(form) on accept:

form=crud.update(...,onaccept=lambda form:updateComputedName(form),...)


Kind regards,

Annet

-- 





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

2012-07-25 Thread 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

 auth.settings.login_form = X509Auth() instance ?


Thanks,
Amit















On Wed, Jul 25, 2012 at 2:28 PM, Michele Comitini <
michele.comit...@gmail.com> 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:
>
> http://web2py.com/books/default/chapter/29/10?search=rest#Access-Control
>
>
> mic
>
>
> 2012/7/25 Amit :
> > sure Michele, let me go through the code,If i am not wrong simpatica is
> to
> > generate the certificate file for the client and if you are having any
> > sample code to use x509 in case of web service then please do share with
> me.
> >
> > Thanks,
> > Amit
> >
> >
> > On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini
> >  wrote:
> >>
> >> Amit
> >> If you need advice with simpatica don't worry to ask.  I never had time
> to
> >> write some documentation so you have to look at the code and/or ask...
> >>
> >> mic
> >>
> >>
> >> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
> >>>
> >>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
> >>>
> >>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini
> >>>  wrote:
> 
> 
>  This is very similar to what TSL accomplishes with x509 certificates.
>  There is a slight difference, the server does not own a public key
> for each
>  client: it verifies that the  client owns an x509 certificate signed
> by the
>  correct certification authority. So no need to store public keys.  in
> any
>  case AFAIK in public/private key algorithms the private key always
> allows
>  generation of the corresponding public key, not the contrary of
> course.
> 
>  To accomplish what you need in the simplest way you have to:
> 
>  - create a certification authority with self signed certificate
>  - create certificate for you webserver signed with the private key of
>  the certification authority above.
>  - configure your webserver to require a client certificate (with
> rocket
>  look at --ca-cert option)
>  - In case you need to know some infos about the connecting client as
>  reported in its certificate you can use x509_auth.py to use x509
>  authentication and configure your REST action with
> @auth.requires_login().
>  This will give you access to  information contained in the
> certificate such
>  common name or serial id.  To customize you can extend the X509_Auth
> class.
> 
>  To generate test certificates fast you can use simpatica as Derek
>  correctly suggests.
> 
>  mic
> 
>  Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
> >
> > Hi,
> > I have to provide pub

Re: [web2py] Re: SQLFORM.grid pagination refresh

2012-07-25 Thread dave
I actually dont want 60, I just gave that as an example

-- 





Re: [web2py] displacement of password button [web2py twitter bootstrap]

2012-07-25 Thread Simon Ashley
Negative on that. 
Still have an issue from the most currently nightly build. 
Has anyone tracked down precisely what's causing it?

TIA,

-- 





Re: [web2py] prettydate question

2012-07-25 Thread ctrlSoft
but with translation wont work, i have al translation files in languages 
folder.

-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
Perhaps a coincidence, but:

User 1 - Accessed my site through a Facebook link on iPhone
User 2 - Accessed my site through a Facebook link on iPad

Does FB do anything strange with links to external sites that could cause 
the request.client to be unknown? I've accessed my site through the FB link 
using my Android mobile, and no noticeable problems.

On Wednesday, July 25, 2012 9:27:36 AM UTC+1, Neil wrote:
>
> Incidentally, no problems importing urandom.
>
> On Wednesday, July 25, 2012 8:10:53 AM UTC+1, Neil wrote:
>>
>>
>>> Issue #2
>>> ===
>>>
>>> There is a bug with may prevent urandom from working:
>>>
>>> http://community.webfaction.**com/questions/9333/**
>>> importerror-cannot-import-**name-urandom
>>> http://stackoverflow.com/**questions/10776797/error-when-**
>>> importing-wsgihandler-with-**django
>>>
>>> Can you check if you can import urandom on your version of python on 
>>> webfaction?
>>>
>>>
>>>

-- 





Re: [web2py] Re: Empty Database value is not None, but an empty string

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

Sorry, but I cannot figure out why this is happening.

Here, my data becomes None if I do this. I'm using SQLite.
If you define a fresh new table in your db.py with just one string 
field, just using default configs, this problem still happens?


--
Vinicius Assef


On 07/25/2012 12:31 AM, Mark Li wrote:

Anthony, I tried

|
db.mytable.import_from_csv_file([file object],null='')
|

from the web2py shell, but it gave me an error:

OperationalError: near ")": syntax error


In fact, trying to import from csv using the book's method does not work
at all, although exporting works fine.


Viniciusban, I'm inserting data through the database administation
interface (filling out the form). I've also tried importing the CSV file
through the administrative interface as well, where all blank spaces in
the csv some out to empty strings (unless the field type is 'integer').



On Monday, July 23, 2012 10:47:24 PM UTC-7, viniciusban wrote:

Yes, they are default settings.

It's quite strange you get empty strings instead null (None, in
Python).

How are you inserting data into db? Are you using a SQLFORM or
my_table.validate_and_insert() or simply mytable.insert()?

Do you get same results (blank values) inserting it from web2py shell
using simply mytable.insert()?

--
Vinicius Assef


> On Monday, July 23, 2012 5:58:19 PM UTC-4, Mark Li wrote:
>
> Aren't those the default values for a Field Contructor? I tried
> explicitly adding "notnull=False" and "required=False", and didn't
> set the default property, but empty values still come out as an
> empty string instead of None.
>
> On Monday, July 23, 2012 2:48:56 PM UTC-7, viniciusban wrote:
>
> As far as I know, let "notnull=False" and "required=False" for 
your
> fields and don't set "default" property.
>
>
>
> On 07/23/2012 06:32 PM, Mark Li wrote:
> > Unfortunately the lambda method didn't work, Anthony. Any other 
ideas
> > for having a None default for empty entries?
> >
> >
> > On a side note, if the 'integer' field type is used, then a 
blank entry
> > results in a None. Don't know if that helps but it's something 
I've noticed.
> >
> > On Monday, July 23, 2012 2:07:51 PM UTC-7, Anthony wrote:
> >
> > To enter a value of None, this might work:
> >
> > |
> > default=lambda:None
> > |
> >
> > Anthony
> >
> > On Monday, July 23, 2012 5:04:44 PM UTC-4, Anthony wrote:
> >
> > default=None means that no default is specified, not 
that a
> > default value of None will be inserted.
> >
> > Anthony
> >
> > On Monday, July 23, 2012 5:02:33 PM UTC-4, Mark Li 
wrote:
> >
> > I have a table defined in the following manner:
> >
> > db.define_table('songinfo',
> > Field('songtitle'),
> > Field('artist'))
> >
> > When I add an empty entry, or upload a CSV with 
empty
> > values, I can only access those values with a 
database call like
> >
> > songs = db(db.songinfo.artist=="").select()
> >
> > as opposed to db(db.songinfo.artist==None).select()
> >
> >
> > The web2py book states that fields default=None, 
but I'm
> > getting an empty string. Is there an appropriate 
way to have
> > None instead of an empty string in the database?
> >
> >
> > --
> >
> >
> >
>
> --
>
>
>

--





--





Re: [web2py] Re: Posgresql's full text search capabilities and DAL

2012-07-25 Thread Johann Spies
Hallo Massimo,

Long ago you reacted to an email by me:

On 1 December 2010 17:53, mdipierro  wrote:

> The query is easy:
>
> db("@@ to_tsquery('%s');" % title_body.replace("'","''")).select()
>
> to generate the table you need SQLCustomField and the compute
> attribute.
> Give it a try and please report back. I am very much interested in
> this issue.
>
>
>
>
> On Dec 1, 6:32 am, Johann Spies  wrote:
> > How do I handle the following PostgreSQL function in Web2py?
> >
> > ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;
> > UPDATE pgweb SET textsearchable_index_col =
> >  to_tsvector('english', coalesce(title,'') || ' ' ||
> coalesce(body,''));
> >
> > I know I can use executesql for creating the indexes but in some cases
> > it is preferable to create a column with the type 'tsvector' as in the
> > example above or in the one below:
> >
> > CREATE TABLE messages (
> > title   text,
> > bodytext,
> > tsv tsvector
> > );
> >
> > And then how do I handle queries like this?
> >
> > SELECT title, body FROM messages WHERE tsv @@ to_tsquery('title & body');
> >
>

I am making some progress and could get full text search to work in the
following way:

In Web2py:

from gluon.dal import SQLCustomType

Add a  definition:

 tsv = SQLCustomType(
  type ='text',
  native='tsvector' )

Add field to model:

 Field('tsv',type=tsv)

Then in postgresql:

UPDATE akb_articles SET tsv= to_tsvector('simple', coalesce(title,'') || '
' || coalesce (abstract,''))  where tsv is null;

CREATE INDEX art_tsv_idx ON akb_articles  USING gin(tsv);

CREATE OR REPLACE FUNCTION bou_art_tsv()
  RETURNS trigger AS
$BODY$
begin
new.tsv :=
to_tsvector(coalesce(new.title,'')) ||
to_tsvector(coalesce(new.abstract,''));
return new;
end

CREATE TRIGGER tsvectorupdate
  BEFORE INSERT OR UPDATE
  ON akb_articles
  FOR EACH ROW
  EXECUTE PROCEDURE bou_art_tsv();


Now I can do build and execute a query like this:

q = "akb_articles.tsv@@'%s'"
s = 'water&(navors | research)'
query = q % s

l= db(query).select(db.akb_articles.title)

But I cannot do

==
In [48]: fields = [db.akb_articles.title]
fields = [db.akb_articles.title]

In [50]: b = SQLFORM.grid(query, fields=fields)
b = SQLFORM.grid(query, fields=fields)
---
AttributeErrorTraceback (most recent call last)
/home/js/web2py/applications/akb/models/wbank.py in ()
> 1 b = SQLFORM.grid(query, fields=fields)

/home/js/web2py/gluon/sqlhtml.pyc in grid(query, fields, field_id, left,
headers, orderby, groupby, searchable, sortable, paginate, deletable,
editable, details, selectable, create, csv, links, links_in_grid, upload,
args, user_signature, maxtextlengths, maxtextlength, onvalidation,
oncreate, onupdate, ondelete, sorter_icons, ui, showbuttontext, _class,
formname, search_widget, ignore_rw, formstyle, exportclasses, formargs,
createargs, editargs, viewargs)
   1543
   1544 from gluon import current, redirect
-> 1545 db = query._db
   1546 T = current.T
   1547 request = current.request

AttributeError: 'str' object has no attribute '_db'
=
Is there a way to get this type of query to work with SQLFORM.grid?

Regards
Johann

-- 





[web2py] db.mytable.myfield.contains('value') doesn't work?

2012-07-25 Thread Alec Taylor
Unsure as to why this isn't working, it looks the same as the examples in 
the DAL chapter:

search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
if search_form.process().accepted:
session.search_term = search_form.vars.search_term
#query = ( db.group_of_events.group_name.contains(session.search_term) 
| db.group_of_events.group_desc.contains(session.search_term)  | 
db.group_of_events.group_tags.contains(session.search_term) )
rows = 
db(db.group_of_events.group_name.contains(session.search_term)).select()
return dict(search_terms=rows)


I'm getting a:
 CONTAINS() takes exactly 3 arguments (2 given)

What am I doing wrong?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] db.mytable.myfield.contains('value') doesn't work?

2012-07-25 Thread Johann Spies
On 25 July 2012 13:38, Alec Taylor  wrote:

> Unsure as to why this isn't working, it looks the same as the examples in
> the DAL chapter:
>
> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
> if search_form.process().accepted:
> session.search_term = search_form.vars.search_term
> #query = ( 
> db.group_of_events.group_name.contains(session.search_term) | 
> db.group_of_events.group_desc.contains(session.search_term)  | 
> db.group_of_events.group_tags.contains(session.search_term) )
> rows = 
> db(db.group_of_events.group_name.contains(session.search_term)).select()
> return dict(search_terms=rows)
>
>
> I'm getting a:
>  CONTAINS() takes exactly 3 arguments (2
> given)
>
> What am I doing wrong?
>
>
Where does search_form.form.vars.search_term come from?   You defined a
field with a name 'Search', not 'search_term' .

Regards
Johann

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

-- 





[web2py] update progress to user

2012-07-25 Thread Janath
Hi,

One function of my application involves running a set of algorithms which 
takes longer. Last time it took abt 10 minutes. And having executed it in 
another machine, I thought there was an error in processing, but it had ran 
perfectly when I checked in server. To avoid this confusing situation, I 
would like to update user with the progress during the run time of the 
algorithm, I have two variables depending updated on run time on which that 
I can report the progress to the user. 

I have almost no experience in using ajax or java script in web2py. I had a 
look at some of the similar threads but was not able to capture the idea.

Any support is appreciated.

Janath


-- 





Re: [web2py] Re: Cookbook Chapter 2 - Reddit clone Ajax problem

2012-07-25 Thread villas
Right, I wondered why.

I also found this code in layout to be a 'challenge':

  middle_columns = {0:'span12',1:'span9',2:'span6'}[
(left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)]
  }}

It took me a while to figure out what was going on there -- it seems very 
clever and concise,  but perhaps not the most readable code!  (for me at 
least).


On Tuesday, July 24, 2012 11:07:34 PM UTC+1, Jonathan Lundell wrote:
>
> On 24 Jul 2012, at 2:57 PM, villas wrote:
>
> But why not this which seems much more readble?
>
> value = +1 if mode == 'plus' else -1
>
>
> Originally for compatibility with Python 2.4. Not sure how much of a 
> priority that is these days...
>
>
>
>
> On Tuesday, July 24, 2012 10:20:51 PM UTC+1, pjryan126 wrote:
>>
>> I'm working through this same example, and I'm having trouble 
>> understanding how the following resolves:
>>
>> value = (mode=='plus') and +1 or -1
>>
>> Can anyone explain to me what is happening with this line of code?
>>
>>
>> On Monday, March 26, 2012 10:28:27 AM UTC-4, Omi Chiba wrote:
>>>
>>> OK it worked !
>>>
>>> The indent for last three line was wrong on book and it was fixed on the 
>>> downloaded code.
>>>
>>>
>>>
>>> On Friday, March 23, 2012 6:18:36 PM UTC-5, Omi Chiba wrote:

 Alan, 

 Thanks. Good idea. I will try the support files. 


 Sent from my Verizon Wireless BlackBerry 

>>>
>
>
>

-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
Could this be related?

http://stackoverflow.com/questions/11092444/nginx-keeps-passing-the-same-http-cookie-to-uwsgi
 

It's a little beyond me, but I notice that HTTP_REFERER is facebook in both 
cases, and they are also using nginx+uwsgi.

On Wednesday, July 25, 2012 12:07:26 PM UTC+1, Neil wrote:
>
> Perhaps a coincidence, but:
>
> User 1 - Accessed my site through a Facebook link on iPhone
> User 2 - Accessed my site through a Facebook link on iPad
>
> Does FB do anything strange with links to external sites that could cause 
> the request.client to be unknown? I've accessed my site through the FB link 
> using my Android mobile, and no noticeable problems.
>
> On Wednesday, July 25, 2012 9:27:36 AM UTC+1, Neil wrote:
>>
>> Incidentally, no problems importing urandom.
>>
>> On Wednesday, July 25, 2012 8:10:53 AM UTC+1, Neil wrote:
>>>
>>>
 Issue #2
 ===

 There is a bug with may prevent urandom from working:

 http://community.webfaction.**com/questions/9333/**
 importerror-cannot-import-**name-urandom
 http://stackoverflow.com/**questions/10776797/error-when-**
 importing-wsgihandler-with-**django

 Can you check if you can import urandom on your version of python 
 on webfaction?




-- 





[web2py] Re: bootstrap and user panel

2012-07-25 Thread Alan Etkin
Buenísimas las dos aplicaciones. ¿No se puede integrar el manejo de las 
tablas auth_ con appadmin como una funcionalidad más?

*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] db.mytable.myfield.contains('value') doesn't work?

2012-07-25 Thread Alec Taylor
Thanks for that, that solved the error, however a strange result is now 
occurring, always None; even when using the exact name is specified:

def search():
search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))

search_result=None
if search_form.process().accepted:
session.search_term = search_form.vars
query = ( db.group_of_events.group_name.contains(session.search_term) | 
db.group_of_events.group_desc.contains(session.search_term)  | 
db.group_of_events.group_tags.contains(session.search_term) )
search_result = db(query).select()

return dict(search_form=search_form,  search_result=search_result)


Note: I've confirmed that it's received the correct term by returning `
search_result=session.search_term`.

Did I misrepresent the query?

On Wednesday, July 25, 2012 9:52:00 PM UTC+10, Johann Spies wrote:
>
> On 25 July 2012 13:38, Alec Taylor  wrote:
>
>> Unsure as to why this isn't working, it looks the same as the examples in 
>> the DAL chapter:
>>
>> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
>> if search_form.process().accepted:
>> session.search_term = search_form.vars.search_term
>> #query = ( 
>> db.group_of_events.group_name.contains(session.search_term) | 
>> db.group_of_events.group_desc.contains(session.search_term)  | 
>> db.group_of_events.group_tags.contains(session.search_term) )
>> rows = 
>> db(db.group_of_events.group_name.contains(session.search_term)).select()
>> return dict(search_terms=rows)
>>
>>
>> I'm getting a:
>>  CONTAINS() takes exactly 3 arguments (2 
>> given)
>>
>> What am I doing wrong?
>>
>>
> Where does search_form.form.vars.search_term come from?   You defined a 
> field with a name 'Search', not 'search_term' .
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





[web2py] "Internal error" on every page, can't even access admin

2012-07-25 Thread Alec Taylor
I'm getting an annoying "Internal error" message on every page, with a link 
to the ticket it issued. Unfortunately following that link presents me with 
another "Internal error" page.

Could this be a web-server issue, e.g.: out of memory?

Would it be possible to open the ticket over SSH?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] db.mytable.myfield.contains('value') doesn't work?

2012-07-25 Thread Anthony
Perhaps:

session.search_term = search_form.vars

should be:

session.search_term = search_form.vars.Search

Anthony

On Wednesday, July 25, 2012 8:55:39 AM UTC-4, Alec Taylor wrote:
>
> Thanks for that, that solved the error, however a strange result is now 
> occurring, always None; even when using the exact name is specified:
>
> def search():
> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
>
> search_result=None
> if search_form.process().accepted:
> session.search_term = search_form.vars
> query = ( db.group_of_events.group_name.contains(session.search_term) 
> | db.group_of_events.group_desc.contains(session.search_term)  | 
> db.group_of_events.group_tags.contains(session.search_term) )
> search_result = db(query).select()
> 
> return dict(search_form=search_form,  search_result=search_result)
>
>
> Note: I've confirmed that it's received the correct term by returning `
> search_result=session.search_term`.
>
> Did I misrepresent the query?
>
> On Wednesday, July 25, 2012 9:52:00 PM UTC+10, Johann Spies wrote:
>>
>> On 25 July 2012 13:38, Alec Taylor  wrote:
>>
>>> Unsure as to why this isn't working, it looks the same as the examples 
>>> in the DAL chapter:
>>>
>>> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
>>> if search_form.process().accepted:
>>> session.search_term = search_form.vars.search_term
>>> #query = ( 
>>> db.group_of_events.group_name.contains(session.search_term) | 
>>> db.group_of_events.group_desc.contains(session.search_term)  | 
>>> db.group_of_events.group_tags.contains(session.search_term) )
>>> rows = 
>>> db(db.group_of_events.group_name.contains(session.search_term)).select()
>>> return dict(search_terms=rows)
>>>
>>>
>>> I'm getting a:
>>>  CONTAINS() takes exactly 3 arguments (2 
>>> given)
>>>
>>> What am I doing wrong?
>>>
>>>
>> Where does search_form.form.vars.search_term come from?   You defined a 
>> field with a name 'Search', not 'search_term' .
>>
>> Regards
>> Johann
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>

-- 





Re: [web2py] displacement of password button [web2py twitter bootstrap]

2012-07-25 Thread Kevin Miller
To me it seems like it was the placement of the welcome message that caused
the problem. In the latest build the welcome message is now in the same
line as the other auth links.

Are you sure you are using the most current build? If you were using a
previous build you should probably clear your browsing data and refresh.

Not sure why you are still having the problem. Is it in both browsers or
just google chrome?




On Wed, Jul 25, 2012 at 5:57 AM, Simon Ashley wrote:

> Negative on that.
> Still have an issue from the most currently nightly build.
> Has anyone tracked down precisely what's causing it?
>
> TIA,
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Empty Database value is not None, but an empty string

2012-07-25 Thread Anthony
Can you attach a sample CSV file that fails, and show your table model code 
as well as any code used to do the import?

Anthony

On Tuesday, July 24, 2012 11:31:27 PM UTC-4, Mark Li wrote:
>
> Anthony, I tried
>
> db.mytable.import_from_csv_file([file object], null='')
>
> from the web2py shell, but it gave me an error:
>
> OperationalError: near ")": syntax error
>
>
> In fact, trying to import from csv using the book's method does not work 
> at all, although exporting works fine.
>
>
> Viniciusban, I'm inserting data through the database administation 
> interface (filling out the form). I've also tried importing the CSV file 
> through the administrative interface as well, where all blank spaces in the 
> csv some out to empty strings (unless the field type is 'integer').
>
>
>
> On Monday, July 23, 2012 10:47:24 PM UTC-7, viniciusban wrote:
>>
>> Yes, they are default settings. 
>>
>> It's quite strange you get empty strings instead null (None, in Python). 
>>
>> How are you inserting data into db? Are you using a SQLFORM or 
>> my_table.validate_and_insert() or simply mytable.insert()? 
>>
>> Do you get same results (blank values) inserting it from web2py shell 
>> using simply mytable.insert()? 
>>
>> -- 
>> Vinicius Assef 
>>
>>
>> > On Monday, July 23, 2012 5:58:19 PM UTC-4, Mark Li wrote: 
>> > 
>> > Aren't those the default values for a Field Contructor? I tried 
>> > explicitly adding "notnull=False" and "required=False", and didn't 
>> > set the default property, but empty values still come out as an 
>> > empty string instead of None. 
>> > 
>> > On Monday, July 23, 2012 2:48:56 PM UTC-7, viniciusban wrote: 
>> > 
>> > As far as I know, let "notnull=False" and "required=False" for 
>> your 
>> > fields and don't set "default" property. 
>> > 
>> > 
>> > 
>> > On 07/23/2012 06:32 PM, Mark Li wrote: 
>> > > Unfortunately the lambda method didn't work, Anthony. Any 
>> other ideas 
>> > > for having a None default for empty entries? 
>> > > 
>> > > 
>> > > On a side note, if the 'integer' field type is used, then a 
>> blank entry 
>> > > results in a None. Don't know if that helps but it's 
>> something I've noticed. 
>> > > 
>> > > On Monday, July 23, 2012 2:07:51 PM UTC-7, Anthony wrote: 
>> > > 
>> > > To enter a value of None, this might work: 
>> > > 
>> > > | 
>> > > default=lambda:None 
>> > > | 
>> > > 
>> > > Anthony 
>> > > 
>> > > On Monday, July 23, 2012 5:04:44 PM UTC-4, Anthony wrote: 
>> > > 
>> > > default=None means that no default is specified, not 
>> that a 
>> > > default value of None will be inserted. 
>> > > 
>> > > Anthony 
>> > > 
>> > > On Monday, July 23, 2012 5:02:33 PM UTC-4, Mark Li 
>> wrote: 
>> > > 
>> > > I have a table defined in the following manner: 
>> > > 
>> > > db.define_table('songinfo', 
>> > > Field('songtitle'), 
>> > > Field('artist')) 
>> > > 
>> > > When I add an empty entry, or upload a CSV with 
>> empty 
>> > > values, I can only access those values with a 
>> database call like 
>> > > 
>> > > songs = db(db.songinfo.artist=="").select() 
>> > > 
>> > > as opposed to 
>> db(db.songinfo.artist==None).select() 
>> > > 
>> > > 
>> > > The web2py book states that fields default=None, 
>> but I'm 
>> > > getting an empty string. Is there an appropriate 
>> way to have 
>> > > None instead of an empty string in the database? 
>> > > 
>> > > 
>> > > -- 
>> > > 
>> > > 
>> > > 
>> > 
>> > -- 
>> > 
>> > 
>> > 
>>
>>

-- 





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

2012-07-25 Thread Michele Comitini
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=
 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:
>>
>> http://web2py.com/books/default/chapter/29/10?search=rest#Access-Control
>>
>>
>> mic
>>
>>
>> 2012/7/25 Amit :
>> > sure Michele, let me go through the code,If i am not wrong simpatica is
>> > to
>> > generate the certificate file for the client and if you are having any
>> > sample code to use x509 in case of web service then please do share with
>> > me.
>> >
>> > Thanks,
>> > Amit
>> >
>> >
>> > On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini
>> >  wrote:
>> >>
>> >> Amit
>> >> If you need advice with simpatica don't worry to ask.  I never had time
>> >> to
>> >> write some documentation so you have to look at the code and/or ask...
>> >>
>> >> mic
>> >>
>> >>
>> >> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
>> >>>
>> >>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
>> >>>
>> >>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini
>> >>>  wrote:
>> 
>> 
>>  This is very similar to what TSL accomplishes with x509 certificates.
>>  There is a slight difference, the server does not own a public key
>>  for each
>>  client: it verifies that the  client owns an x509 certificate signed
>>  by the
>>  correct certification authority. So no need to store public keys.  in
>>  any
>>  case AFAIK in public/private key algorithms the private key always
>>  allows
>>  generation of the corresponding public key, not the contrary of
>>  course.
>> 
>>  To accomplish what you need in the simplest way you h

Re: [web2py] Re: Problem running Web2py DAL (Trunk) as Standalone

2012-07-25 Thread Phyo Arkar
I c, Let me check again.

Thanks!

On Thu, Jul 19, 2012 at 9:17 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you check if trunk now works?
>
>
>
> On Wednesday, 18 July 2012 10:55:51 UTC-5, Phyo Arkar wrote:
>>
>> Hello Massimo and all;
>>
>> I had to update to trunk version of web2py because we having issue of
>> web2py DAL not closing down connection , casuing connections to queue up
>> and then mysql no longer accept connection (Limit reached).
>>
>> But when we run it we get this error:
>>
>> It is just a simple script to test close() function..
>>
>> Please help.
>>
>> Traceback (most recent call last):
>>   File "mysql_data_test.py", line 40, in 
>> from gluon.sql import DAL,Field
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/__init__.py", line
>> 15, in 
>> from globals import current
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/globals.py", line
>> 18, in 
>> from streamer import streamer, stream_file_or_304_or_206,
>> DEFAULT_CHUNK_SIZE
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/streamer.py", line
>> 15, in 
>> import rewrite
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/rewrite.py", line
>> 27, in 
>> from fileutils import abspath, read_file
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/fileutils.py", line
>> 388, in 
>> from settings import global_settings # we need to import settings
>> here because
>>   File "/home/lmk/Temp/web2py-web2py-**ac95b39/gluon/settings.py", line
>> 36, in 
>> version_info = open(os.path.join(global_**settings.gluon_parent,
>> 'VERSION'), 'r')
>> IOError: [Errno 2] No such file or directory:
>> '/home/lmk/Temp/web2py-web2py-**ac95b39/applications/**
>> EDCentric/modules/VERSION'
>>
>  --
>
>
>
>

-- 





[web2py] Re: Question on using legacy tables

2012-07-25 Thread Massimo Di Pierro
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
>

-- 





Re: [web2py] prettydate question

2012-07-25 Thread Massimo Di Pierro
Can you post the language file that you are using? What language is your 
browser set up to?

Massimo

On Wednesday, 25 July 2012 06:05:27 UTC-5, ctrlSoft wrote:
>
> but with translation wont work, i have al translation files in languages 
> folder.

-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Massimo Di Pierro
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

On Wednesday, 25 July 2012 07:23:46 UTC-5, Neil wrote:
>
> Could this be related?
>
>
> http://stackoverflow.com/questions/11092444/nginx-keeps-passing-the-same-http-cookie-to-uwsgi
>  
>
> It's a little beyond me, but I notice that HTTP_REFERER is facebook in 
> both cases, and they are also using nginx+uwsgi.
>
> On Wednesday, July 25, 2012 12:07:26 PM UTC+1, Neil wrote:
>>
>> Perhaps a coincidence, but:
>>
>> User 1 - Accessed my site through a Facebook link on iPhone
>> User 2 - Accessed my site through a Facebook link on iPad
>>
>> Does FB do anything strange with links to external sites that could cause 
>> the request.client to be unknown? I've accessed my site through the FB link 
>> using my Android mobile, and no noticeable problems.
>>
>> On Wednesday, July 25, 2012 9:27:36 AM UTC+1, Neil wrote:
>>>
>>> Incidentally, no problems importing urandom.
>>>
>>> On Wednesday, July 25, 2012 8:10:53 AM UTC+1, Neil wrote:


> Issue #2
> ===
>
> There is a bug with may prevent urandom from working:
>
> http://community.webfaction.**com/questions/9333/**
> importerror-cannot-import-**name-urandom
> http://stackoverflow.com/**questions/10776797/error-when-**
> importing-wsgihandler-with-**django
>
> Can you check if you can import urandom on your version of python 
> on webfaction?
>
>
>

-- 





Re: [web2py] prettydate question

2012-07-25 Thread ctrlSoft
browser is set up to english, but in model i do T.force('ro'). without 
forced translation result is the same

-- 



# coding: utf8
{
'!=': '!=',
'!langcode!': 'ro',
'!langname!': 'Rom?n?',
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" (actualizeaz?) este o expresie op?ional? precum "c?mp1=\'valoare_nou?\'". Nu pute?i actualiza sau ?terge rezultatele unui JOIN',
'%(nrows)s records found': '%(nrows)s ?nregistr?ri g?site',
'%d hours ago': '%d hours ago',
'%d weeks ago': '%d saptamani in urma',
'%d-%m-%Y': '%d-%m-%Y',
'%d-%m-%Y %H:%M:%S': '%d-%m-%Y %H:%M:%S',
'%s %%{row} deleted': '%s linii ?terse',
'%s %%{row} updated': '%s linii actualizate',
'%s selected': '%s selectat(e)',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'(something like "it-it")': '(ceva ce seam?n? cu "it-it")',
'1 month ago': '1 luna in urma',
'1 week ago': '1 saptamana in urma',
'<': '<',
'<=': '<=',
'=': '=',
'>': '>',
'>=': '>=',
'A new version of web2py is available': 'O nou? versiune de web2py este disponibil?',
'A new version of web2py is available: %s': 'O nou? versiune de web2py este disponibil?: %s',
'About': 'Despre',
'about': 'despre',
'About application': 'Despre aplica?ie',
'Access Control': 'Control acces',
'Add': 'Adaug?',
'additional code for your application': 'cod suplimentar pentru aplica?ia dvs.',
'admin disabled because no admin password': 'administrare dezactivat? deoarece parola de administrator nu a fost furnizat?',
'admin disabled because not supported on google app engine': 'administrare dezactivat? deoarece func?ionalitatea nu e suportat pe Google App Engine',
'admin disabled because unable to access password file': 'administrare dezactivat? deoarece nu exist? acces la fi?ierul cu parole',
'Admin is disabled because insecure channel': 'Adminstrarea este dezactivat? deoarece conexiunea nu este sigur?',
'Admin is disabled because unsecure channel': 'Administrarea este dezactivat? deoarece conexiunea nu este securizat?',
'Administration': 'Administrare',
'Administrative Interface': 'Interfa?? administrare',
'Administrator Password:': 'Parol? administrator:',
'Adresa': 'Adresa',
'Ai uitat parola?': 'Ai uitat parola?',
'Ajax Recipes': 'Re?ete Ajax',
'And': '?i',
'and rename it (required):': '?i renumi?i (obligatoriu):',
'and rename it:': ' ?i renumi?i:',
'appadmin': 'appadmin',
'appadmin is disabled because insecure channel': 'appadmin dezactivat deoarece conexiunea nu e sigur?',
'application "%s" uninstalled': 'aplica?ia "%s" a fost dezinstalat?',
'application compiled': 'aplica?ia a fost compilat?',
'application is compiled and cannot be designed': 'aplica?ia este compilat? ?i nu poate fi editat?',
'Are you sure you want to delete file "%s"?': 'Sigur ?terge?i fi?ierul "%s"?',
'Are you sure you want to delete this object?': 'Sigur ?terge?i acest obiect?',
'Are you sure you want to uninstall application "%s"': 'Sigur dezinstala?i aplica?ia "%s"',
'Are you sure you want to uninstall application "%s"?': 'Sigur dezinstala?i aplica?ia "%s"?',
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': 'ATEN?IE: Nu v? pute?i conecta dec?t utiliz?nd o conexiune securizat? (HTTPS) sau rul?nd aplica?ia pe computerul local.',
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ATEN?IE: Nu pute?i efectua mai multe teste o dat? deoarece lansarea ?n execu?ie a mai multor subpocese nu este sigur?.',
'ATTENTION: you cannot edit the running application!': 'ATEN?IE: nu pute?i edita o aplica?ie ?n curs de execu?ie!',
'Autentificare': 'Autentificare',
'Authentication': 'Autentificare',
'Autoritatea Contractanta': 'Autoritatea Contractanta',
'Available databases and tables': 'Baze de date ?i tabele disponibile',
'Back': '?napoi',
'Buy this book': 'Cump?r? aceast? carte',
'cache': 'cache',
'Cache Keys': 'Chei cache',
'cache, errors and sessions cleaned': 'cache, erori ?i sesiuni golite',
'Cannot be empty': 'Nu poate fi vid',
'Cannot compile: there are errors in your app.Debug it, correct errors and try again.': 'Compilare imposibil?: aplica?ia con?ine erori. Deboga?i aplica?ia ?i ?ncerca?i din nou.',
'cannot create file': 'fi?ier imposibil de creat',
'cannot upload file "%(filename)s"': 'imposibil de ?nc?rcat fi?ierul "%(filename)s"',
'Categoria': 'Categoria',
'Change Password': 'Schimbare parol?',
'Change password': 'Schimbare parol?',
'change password': 'schimbare parol?',
'check all': 'co?a?i tot',
'Check to delete': 'Co?a?i pentru a ?terge',
'clean': 'golire',
'Clear': 'Gole?te',
'click to check for upgrades': 'Clic pentru a verifica dac? exist? upgrade-uri',
'Client IP': 'IP client',
'Cod Banca': 'Cod Banca',
'Cod Fiscal': 'Cod Fiscal',
'Community': 'Comunitate',
'compile': 'compilare',
'compiled application removed': 'aplica?ia compilat? a fost ?tears?',
'Components and Plugins': 'Componente ?i plugin-uri',
'Cont de decontare': 'Cont de decontare',
'Cont Trezorerial'

[web2py] Re: "Internal error" on every page, can't even access admin

2012-07-25 Thread Jim S
I just fought the same problem.  Mine turned out to be an application error 
on my part.  But, I found it by looking at the text file in the errors 
sub-directory under my application.  If you look around the error files 
enough you'll eventually figure out what is going on.  They aren't easy to 
read, but I was able to find my problem there.  FWIW, this was on 
webfaction.

-Jim

On Wednesday, July 25, 2012 8:00:17 AM UTC-5, Alec Taylor wrote:
>
> I'm getting an annoying "Internal error" message on every page, with a 
> link to the ticket it issued. Unfortunately following that link presents me 
> with another "Internal error" page.
>
> Could this be a web-server issue, e.g.: out of memory?
>
> Would it be possible to open the ticket over SSH?
>
> Thanks for all suggestions,
>
> Alec Taylor
>

-- 





[web2py] Re: "Internal error" on every page, can't even access admin

2012-07-25 Thread Massimo Di Pierro
Look into admin/errors/ and look for the most recent file. You should be 
able to open it with an editor. Look at the last few lines. They contain 
the traceback.

massimo

On Wednesday, 25 July 2012 08:00:17 UTC-5, Alec Taylor wrote:
>
> I'm getting an annoying "Internal error" message on every page, with a 
> link to the ticket it issued. Unfortunately following that link presents me 
> with another "Internal error" page.
>
> Could this be a web-server issue, e.g.: out of memory?
>
> Would it be possible to open the ticket over SSH?
>
> Thanks for all suggestions,
>
> Alec Taylor
>

-- 





Re: [web2py] how to use cache decorator within modules?

2012-07-25 Thread villas
Hi All,

For anyone who was interested in this thread,  Massimo did implement cache 
decorators for use *inside modules* and this is now available in trunk.  It 
seemed to work OK for me and for anyone else wishing to test this, here is 
the description

Example Code for use inside your module:

from gluon.cache import lazy_lazy_cache
@lazy_lazy_cache('key', time_expire=10, cache_model='ram')
def myfunction():
 import time
 return time.time()  

'key' is optional
time_expire defaults to 300 seconds. 
cache_model defaults to 'ram'. 

Note the system is the same as regular cache except that cache_model is 
'ram, not cache.ram.  You cannot use current.cache because cache.ram only 
exists per-request. 




On Monday, July 16, 2012 4:05:38 AM UTC+1, villas wrote:
>
> Ok as you asked,  I raised it as issue 
> 895so you can ponder on 
> it.
> As I think this might be a tricky issue,  I shall pass the cache in as 
> Bruno suggested and I am happy with that solution.  Please mark as wontfix 
> if you don't see an obvious way to implement this.
> Thanks
>
>
> On Monday, July 16, 2012 2:33:46 AM UTC+1, Massimo Di Pierro wrote:
>>
>> Not yet. Please open a ticket about this.
>>
>> On Mar 1, 2011, at 5:05 AM, Carl Roach wrote:
>>
>> thanks Massimo.
>> The ability to have cache decorators in modules would be great.
>>
>> On 1 March 2011 02:09, Massimo Di Pierro wrote:
>>
>>> Jonathan and I have a plan to make this easy but it will not be in
>>> until 1.93 or 1.94.
>>>
>>> On Feb 28, 3:12 pm, pbreit  wrote:
>>> > Yeah, I'm having a hard time figuring out when and how to put stuff in
>>> > modules. And what the implications are of putting functions in /models.
>>>
>>
>>
>>

-- 





Re: [web2py] how to use cache decorator within modules?

2012-07-25 Thread Anthony
Why is it called lazy_lazy_cache, as opposed to just lazy_cache?

On Wednesday, July 25, 2012 10:36:50 AM UTC-4, villas wrote:
>
> Hi All,
>
> For anyone who was interested in this thread,  Massimo did implement cache 
> decorators for use *inside modules* and this is now available in trunk.  
> It seemed to work OK for me and for anyone else wishing to test this, here 
> is the description
>
> Example Code for use inside your module:
>
> from gluon.cache import lazy_lazy_cache
> @lazy_lazy_cache('key', time_expire=10, cache_model='ram')
> def myfunction():
>  import time
>  return time.time()  
>
> 'key' is optional
> time_expire defaults to 300 seconds. 
> cache_model defaults to 'ram'. 
>
> Note the system is the same as regular cache except that cache_model is 
> 'ram, not cache.ram.  You cannot use current.cache because cache.ram only 
> exists per-request. 
>
>
>
>
> On Monday, July 16, 2012 4:05:38 AM UTC+1, villas wrote:
>>
>> Ok as you asked,  I raised it as issue 
>> 895so you can ponder 
>> on it.
>> As I think this might be a tricky issue,  I shall pass the cache in as 
>> Bruno suggested and I am happy with that solution.  Please mark as wontfix 
>> if you don't see an obvious way to implement this.
>> Thanks
>>
>>
>> On Monday, July 16, 2012 2:33:46 AM UTC+1, Massimo Di Pierro wrote:
>>>
>>> Not yet. Please open a ticket about this.
>>>
>>> On Mar 1, 2011, at 5:05 AM, Carl Roach wrote:
>>>
>>> thanks Massimo.
>>> The ability to have cache decorators in modules would be great.
>>>
>>> On 1 March 2011 02:09, Massimo Di Pierro wrote:
>>>
 Jonathan and I have a plan to make this easy but it will not be in
 until 1.93 or 1.94.

 On Feb 28, 3:12 pm, pbreit  wrote:
 > Yeah, I'm having a hard time figuring out when and how to put stuff in
 > modules. And what the implications are of putting functions in 
 /models.

>>>
>>>
>>>

-- 





[web2py] Re: Suggestion - a pickled DAL field

2012-07-25 Thread Omri Har-Shemesh
Thanks!

I will try it out :)

On Wednesday, July 25, 2012 3:55:39 AM UTC+2, Anthony wrote:
>
> On Tuesday, July 24, 2012 5:58:29 PM UTC-4, Derek wrote:
>>
>> Make it a computed field?
>>
>
> I'm not sure that would be helpful in this case. A computed field computes 
> its value automatically based on other fields in the record, but in this 
> case, he needs to pickle an object, which is not one of the other fields. 
> Also, it needs to be unpickled when queried, which a computed field 
> wouldn't handle. 
>
> Anthony
>

-- 





Re: [web2py] MySQL DB reads have stopped working for one table in a background process

2012-07-25 Thread David Phillips
I think you have hit on the issue. I added a db.commit() call before I 
attempted to read from the table and the read was successful.

Thanks so much.

David


On Jul 24, 2012, at 11:16 PM, Massimo Di Pierro wrote:

> First of all we need to establish there is a problem and this is not the 
> expected behavior. I am not sure. 
> 
> MySQL has 4 different isolation modes and defaults to:
> 
> http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html#isolevel_repeatable-read
> 
> "All consistent reads within the same transaction read the snapshot 
> established by the first read."
> 
> I think this means that your background process does not see new updated 
> records unless it starts a new transaction. You can check it. Try adding some 
> db.commit() to the background process, even if it does not write data.
> 
> If this is the problem, you may also be able to change the isolation level 
> with SET TRANSACTION.
> 
> Massimo
> 
> 
> 
> On Tuesday, 24 July 2012 22:26:26 UTC-5, David Phillips wrote:
> Hello, Massimo.
> 
>> What changed? Did you upgrade? What web2py version? 
> 
> I removed a task in the background process that was periodically calling 
> db.commit. In its place, I started using memcache where I had been writing to 
> the db.
> 
> I haven't upgraded. I've been using 1.99.7 all along.
> 
>>  When you say the select does not work anymore, dwhat do you mean? Does it 
>> lock or do you get a traceback? 
> 
>   I add an account to the account table with account_id == 1 and id == 1 
> using appadmin on the web server.
> 
> Then I go to the background process and execute these commands both in my 
> code and using the debugger:
> 
>   rows = db (db.account.account_id == 1).select().first() 
> 
> returns None.
> 
>   count = db (db.account.id > 0).count()
> 
> return zero.
> 
>   db.executesql("select account_id from account")
> 
> returns None.
> 
> No error messages, exceptions, lock-ups or the like. select() simply fails to 
> find the data in the table which I can see with appadmin and the mysql 
> command-line client.
> 
> Curiously, if I stop the background process and restart it, I can read the 
> account from the account table:
> 
>   db (db.account.id > 0).count()
> 
> returns 1.
> 
> It's not a matter of the committing the database after the initial write. I 
> added a db.commit() call after writing the account to the db just to make 
> sure. It made no difference.
> 
>> Which database driver? People have reported problems with pymysql but not 
>> with mysqldb.
> 
> It's pymysql for both the development platform (Mac OS X 10.7) and the 
> production platform (CentOS).
> 
> 
> Do you have any advice on how to diagnose my problem?
> 
> Thanks,
> David
> 
> 
> 
> On Jul 24, 2012, at 8:50 PM, Massimo Di Pierro wrote:
> 
>> What changed? Did you upgrade? What web2py version? When you say the select 
>> does not work anymore, dwhat do you mean? Does it lock or do you get a 
>> traceback? Which database driver? People have reported problems with pymysql 
>> but not with mysqldb.
>> 
>> On Tuesday, 24 July 2012 19:42:29 UTC-5, David Phillips wrote:
>> On the eve of delivering a project to a client, I've come up against a 
>> problem that has me stumped. select() statements on one of my mysql tables 
>> have stopped working.
>> 
>> My application is a web2py web server and a background process (also called 
>> a homemade task queue in the web2py book). They share the database. The web 
>> server writes to the table from within an HTTP request, and several seconds 
>> later, I attempt to read the record in my background process.
>> 
>> Up until yesterday, I didn't have any trouble reading from this or any of 
>> the tables. And now, all the others work fine. I can still write and read 
>> from the misbehaving table from the web server. 
>> 
>> I am at a loss. I'm not sure where to look to diagnose the problem. Any 
>> pointers would be gratefully received.
>> 
>> 
>> -- 
>>  
>>  
>>  
> 
> 
> -- 
>  
>  
>  

-- 





[web2py] how to set values for certains fields (SQLFORM.factory for one table and list of fields, fields are not bind to a table) with ajax or $.ajax callback

2012-07-25 Thread Richard Vézina
Hello,

I have a form generated like this :

SQLFORM.factory(db.table1, Field('name','type',requires='something',
...), Field('name1','type',requires='something', ...), etc.)

Base on the value entered for a field in the db.table1 I want to set
predefined (or default) values stored in database to the appropriate custom
fields (name, name1) included in the form with SQLFORM.factory.

Now, I am not sure, if web2py ajax if enough for the task or I will need
$.ajax...

I have to send to web2py controller function the value entered by the user.
I thought it could be easier to have callback function, independent from
the function that generate the form, that will only return the list
predefined defaults values base on the user input, then write a little
jquery loop to set those defaults values in the form.

I am not sure web2py ajax can handle this. Also, I don't know how to get
data pass to the "callback" function with $.ajax(..., data:{key:value})...

Thanks.

Richard

-- 





[web2py] Re: SQLFORM.grid pagination refresh

2012-07-25 Thread Anthony
Yeah, it looks like the query string isn't propagated to the links within 
the table. However, you can propagate URL args by specifying the "args" 
argument to .grid(). Maybe something like this:

{{=LOAD('default', 'ajaxTable2.load', args=[60], ajax=True, target='grid')}}


  $('#input4').keyup(function(){
input_value = $("#input4").val();
web2py_component('{{=URL("default", "ajaxTable3.load")}}' + '/' +input_value
, 'grid');
  });



def ajaxTable3():
query = (db.applicant.id > 0) & (db.applicant.id < request.args(0))
grid = SQLFORM.grid(query, args=[request.args(0)], searchable=False, csv
=False)
return grid

Also, do not put the {{=LOAD(...)}} inside a div with id="grid". The LOAD() 
helper automatically creates its own div with the id set to the "target" 
argument (if "target" isn't specified, it generates a random id 
automatically).

Anthony

-- 





[web2py] [WEB2PY] Twitter bootstrap Carousel not cycling

2012-07-25 Thread Kevin Miller
Hi all,

Any ideas why twitter bootstrap carousel not cycling.

I followed what was told:

I put this in the header:

  $(document).ready(function(){
  $('#myCarousel').carousel({
  interval: 2000
});
 }


and in the body I placed the code as indicated on the website.


It only cycles after I click on one of the controls. I want it to cycle
automatically.

Thanks.

Kevin

-- 





Re: [web2py] Re: "Internal error" on every page, can't even access admin

2012-07-25 Thread Alec Taylor
I didn't do anything on the website for the past 3 hours (had some more
academic research to do), and when I went back to the site, it loaded.

Checking tickets, found a few of these:


*OSError: [Errno 28] No space left on device: '/tmp/tmpznG08R'* +
details
Probably uwsgi memory limit causing problems.

Damned webfaction's limits, all well, pretty soon I should have it up on
OpenShift and all will be right with the world :P

Thanks for the advice

On Thu, Jul 26, 2012 at 12:07 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Look into admin/errors/ and look for the most recent file. You should be
> able to open it with an editor. Look at the last few lines. They contain
> the traceback.
>
> massimo
>
>
> On Wednesday, 25 July 2012 08:00:17 UTC-5, Alec Taylor wrote:
>>
>> I'm getting an annoying "Internal error" message on every page, with a
>> link to the ticket it issued. Unfortunately following that link presents me
>> with another "Internal error" page.
>>
>> Could this be a web-server issue, e.g.: out of memory?
>>
>> Would it be possible to open the ticket over SSH?
>>
>> Thanks for all suggestions,
>>
>> Alec Taylor
>>
>  --
>
>
>
>

-- 





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

2012-07-25 Thread Toby Shepard

On 07/24/2012 06:55 PM, Anthony wrote:

On Tuesday, July 24, 2012 5:58:29 PM UTC-4, Derek wrote:

Make it a computed field?


I'm not sure that would be helpful in this case. A computed field
computes its value automatically based on other fields in the record,
but in this case, he needs to pickle an object, which is not one of the
other fields. Also, it needs to be unpickled when queried, which a
computed field wouldn't handle.



I haven't used one, but I remember coming across it in the manual.
Don't you just pass a lambda when you create the field.  It would
seem that you could do anything you want to the value without consulting
other fields.

--





Re: [web2py] Re: callback on an anchor tag

2012-07-25 Thread Toby Shepard




{{=A("CLICK ME!!", callback=URL('http://mysite.com/foo.html'
),
target='hater')}}

should be

{{=A("CLICK ME!!", callback='http://mysite.com/foo.html'
,target='hater')}}


Ok, thanks.  Perhaps there is a small problem with the
manual section on views.  I copied my example from the manual:


{{=A('click me', callback=URL('myaction'), target="t")}}


and the response of the ajax callback will be stored in the DIV with id 
equal to "t".



Tobiah


which would produce:

http://mysite.com/foo.html',[],'hater';);return
false">CLICK ME!!

and that is what is expected. Perhaps I misunderstand the question.


On Tuesday, 24 July 2012 16:21:59 UTC-5, Toby Shepard wrote:

Working through the html helper docs,
I decided to try the callback parameter
to the anchor tag:


{{=A("CLICK ME!!", callback=URL('http://mysite.com/foo.html'
),
target='hater')}}
{{=DIV(_id = 'hater')}}

foo.html delivers a bit of content. This did not work.
Viewing the source, I see that the tag was rendered like this:

http://register.rcsreg.com/foo.html'
;,[],'hater');return

false;">CLICK ME!!

That doesn't so good. Am I doing something wrong?

Thanks,

Tobiah

--





--





[web2py] Complex query with left outer join

2012-07-25 Thread jw
Hi,

my question is about the following query. I'm planning to program an 
e-learning software. For this I use three tables to select the cards to 
learn for today.
Table "cards" contains the question, "userCard" contains the progress for 
the special student (lastTimeLearned as a multiplicator for the calculating 
of the next time to learn), "subject" contains the name of the subject and 
groupCard contains the answer for the special group.

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
).select(db.userCard.id,db.card.id, 
left=db.userCard.on((db.userCard.card_id == db.card.id)))

I would like to select in this query all the cards for a specific student 
in a choosen subject, with the answers of his learnGroup (groupCard) and 
only the cards he doesn't learned today. I try to use the left outer join, 
because there are cards, the user learns them for the first time.
I tried many hours to find a correct query but now i feel desperate.

The other thing is the '1' in the timedelta. I get the exception, that it 
is not allowed to use a field in timedelta.

Can somebody please help me?
P.S.: Sory for my english!

-- 





Re: [web2py] prettydate question

2012-07-25 Thread Asimionese Alexandru


On Wednesday, July 25, 2012 11:48:34 AM UTC+3, ctrlSoft wrote:
>
>
>
> On Tuesday, July 24, 2012 5:58:16 PM UTC+3, dbdeveloper wrote:
>>
>>  ctrlSoft, is issue still present ?
>>
>> Vladyslav Kozlovskyy (Ukraine)
>>
>> 23.07.12 13:32, ctrlSoft написав(ла):
>>  
>> datetime format is: 2012-07-18 10:00:00  
>>  
>>  hi in view i have following code:
>> {{=prettydate(row.deadline,T)}}
>>
>>  but result is :
>> %d days ago 
>>  %d days ago  
>> %d days ago   
>>  %d days ago   
>>  ...
>> 1 week ago
>> 1 week ago
>> ...
>> %d weeks ago 
>>  %d weeks ago 
>>  %d weeks ago 
>>  
>>  how to display 
>> 4 days ago
>> 5 days ago
>> ...
>> 2 weeks ago
>> 3 weeks ago
>> ... 
>> ...
>>
>>  -- 
>>  
>>  
>> ( web2py version is from trunk.) i tried Bruno solution 
>> {{=prettydate(row.deadline, lambda x: x)}}  and it works...
>>
>>  bu i need with translation, {{=prettydate(row.deadline, lambda x: 
> x)}}, i have all transaltion files in laguages folder
>  
>

-- 





[web2py] web2py with Amazon AWS and dynamoDB

2012-07-25 Thread kantaki
Hello,

is it possible to run web2py with dynamodb? If yes what are the 
restrictions?
Maybe there are other frameworks that are more suitable with dynamodb?

-- 





[web2py] Left outer join in a compex select

2012-07-25 Thread jw
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] Error using Scheduler with CouchDB

2012-07-25 Thread Ted
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] Re: "Internal error" on every page, can't even access admin

2012-07-25 Thread Alec Taylor
Alright, happened again, just checked the uwsgi log:

tmpfile(): No space left on device [proto/http.c line 338]
error parsing request

:\

On Thu, Jul 26, 2012 at 2:04 AM, Alec Taylor  wrote:

> I didn't do anything on the website for the past 3 hours (had some more
> academic research to do), and when I went back to the site, it loaded.
>
> Checking tickets, found a few of these:
>
>
> *OSError: [Errno 28] No space left on device: '/tmp/tmpznG08R'* + 
> details
> Probably uwsgi memory limit causing problems.
>
> Damned webfaction's limits, all well, pretty soon I should have it up on
> OpenShift and all will be right with the world :P
>
> Thanks for the advice
>
>
> On Thu, Jul 26, 2012 at 12:07 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Look into admin/errors/ and look for the most recent file. You should be
>> able to open it with an editor. Look at the last few lines. They contain
>> the traceback.
>>
>> massimo
>>
>>
>> On Wednesday, 25 July 2012 08:00:17 UTC-5, Alec Taylor wrote:
>>>
>>> I'm getting an annoying "Internal error" message on every page, with a
>>> link to the ticket it issued. Unfortunately following that link presents me
>>> with another "Internal error" page.
>>>
>>> Could this be a web-server issue, e.g.: out of memory?
>>>
>>> Would it be possible to open the ticket over SSH?
>>>
>>> Thanks for all suggestions,
>>>
>>> Alec Taylor
>>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: prettydate question

2012-07-25 Thread Alec Taylor
On Tue, Jul 24, 2012 at 2:28 AM, ctrlSoft  wrote:

> yes.
>>>
>> http://i.imgur.com/jaeop.jpg
>
> http://i.imgur.com/xPBG1.jpg
>
> Quick aside, that view you've screenshotted, would you be able to show me
the code (view+controller) you used to generate it?

-- 





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

2012-07-25 Thread Anthony

>
> > Make it a computed field? 
> > 
> > 
> > I'm not sure that would be helpful in this case. A computed field 
> > computes its value automatically based on other fields in the record, 
> > but in this case, he needs to pickle an object, which is not one of the 
> > other fields. Also, it needs to be unpickled when queried, which a 
> > computed field wouldn't handle. 
> > 
>
> I haven't used one, but I remember coming across it in the manual. 
> Don't you just pass a lambda when you create the field.  It would 
> seem that you could do anything you want to the value without consulting 
> other fields.
>

Are you talking about a computed field? The compute function only runs if 
you *don't* pass a value to the field -- it calculates a value for the 
field based on the values of *other* fields in the record. Also, it doesn't 
do anything to the value upon query, so wouldn't help with the unpickling 
in this case.

Anthony

-- 





Re: [web2py] Re: callback on an anchor tag

2012-07-25 Thread Anthony

>
> Ok, thanks.  Perhaps there is a small problem with the 
> manual section on views.  I copied my example from the manual: 
>
>
> {{=A('click me', callback=URL('myaction'), target="t")}} 
>  
>
> and the response of the ajax callback will be stored in the DIV with id 
> equal to "t". 
>

No, there's no problem with the book. Notice, you didn't copy the example 
exactly. The example generates the callback URL using the web2py URL() 
function, which generates web2py URLs. In your code, you passed a fully 
formed URL (possibly an external URL?) to the URL() function, which is not 
how it works.

Anthony 

-- 





Re: [web2py] Re: callback on an anchor tag

2012-07-25 Thread Toby Shepard

On 07/24/2012 06:48 PM, Massimo Di Pierro wrote:

{{=A("CLICK ME!!", callback=URL('http://mysite.com/foo.html'
),
target='hater')}}

should be

{{=A("CLICK ME!!", callback='http://mysite.com/foo.html'
,target='hater')}}


Ok, so now I have:

{{=A("CLICK ME!!", callback='http://mysite.com/foo.html', target='hater')}}
{{=DIV(_id = 'hater')}}

And, viewing the source, I'm getting this:

onclick="ajax('http://mysite.com/foo.html',[],'hater';);return 
false;">CLICK ME!!




Thanks,

Tobiah

--





Re: [web2py] Re: callback on an anchor tag

2012-07-25 Thread Toby Shepard

On 07/25/2012 09:21 AM, Anthony wrote:

Ok, thanks. Perhaps there is a small problem with the
manual section on views. I copied my example from the manual:


{{=A('click me', callback=URL('myaction'), target="t")}}


and the response of the ajax callback will be stored in the DIV with id
equal to "t".


No, there's no problem with the book. Notice, you didn't copy the
example exactly. The example generates the callback URL using the web2py
URL() function, which generates web2py URLs. In your code, you passed a
fully formed URL (possibly an external URL?) to the URL() function,
which is not how it works.

Anthony

--





Oh, I had thought that 'myaction' stood for a full URL.  So in this
case, is 'myaction' actually the name of a controller, or function?

Thanks,

Toby

--





Re: [web2py] Complex query with left outer join

2012-07-25 Thread Alec Taylor
On Thu, Jul 26, 2012 at 12:13 AM, jw  wrote:

> Hi,
>
> my question is about the following query. I'm planning to program an
> e-learning software. For this I use three tables to select the cards to
> learn for today.
> Table "cards" contains the question, "userCard" contains the progress for
> the special student (lastTimeLearned as a multiplicator for the calculating
> of the next time to learn), "subject" contains the name of the subject and
> groupCard contains the answer for the special group.
>
> 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
> ).select(db.userCard.id,db.card.id,
> left=db.userCard.on((db.userCard.card_id == db.card.id)))
>
> I would like to select in this query all the cards for a specific student
> in a choosen subject, with the answers of his learnGroup (groupCard) and
> only the cards he doesn't learned today. I try to use the left outer join,
> because there are cards, the user learns them for the first time.
> I tried many hours to find a correct query but now i feel desperate.
>
> The other thing is the '1' in the timedelta. I get the exception, that it
> is not allowed to use a field in timedelta.
>

from datetime import date, timedelta

& (db.userCard.lastTimeLearned < (date.today() - timedelta(days=1)))

Can somebody please help me?
> P.S.: Sory for my english!
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: callback on an anchor tag

2012-07-25 Thread Anthony

>
> Oh, I had thought that 'myaction' stood for a full URL.  So in this 
> case, is 'myaction' actually the name of a controller, or function?
>

It's a function. When you don't pass an application or controller name to 
URL(), it assumes the current application and current controller.

Anthony 

-- 





[web2py] BR()

2012-07-25 Thread Toby Shepard

In my own html generating libraries, I normally allow
an integer argument to the  maker, which is a count
of how many tags to put out.  So:

{{=BR(5)}}

could output 

This works out since the BR tag can't have any components
anyway.

Just a thought.  I find it useful at times.

Tobiah

--





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
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: Complex query with left outer join

2012-07-25 Thread pbreit
I don't really understand what you're trying to do but I would recommend 
trying to simplify. First, you don't always need to do a join or a left 
join. Try to figure out if those are really necessary. For example, do you 
really need to join the questions and the progress or can you retrieve 
those separately? Second, you're only selecting for two fields. That may be 
OK but I would suggest selecting for all fields (ie, delete 
"db.userCard.id,db.card.id," from select()). If you want to optimize 
*after* you get it working, then you can do so. Third, working with 
datetime and DB can be difficult. Try to get the query working before 
adding a timedate query component.

When I build a complex query, I start with one query, make it work, then 
add a query, make it work, and so on.

-- 





Re: [web2py] Complex query with left outer join

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

timedelta syntax is timedelta(days=1)

On 07/25/2012 11:13 AM, jw wrote:

Hi,

my question is about the following query. I'm planning to program an
e-learning software. For this I use three tables to select the cards to
learn for today.
Table "cards" contains the question, "userCard" contains the progress
for the special student (lastTimeLearned as a multiplicator for the
calculating of the next time to learn), "subject" contains the name of
the subject and groupCard contains the answer for the special group.

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
 ).select(db.userCard.id,db.card.id,
left=db.userCard.on((db.userCard.card_id == db.card.id)))

I would like to select in this query all the cards for a specific
student in a choosen subject, with the answers of his learnGroup
(groupCard) and only the cards he doesn't learned today. I try to use
the left outer join, because there are cards, the user learns them for
the first time.
I tried many hours to find a correct query but now i feel desperate.

The other thing is the '1' in the timedelta. I get the exception, that
it is not allowed to use a field in timedelta.

Can somebody please help me?
P.S.: Sory for my english!

--





--





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

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

Indeed, pbreit.

Did you check if your SQL query is correct?
print db._lastsql would help, too.

Baby steps, baby. Baby steps.

--
Vinicius Assef



On 07/25/2012 01:58 PM, pbreit wrote:

I don't really understand what you're trying to do but I would recommend
trying to simplify. First, you don't always need to do a join or a left
join. Try to figure out if those are really necessary. For example, do
you really need to join the questions and the progress or can you
retrieve those separately? Second, you're only selecting for two fields.
That may be OK but I would suggest selecting for all fields (ie, delete
"db.userCard.id,db.card.id," from select()). If you want to optimize
*after* you get it working, then you can do so. Third, working with
datetime and DB can be difficult. Try to get the query working before
adding a timedate query component.

When I build a complex query, I start with one query, make it work, then
add a query, make it work, and so on.

--





--





Re: [web2py] BR()

2012-07-25 Thread Lucas R. Martins

You also can use {{=BR()*5}}  or {{=ANYTHING()*5}}

Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu:

In my own html generating libraries, I normally allow
an integer argument to the  maker, which is a count
of how many tags to put out. So:

{{=BR(5)}}

could output 

This works out since the BR tag can't have any components
anyway.

Just a thought. I find it useful at times.

Tobiah




--





Re: [web2py] BR()

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

No, you cannot.

On 07/25/2012 02:18 PM, Lucas R. Martins wrote:

You also can use {{=BR()*5}}  or {{=ANYTHING()*5}}

Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu:

In my own html generating libraries, I normally allow
an integer argument to the  maker, which is a count
of how many tags to put out. So:

{{=BR(5)}}

could output 

This works out since the BR tag can't have any components
anyway.

Just a thought. I find it useful at times.

Tobiah






--





[web2py] Visit Plugow on FISL13

2012-07-25 Thread vinicius...@gmail.com
Plugow is a totem developed by our team, at Agencia X4, using Python and 
web2py.


It integrates several techologies like webcam, qrcode, social networks 
(twitter and fb) and youtube.
We're on FISL 13 [1] (International Free Software Forum, 13th edition) 
in Brazil.


If you understand Portuguese, see it: http://labs.agenciax4.com.br/fisl13
BTW, this hotsite is powered by web2py, too. ;-) I has been our main web 
technology for about a year, now.



[1] http://softwarelivre.org/fisl13

--
Vinicius Assef

--





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Roberto De Ioris

Il giorno 25/lug/2012, alle ore 18:54, Neil ha scritto:

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

You can get the updated stable-branch from here:

http://projects.unbit.it/hg/uwsgi-1.2

(the maintainance release will be tomorrow)

but generally you will get not advantages in using plain async mode with web2py 
(probably that's why the bug popped up so late)

--
Roberto De Ioris
http://unbit.it
JID: robe...@jabber.unbit.it

-- 





Re: [web2py] BR()

2012-07-25 Thread Anthony
Though you can do:

{{=BR().xml()*5}}

or

{{=str(BR())*5}}

Anthony

On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote:
>
> No, you cannot. 
>
> On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
> > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
> > 
> > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
> >> In my own html generating libraries, I normally allow 
> >> an integer argument to the  maker, which is a count 
> >> of how many tags to put out. So: 
> >> 
> >> {{=BR(5)}} 
> >> 
> >> could output  
> >> 
> >> This works out since the BR tag can't have any components 
> >> anyway. 
> >> 
> >> Just a thought. I find it useful at times. 
> >> 
> >> Tobiah 
> >> 
> > 
> > 
>
>

-- 





Re: [web2py] BR()

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

They don't work. Output is escaped.

Try it out.

--
Vinicius Assef


On 07/25/2012 03:40 PM, Anthony wrote:

Though you can do:

|
{{=BR().xml()*5}}
|

or

|
{{=str(BR())*5}}
|

Anthony

On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote:

No, you cannot.

On 07/25/2012 02:18 PM, Lucas R. Martins wrote:
> You also can use {{=BR()*5}}  or {{=ANYTHING()*5}}
>
> Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu:
>> In my own html generating libraries, I normally allow
>> an integer argument to the  maker, which is a count
>> of how many tags to put out. So:
>>
>> {{=BR(5)}}
>>
>> could output 
>>
>> This works out since the BR tag can't have any components
>> anyway.
>>
>> Just a thought. I find it useful at times.
>>
>> Tobiah
>>
>
>

--





--





[web2py] Re: Error using Scheduler with CouchDB

2012-07-25 Thread Niphlod
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] BR()

2012-07-25 Thread Derek
Ok, how about {{=(BR()*5).XML()}}

On Wednesday, July 25, 2012 11:53:05 AM UTC-7, viniciusban wrote:
>
> They don't work. Output is escaped. 
>
> Try it out. 
>
> -- 
> Vinicius Assef 
>
>
> On 07/25/2012 03:40 PM, Anthony wrote: 
> > Though you can do: 
> > 
> > | 
> > {{=BR().xml()*5}} 
> > | 
> > 
> > or 
> > 
> > | 
> > {{=str(BR())*5}} 
> > | 
> > 
> > Anthony 
> > 
> > On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote: 
> > 
> > No, you cannot. 
> > 
> > On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
> > > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
> > > 
> > > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
> > >> In my own html generating libraries, I normally allow 
> > >> an integer argument to the  maker, which is a count 
> > >> of how many tags to put out. So: 
> > >> 
> > >> {{=BR(5)}} 
> > >> 
> > >> could output  
> > >> 
> > >> This works out since the BR tag can't have any components 
> > >> anyway. 
> > >> 
> > >> Just a thought. I find it useful at times. 
> > >> 
> > >> Tobiah 
> > >> 
> > > 
> > > 
> > 
> > -- 
> > 
> > 
> > 
>
>

-- 





Re: [web2py] BR()

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

You cannot, too.

I've tested. The correct way is: {{=XML(str(BR())*5)}}




On 07/25/2012 04:09 PM, Derek wrote:

Ok, how about {{=(BR()*5).XML()}}

On Wednesday, July 25, 2012 11:53:05 AM UTC-7, viniciusban wrote:

They don't work. Output is escaped.

Try it out.

--
Vinicius Assef


On 07/25/2012 03:40 PM, Anthony wrote:
> Though you can do:
>
> |
> {{=BR().xml()*5}}
> |
>
> or
>
> |
> {{=str(BR())*5}}
> |
>
> Anthony
>
> On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote:
>
> No, you cannot.
>
> On 07/25/2012 02:18 PM, Lucas R. Martins wrote:
> > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}}
> >
> > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu:
> >> In my own html generating libraries, I normally allow
> >> an integer argument to the  maker, which is a count
> >> of how many tags to put out. So:
> >>
> >> {{=BR(5)}}
> >>
> >> could output 
> >>
> >> This works out since the BR tag can't have any components
> >> anyway.
> >>
> >> Just a thought. I find it useful at times.
> >>
> >> Tobiah
> >>
> >
> >
>
> --
>
>
>

--





--





[web2py] Re: Web2Py on OpenShift

2012-07-25 Thread Alec Taylor
Looking good, but I was wondering, is it possible to get this working with 
latest trunk?

I tried, but ended up with "Internal error"s before I was even presented 
with the enter admin password view. The welcome app worked fine though >.<

Thanks

On Saturday, June 9, 2012 1:07:39 AM UTC+10, Andrew wrote:
>
> Just FYI to anyone interested, I've put together a web2py template for 
> OpenShift  (Red Hat's Opensource 
> PaaS). 
>
> You can find it here: - https://github.com/prelegalwonder/openshift_web2py
>
> I've also put together a basic openshift deployer from the admin page, and 
> you can grab the changes from my fork of web2py - 
> https://github.com/prelegalwonder/web2py
> It's just 3 files in the admin app:
>  controllers/openshift.py
>  views/openshift/deploy.html
> and a modification to views/default/site.html
>
> It's only requirement to work beyond having a local working openshift 
> project is GitPython installed and accessible from the runtime that web2py 
> is running in.
>
> So you can either run the admin app in the cloud and access it directly or 
> run a local web2py instance and execute the deployer when you want to test 
> out your changes. 
>
> I'm working on a detailed blog that I intent to submit to the OpenShift 
> team so they can put it on their site for getting started. 
>
> Enjoy
>

-- 





Re: [web2py] BR()

2012-07-25 Thread Derek
nope...
 unsupported operand type(s) for *: 'BR' and 
'int'
and also...
 'BR' object has no attribute 'XML'

On Wednesday, July 25, 2012 12:09:24 PM UTC-7, Derek wrote:
>
> Ok, how about {{=(BR()*5).XML()}}
>
> On Wednesday, July 25, 2012 11:53:05 AM UTC-7, viniciusban wrote:
>>
>> They don't work. Output is escaped. 
>>
>> Try it out. 
>>
>> -- 
>> Vinicius Assef 
>>
>>
>> On 07/25/2012 03:40 PM, Anthony wrote: 
>> > Though you can do: 
>> > 
>> > | 
>> > {{=BR().xml()*5}} 
>> > | 
>> > 
>> > or 
>> > 
>> > | 
>> > {{=str(BR())*5}} 
>> > | 
>> > 
>> > Anthony 
>> > 
>> > On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote: 
>> > 
>> > No, you cannot. 
>> > 
>> > On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
>> > > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
>> > > 
>> > > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
>> > >> In my own html generating libraries, I normally allow 
>> > >> an integer argument to the  maker, which is a count 
>> > >> of how many tags to put out. So: 
>> > >> 
>> > >> {{=BR(5)}} 
>> > >> 
>> > >> could output  
>> > >> 
>> > >> This works out since the BR tag can't have any components 
>> > >> anyway. 
>> > >> 
>> > >> Just a thought. I find it useful at times. 
>> > >> 
>> > >> Tobiah 
>> > >> 
>> > > 
>> > > 
>> > 
>> > -- 
>> > 
>> > 
>> > 
>>
>>

-- 





[web2py] Re: Suggestion - a pickled DAL field

2012-07-25 Thread howesc
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: web2py with Amazon AWS and dynamoDB

2012-07-25 Thread howesc
i may be speaking out of turn, but i don't recall that there is a DAL 
adapter for dynamodb.  i bet the DAL adapter would look like other nosql 
adapters  We should probably add it in if there is demand for it!

the rest of web2py should run fine.

On Wednesday, July 25, 2012 4:51:56 AM UTC-7, kantaki wrote:
>
> Hello,
>
> is it possible to run web2py with dynamodb? If yes what are the 
> restrictions?
> Maybe there are other frameworks that are more suitable with dynamodb?
>
>

-- 





[web2py] Re: [WEB2PY] Twitter bootstrap Carousel not cycling

2012-07-25 Thread howesc
check the JS console for errors.  if somehow your code above is executed 
before bootstrap has finished loading it bet the init fails...though i 
wouldn't expect it to work at all.  i guess check the console and let us 
know if you see errors.

On Wednesday, July 25, 2012 9:04:00 AM UTC-7, dundee wrote:
>
>
> Hi all,
>
> Any ideas why twitter bootstrap carousel not cycling.
>
> I followed what was told:
>
> I put this in the header:
>
>   $(document).ready(function(){
>   $('#myCarousel').carousel({
>   interval: 2000
> });  
>  }
>
>
> and in the body I placed the code as indicated on the website.
>
>
> It only cycles after I click on one of the controls. I want it to cycle 
> automatically.
>
> Thanks.
>
> Kevin
>

-- 





Re: [web2py] BR()

2012-07-25 Thread Derek
Better way is this:
{{=XML(""*5)}}

But only because you have a ton less brackets.

On Wednesday, July 25, 2012 12:14:09 PM UTC-7, viniciusban wrote:
>
> You cannot, too. 
>
> I've tested. The correct way is: {{=XML(str(BR())*5)}} 
>
>
>
>
> On 07/25/2012 04:09 PM, Derek wrote: 
> > Ok, how about {{=(BR()*5).XML()}} 
> > 
> > On Wednesday, July 25, 2012 11:53:05 AM UTC-7, viniciusban wrote: 
> > 
> > They don't work. Output is escaped. 
> > 
> > Try it out. 
> > 
> > -- 
> > Vinicius Assef 
> > 
> > 
> > On 07/25/2012 03:40 PM, Anthony wrote: 
> > > Though you can do: 
> > > 
> > > | 
> > > {{=BR().xml()*5}} 
> > > | 
> > > 
> > > or 
> > > 
> > > | 
> > > {{=str(BR())*5}} 
> > > | 
> > > 
> > > Anthony 
> > > 
> > > On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote: 
> > > 
> > > No, you cannot. 
> > > 
> > > On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
> > > > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
> > > > 
> > > > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
> > > >> In my own html generating libraries, I normally allow 
> > > >> an integer argument to the  maker, which is a count 
> > > >> of how many tags to put out. So: 
> > > >> 
> > > >> {{=BR(5)}} 
> > > >> 
> > > >> could output  
> > > >> 
> > > >> This works out since the BR tag can't have any components 
> > > >> anyway. 
> > > >> 
> > > >> Just a thought. I find it useful at times. 
> > > >> 
> > > >> Tobiah 
> > > >> 
> > > > 
> > > > 
> > > 
> > > -- 
> > > 
> > > 
> > > 
> > 
> > -- 
> > 
> > 
> > 
>
>

-- 





[web2py] email question, and mysterious variable behavior

2012-07-25 Thread joe
Hello

Two problems.  First, I have no experience whatsoever with the mail system, 
but I need to use it for a request/notification system.  (when the status 
of a run changes to what a user wanted it to change to, the user gets an 
email).  The email is not being sent.  I set up email like this:

from gluon.tools import Mail
mail = Mail()
mail.settings.server = 'http://127.0.0.1:8000'
mail.settings.sender = 'myem...@emailclient.com'

Then I call this method in my index function, which is being accessed every 
time a run is updated, to check for updates, and wee if they match:

def check_reqnot():
for row in db().select(db.request_notification.ALL):
if not row.notified:
if row.notify_when == db.run[row.run].status:
row.notified = True
mail.send('testem...@gmail.com',
'WOW!',
'It Worked! (HOLY CRAP)')
response.flash = 'It should have worked'

It should be working, because when the status matches the request, I see 
the flash response, but the email is not sent (yes, I checked my junk mail 
folder).

The other odd thing is that notified stays false.

For reference here is the request_notification table:

db.define_table('request_notification',
Field ('run', db.run, 
requires = IS_NOT_EMPTY 
()),
Field ('notify_when', 
requires = IS_IN_SET 
(['Requested', 'In 
Proccess', 'Completed'])),
Field ('notified', 
'boolean', default = False, readable = False),
Field ('user_signature', 
db.auth_user, compute = lambda row: auth.user_id))


And the relevant field form the run table:

Field ('status', requires = 
IS_EMPTY_OR (IS_IN_SET 
(['Requested', 'In 
Proccess', 'Completed']))),

-- 





Re: [web2py] BR()

2012-07-25 Thread Niphlod
1.99.7

{{=XML(BR().xml()*5)}}

works ok.

On Wednesday, July 25, 2012 9:17:04 PM UTC+2, Derek wrote:
>
> nope...
>  unsupported operand type(s) for *: 'BR' and 
> 'int'
> and also...
>  'BR' object has no attribute 'XML'
>
> On Wednesday, July 25, 2012 12:09:24 PM UTC-7, Derek wrote:
>>
>> Ok, how about {{=(BR()*5).XML()}}
>>
>> On Wednesday, July 25, 2012 11:53:05 AM UTC-7, viniciusban wrote:
>>>
>>> They don't work. Output is escaped. 
>>>
>>> Try it out. 
>>>
>>> -- 
>>> Vinicius Assef 
>>>
>>>
>>> On 07/25/2012 03:40 PM, Anthony wrote: 
>>> > Though you can do: 
>>> > 
>>> > | 
>>> > {{=BR().xml()*5}} 
>>> > | 
>>> > 
>>> > or 
>>> > 
>>> > | 
>>> > {{=str(BR())*5}} 
>>> > | 
>>> > 
>>> > Anthony 
>>> > 
>>> > On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote: 
>>> > 
>>> > No, you cannot. 
>>> > 
>>> > On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
>>> > > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
>>> > > 
>>> > > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
>>> > >> In my own html generating libraries, I normally allow 
>>> > >> an integer argument to the  maker, which is a count 
>>> > >> of how many tags to put out. So: 
>>> > >> 
>>> > >> {{=BR(5)}} 
>>> > >> 
>>> > >> could output  
>>> > >> 
>>> > >> This works out since the BR tag can't have any components 
>>> > >> anyway. 
>>> > >> 
>>> > >> Just a thought. I find it useful at times. 
>>> > >> 
>>> > >> Tobiah 
>>> > >> 
>>> > > 
>>> > > 
>>> > 
>>> > -- 
>>> > 
>>> > 
>>> > 
>>>
>>>

-- 





Re: [web2py] BR()

2012-07-25 Thread Anthony
Right, you have to put it inside an XML().

On Wednesday, July 25, 2012 2:53:05 PM UTC-4, viniciusban wrote:
>
> They don't work. Output is escaped. 
>
> Try it out. 
>
> -- 
> Vinicius Assef 
>
>
> On 07/25/2012 03:40 PM, Anthony wrote: 
> > Though you can do: 
> > 
> > | 
> > {{=BR().xml()*5}} 
> > | 
> > 
> > or 
> > 
> > | 
> > {{=str(BR())*5}} 
> > | 
> > 
> > Anthony 
> > 
> > On Wednesday, July 25, 2012 1:23:37 PM UTC-4, viniciusban wrote: 
> > 
> > No, you cannot. 
> > 
> > On 07/25/2012 02:18 PM, Lucas R. Martins wrote: 
> > > You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
> > > 
> > > Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
> > >> In my own html generating libraries, I normally allow 
> > >> an integer argument to the  maker, which is a count 
> > >> of how many tags to put out. So: 
> > >> 
> > >> {{=BR(5)}} 
> > >> 
> > >> could output  
> > >> 
> > >> This works out since the BR tag can't have any components 
> > >> anyway. 
> > >> 
> > >> Just a thought. I find it useful at times. 
> > >> 
> > >> Tobiah 
> > >> 
> > > 
> > > 
> > 
> > -- 
> > 
> > 
> > 
>
>

-- 





[web2py] Re: email question, and mysterious variable behavior

2012-07-25 Thread Niphlod
mail.settings.server needs to be ('logging' for debugging purposes or) an 
ip(:port) where a mail daemon is listening, not the http address of a 
web2py instance..

And again (this rises up quite a bit): DAL is not an ORM. DAL is a Database 
Abstraction Layer, not an Object Relational Mapper. 
With this statement I mean "your modifications to objects doesn't get 
automatically propagated to the database"

db(something).select() return a Rows() object.

This is a list of  dictionaries accessible both as db['tablename']['field'] 
AND by db.tablename.field.

When you change a value in this dict, you changed it ONLY in the object 
itself. This doesn't save the results in the db automatically.

This is why you end up having "notified" always false on the next select.

If you want to do that you have to call it like this:

row.update_record(notified=True).

Actually, I'd put it AFTER the mail is sent, so you update the notified 
field only in the case the email is actually sent (queued to the mail 
daemon)



On Wednesday, July 25, 2012 9:29:57 PM UTC+2, joe wrote:
>
> Hello
>
> Two problems.  First, I have no experience whatsoever with the mail 
> system, but I need to use it for a request/notification system.  (when the 
> status of a run changes to what a user wanted it to change to, the user 
> gets an email).  The email is not being sent.  I set up email like this:
>
> from gluon.tools import Mail
> mail = Mail()
> mail.settings.server = 'http://127.0.0.1:8000'
> mail.settings.sender = 'myem...@emailclient.com'
>
> Then I call this method in my index function, which is being accessed 
> every time a run is updated, to check for updates, and wee if they match:
>
> def check_reqnot():
> for row in db().select(db.request_notification.ALL):
> if not row.notified:
> if row.notify_when == db.run[row.run].status:
> row.notified = True
> mail.send('testem...@gmail.com',
> 'WOW!',
> 'It Worked! (HOLY CRAP)')
> response.flash = 'It should have worked'
>
> It should be working, because when the status matches the request, I see 
> the flash response, but the email is not sent (yes, I checked my junk mail 
> folder).
>
> The other odd thing is that notified stays false.
>
> For reference here is the request_notification table:
>
> db.define_table('request_notification',
> Field ('run', db.run, 
> requires = IS_NOT_EMPTY 
> ()),
> Field ('notify_when', 
> requires = IS_IN_SET 
> (['Requested', 'In 
> Proccess', 'Completed'])),
> Field ('notified', 
> 'boolean', default = False, readable = False),
> Field 
> ('user_signature', 
> db.auth_user, compute = lambda row: auth.user_id))
>
>
> And the relevant field form the run table:
>
> Field ('status', requires = 
> IS_EMPTY_OR 
> (IS_IN_SET 
> (['Requested', 'In 
> Proccess', 'Completed']))),
>
>

-- 





[web2py] Re: email question, and mysterious variable behavior

2012-07-25 Thread Anthony

>
> from gluon.tools import Mail
> mail = Mail()
> mail.settings.server = 'http://127.0.0.1:8000'
> mail.settings.sender = 'myem...@emailclient.com'
>

You also need:

mail.settings.login = 'username:password'


row.notified = True
>
 

> The other odd thing is that notified stays false.
>

Changing row.notified only changes it in the Row object -- it does not 
update the record in the database. You have two options:

row.notified = True
row.update_record()

or:

row.update_record(notified=True) 

See http://web2py.com/books/default/chapter/29/6#update_record.

Anthony

-- 





[web2py] Re: Inconsistent behavior with SqlGrid and referenced tables

2012-07-25 Thread Derek
created_by works because it references db.auth_user and db.auth_user has a 
format attribute which specifies how it is to be represented. So, your 
argument '%(name)s' gives it a label, but not a representation.
Add a format attribute to those other tables.

On Saturday, July 21, 2012 7:13:08 AM UTC-7, david.waldrop wrote:
>
> I have a table defined as follows:
>
>  db.define_table('org', 
>  Field('name'), 
>  Field('otype',db.orgtypes, label='Type'),
>  Field('jurisdiction',db.jurisdictions),
>  Field('created_by',db.auth_user,readable=True,writable=False),
> 
>  
> Field('created','datetime',default=request.now,readable=False,writable=False),
> 
>  
> Field('last_activity','datetime',default=request.now,readable=False,writable=False),
>  
>   
>  Field('deletedflag', comment='This flags the record as deleted, 
> but does not remove.', writable=False, readable=False),
>  migrate=migrate_db)  
>  db.org.name.requires = [IS_NOT_EMPTY(),IS_NOT_IN_DB(db, 'org.name')]
>  db.org.otype.requires = IS_IN_DB(db, 'orgtypes.id', '%(name)s', 
> zero=T('choose one'))
>  db.org.jurisdiction.requires = IS_IN_DB(db, 'jurisdictions.id', 
> '%(name)s', zero=T('choose one'))
>  if auth.is_logged_in():
>  db.org.created_by.default = auth.user.id
>
> and am trying to use SQLForm.grid like this - SQLFORM.smartgrid(db.org)
>
> The display shows the name of the create_by field by automatically looking 
> up the id of the user who created the organization record, however neither 
> the jurisdictio field, nor the otype field do the same.  Both display the 
> primary key instead of the appropriate names.  
>
> A second issue that may be related in the actual display of the of the 
> auto-rederenced user is David Waldrop (29) - where 29 is the primary key of 
> the user.  I would like to eliminate this as well as it means nothing to 
> the user.
>
> I have played with represents, but cannot figure out why the behavior 
> seesm inconsistent.  Any suggestions are very much appreciated?
>

-- 





[web2py] Re: email question, and mysterious variable behavior

2012-07-25 Thread joe
Thanks, the variable thing works now.  Also, if the server is 'logging', 
will the email be sent?  Sorry, I have never used this before.

Thanks for the help
-Joe peacock

On Wednesday, July 25, 2012 2:42:42 PM UTC-5, Niphlod wrote:
>
> mail.settings.server needs to be ('logging' for debugging purposes or) an 
> ip(:port) where a mail daemon is listening, not the http address of a 
> web2py instance..
>
> And again (this rises up quite a bit): DAL is not an ORM. DAL is a 
> Database Abstraction Layer, not an Object Relational Mapper. 
> With this statement I mean "your modifications to objects doesn't get 
> automatically propagated to the database"
>
> db(something).select() return a Rows() object.
>
> This is a list of  dictionaries accessible both as 
> db['tablename']['field'] AND by db.tablename.field.
>
> When you change a value in this dict, you changed it ONLY in the object 
> itself. This doesn't save the results in the db automatically.
>
> This is why you end up having "notified" always false on the next select.
>
> If you want to do that you have to call it like this:
>
> row.update_record(notified=True).
>
> Actually, I'd put it AFTER the mail is sent, so you update the notified 
> field only in the case the email is actually sent (queued to the mail 
> daemon)
>
>
>
> On Wednesday, July 25, 2012 9:29:57 PM UTC+2, joe wrote:
>>
>> Hello
>>
>> Two problems.  First, I have no experience whatsoever with the mail 
>> system, but I need to use it for a request/notification system.  (when the 
>> status of a run changes to what a user wanted it to change to, the user 
>> gets an email).  The email is not being sent.  I set up email like this:
>>
>> from gluon.tools import Mail
>> mail = Mail()
>> mail.settings.server = 'http://127.0.0.1:8000'
>> mail.settings.sender = 'myem...@emailclient.com'
>>
>> Then I call this method in my index function, which is being accessed 
>> every time a run is updated, to check for updates, and wee if they match:
>>
>> def check_reqnot():
>> for row in db().select(db.request_notification.ALL):
>> if not row.notified:
>> if row.notify_when == db.run[row.run].status:
>> row.notified = True
>> mail.send('testem...@gmail.com',
>> 'WOW!',
>> 'It Worked! (HOLY CRAP)')
>> response.flash = 'It should have worked'
>>
>> It should be working, because when the status matches the request, I see 
>> the flash response, but the email is not sent (yes, I checked my junk mail 
>> folder).
>>
>> The other odd thing is that notified stays false.
>>
>> For reference here is the request_notification table:
>>
>> db.define_table('request_notification',
>> Field ('run', db.run, 
>> requires = IS_NOT_EMPTY 
>> ()),
>> Field ('notify_when', 
>> requires = IS_IN_SET 
>> (['Requested', 'In 
>> Proccess', 'Completed'])),
>> Field ('notified', 
>> 'boolean', default = False, readable = False),
>> Field 
>> ('user_signature', 
>> db.auth_user, compute = lambda row: auth.user_id))
>>
>>
>> And the relevant field form the run table:
>>
>> Field ('status', requires 
>> = IS_EMPTY_OR 
>> (IS_IN_SET 
>> (['Requested', 'In 
>> Proccess', 'Completed']))),
>>
>>

-- 





[web2py] Re: Inconsistent behavior with SqlGrid and referenced tables

2012-07-25 Thread Derek
I'll quote Massimo here...   
http://permalink.gmane.org/gmane.comp.python.web2py/79516

A field has two attributes, requires and represent. If web2py finds a
'reference auth_user" but no requires, it assumes

db.report.person.requires=IS_IN_DB(db, db.auth_user.id,
db.auth_user._format)
db.report.person.represent = lambda id: db.auth_user._format %
db.auth_user[id]

If you give a custom requires, you also need a custom represent or you
do not get one.

In your case it would be easier to do:

db.auth_user._format = '%(last_name)s'

and use the default ones.




On Saturday, July 21, 2012 7:13:08 AM UTC-7, david.waldrop wrote:
>
> I have a table defined as follows:
>
>  db.define_table('org', 
>  Field('name'), 
>  Field('otype',db.orgtypes, label='Type'),
>  Field('jurisdiction',db.jurisdictions),
>  Field('created_by',db.auth_user,readable=True,writable=False),
> 
>  
> Field('created','datetime',default=request.now,readable=False,writable=False),
> 
>  
> Field('last_activity','datetime',default=request.now,readable=False,writable=False),
>  
>   
>  Field('deletedflag', comment='This flags the record as deleted, 
> but does not remove.', writable=False, readable=False),
>  migrate=migrate_db)  
>  db.org.name.requires = [IS_NOT_EMPTY(),IS_NOT_IN_DB(db, 'org.name')]
>  db.org.otype.requires = IS_IN_DB(db, 'orgtypes.id', '%(name)s', 
> zero=T('choose one'))
>  db.org.jurisdiction.requires = IS_IN_DB(db, 'jurisdictions.id', 
> '%(name)s', zero=T('choose one'))
>  if auth.is_logged_in():
>  db.org.created_by.default = auth.user.id
>
> and am trying to use SQLForm.grid like this - SQLFORM.smartgrid(db.org)
>
> The display shows the name of the create_by field by automatically looking 
> up the id of the user who created the organization record, however neither 
> the jurisdictio field, nor the otype field do the same.  Both display the 
> primary key instead of the appropriate names.  
>
> A second issue that may be related in the actual display of the of the 
> auto-rederenced user is David Waldrop (29) - where 29 is the primary key of 
> the user.  I would like to eliminate this as well as it means nothing to 
> the user.
>
> I have played with represents, but cannot figure out why the behavior 
> seesm inconsistent.  Any suggestions are very much appreciated?
>

-- 





[web2py] Re: email question, and mysterious variable behavior

2012-07-25 Thread Niphlod
'logging' gets the raw email printed on the console. it is only for 
debugging purposes.

BTW (and I mean no harm on that): I get that asking on such an active list 
is "speedier" than having to read documentation, but since you are going to 
use the feature, why don't you just go and read about it on 
http://web2py.com/books/default/chapter/29/8 ?

-- 





Re: [web2py] how to use cache decorator within modules?

2012-07-25 Thread Derek
because this one is really lazy.

On Wednesday, July 25, 2012 7:44:20 AM UTC-7, Anthony wrote:
>
> Why is it called lazy_lazy_cache, as opposed to just lazy_cache?
>
> On Wednesday, July 25, 2012 10:36:50 AM UTC-4, villas wrote:
>>
>> Hi All,
>>
>> For anyone who was interested in this thread,  Massimo did implement 
>> cache decorators for use *inside modules* and this is now available in 
>> trunk.  It seemed to work OK for me and for anyone else wishing to test 
>> this, here is the description
>>
>> Example Code for use inside your module:
>>
>> from gluon.cache import lazy_lazy_cache
>> @lazy_lazy_cache('key', time_expire=10, cache_model='ram')
>> def myfunction():
>>  import time
>>  return time.time()  
>>
>> 'key' is optional
>> time_expire defaults to 300 seconds. 
>> cache_model defaults to 'ram'. 
>>
>> Note the system is the same as regular cache except that cache_model is 
>> 'ram, not cache.ram.  You cannot use current.cache because cache.ram only 
>> exists per-request. 
>>
>>
>>
>>
>> On Monday, July 16, 2012 4:05:38 AM UTC+1, villas wrote:
>>>
>>> Ok as you asked,  I raised it as issue 
>>> 895so you can ponder 
>>> on it.
>>> As I think this might be a tricky issue,  I shall pass the cache in as 
>>> Bruno suggested and I am happy with that solution.  Please mark as wontfix 
>>> if you don't see an obvious way to implement this.
>>> Thanks
>>>
>>>
>>> On Monday, July 16, 2012 2:33:46 AM UTC+1, Massimo Di Pierro wrote:

 Not yet. Please open a ticket about this.

 On Mar 1, 2011, at 5:05 AM, Carl Roach wrote:

 thanks Massimo.
 The ability to have cache decorators in modules would be great.

 On 1 March 2011 02:09, Massimo Di Pierro wrote:

> Jonathan and I have a plan to make this easy but it will not be in
> until 1.93 or 1.94.
>
> On Feb 28, 3:12 pm, pbreit  wrote:
> > Yeah, I'm having a hard time figuring out when and how to put stuff 
> in
> > modules. And what the implications are of putting functions in 
> /models.
>




-- 





Re: [web2py] User accessed site without logging in

2012-07-25 Thread Neil
This is very useful information - I was always unsure about using async. 
Thanks a lot!

On Wednesday, July 25, 2012 6:49:39 PM UTC+1, Roberto De Ioris wrote:
>
>
> You can get the updated stable-branch from here: 
>
> http://projects.unbit.it/hg/uwsgi-1.2 
>
> (the maintainance release will be tomorrow) 
>
> but generally you will get not advantages in using plain async mode with 
> web2py (probably that's why the bug popped up so late) 
>
>
>

-- 





Re: [web2py] Re: Web2Py on OpenShift

2012-07-25 Thread Andrew Replogle
I haven't attempted with a recent release. I'll pull down trunk and see if
I can get the admin working.

Keep in mind that when an OpenShift gear is started, your configuration is
copied from the git area to a runtime area and executed from there. So,
while I haven't tested this and can't confirm for certain, I don't think
code changes you'd make from the web IDE would persist between restarts
unless you exported and re-imported the application.

I think the ability to import / pull and push to git repo's will solve this
issue and I'm working to evolve that functionality and add hg support as
well.

Keep in mind there's also the OpenShift deployer in trunk that you can use
to develop locally and deploy your changes as long as your openshift
template is on the same system.

Regards,
Andrew

On Wed, Jul 25, 2012 at 2:15 PM, Alec Taylor  wrote:

> Looking good, but I was wondering, is it possible to get this working with
> latest trunk?
>
> I tried, but ended up with "Internal error"s before I was even presented
> with the enter admin password view. The welcome app worked fine though >.<
>
> Thanks
>
>
> On Saturday, June 9, 2012 1:07:39 AM UTC+10, Andrew wrote:
>>
>> Just FYI to anyone interested, I've put together a web2py template for
>> OpenShift  (Red Hat's Opensource
>> PaaS).
>>
>> You can find it here: - https://github.com/**prelegalwonder/openshift_**
>> web2py 
>>
>> I've also put together a basic openshift deployer from the admin page,
>> and you can grab the changes from my fork of web2py - https://github.com/
>> **prelegalwonder/web2py 
>> It's just 3 files in the admin app:
>>  controllers/openshift.py
>>  views/openshift/deploy.html
>> and a modification to views/default/site.html
>>
>> It's only requirement to work beyond having a local working openshift
>> project is GitPython installed and accessible from the runtime that web2py
>> is running in.
>>
>> So you can either run the admin app in the cloud and access it directly
>> or run a local web2py instance and execute the deployer when you want to
>> test out your changes.
>>
>> I'm working on a detailed blog that I intent to submit to the OpenShift
>> team so they can put it on their site for getting started.
>>
>> Enjoy
>>
>  --
>
>
>
>

-- 





[web2py] Modifying form submit button markup?

2012-07-25 Thread Alec Taylor
I've been able to change the textual value of the submit button on 
`SQLFORM.factory` by modifying the `submit_button` attribute.

I want to change its class to: , and 
move it up to the text field, so it will look like: *Search*[][icon]

For a better explanation on what classes I want to add, see: 
http://twitter.github.com/bootstrap/base-css.html#forms

How do I add in customer classes?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] Re: prettydate question

2012-07-25 Thread ctrlSoft


On Wednesday, July 25, 2012 7:17:43 PM UTC+3, Alec Taylor wrote:
>
> On Tue, Jul 24, 2012 at 2:28 AM, ctrlSoft  wrote:
>
>>  yes.

>>> http://i.imgur.com/jaeop.jpg
>>
>> http://i.imgur.com/xPBG1.jpg 
>>  
>> Quick aside, that view you've screenshotted, would you be able to show me 
> the code (view+controller) you used to generate it?
>

view (line 29):
https://github.com/dimadeveatii/licitatii/blob/master/views/achizitii_cop/grid_partial.html
 

controller:
https://github.com/dimadeveatii/licitatii/blob/master/controllers/achizitii_cop.py
 

-- 





Re: [web2py] Re: Web2Py on OpenShift

2012-07-25 Thread Alec Taylor
Excellent, thanks.

I haven't really looked at the newly built in OpenShift feature, but I'm
pretty sure it just facilitates updating the application on OpenShift,
rather than the application + web-framework.

On Thu, Jul 26, 2012 at 6:23 AM, Andrew Replogle
wrote:

> I haven't attempted with a recent release. I'll pull down trunk and see if
> I can get the admin working.
>
> Keep in mind that when an OpenShift gear is started, your configuration is
> copied from the git area to a runtime area and executed from there. So,
> while I haven't tested this and can't confirm for certain, I don't think
> code changes you'd make from the web IDE would persist between restarts
> unless you exported and re-imported the application.
>
> I think the ability to import / pull and push to git repo's will solve
> this issue and I'm working to evolve that functionality and add hg support
> as well.
>
> Keep in mind there's also the OpenShift deployer in trunk that you can use
> to develop locally and deploy your changes as long as your openshift
> template is on the same system.
>
> Regards,
> Andrew
>
>
> On Wed, Jul 25, 2012 at 2:15 PM, Alec Taylor wrote:
>
>> Looking good, but I was wondering, is it possible to get this working
>> with latest trunk?
>>
>> I tried, but ended up with "Internal error"s before I was even presented
>> with the enter admin password view. The welcome app worked fine though >.<
>>
>> Thanks
>>
>>
>> On Saturday, June 9, 2012 1:07:39 AM UTC+10, Andrew wrote:
>>>
>>> Just FYI to anyone interested, I've put together a web2py template for
>>> OpenShift  (Red Hat's Opensource
>>> PaaS).
>>>
>>> You can find it here: - https://github.com/**prelegalwonder/openshift_**
>>> web2py 
>>>
>>> I've also put together a basic openshift deployer from the admin page,
>>> and you can grab the changes from my fork of web2py -
>>> https://github.com/**prelegalwonder/web2py
>>> It's just 3 files in the admin app:
>>>  controllers/openshift.py
>>>  views/openshift/deploy.html
>>> and a modification to views/default/site.html
>>>
>>> It's only requirement to work beyond having a local working openshift
>>> project is GitPython installed and accessible from the runtime that web2py
>>> is running in.
>>>
>>> So you can either run the admin app in the cloud and access it directly
>>> or run a local web2py instance and execute the deployer when you want to
>>> test out your changes.
>>>
>>> I'm working on a detailed blog that I intent to submit to the OpenShift
>>> team so they can put it on their site for getting started.
>>>
>>> Enjoy
>>>
>>  --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: prettydate question

2012-07-25 Thread Alec Taylor
Thanks

On Thu, Jul 26, 2012 at 6:40 AM, ctrlSoft  wrote:

>
>
> On Wednesday, July 25, 2012 7:17:43 PM UTC+3, Alec Taylor wrote:
>>
>> On Tue, Jul 24, 2012 at 2:28 AM, ctrlSoft  wrote:
>>
>>>  yes.
>
 http://i.imgur.com/jaeop.jpg
>>>
>>> http://i.imgur.com/xPBG1.jpg
>>>
>>> Quick aside, that view you've screenshotted, would you be able to show
>> me the code (view+controller) you used to generate it?
>>
>
> view (line 29):
>
> https://github.com/dimadeveatii/licitatii/blob/master/views/achizitii_cop/grid_partial.html
>
>
> controller:
>
> https://github.com/dimadeveatii/licitatii/blob/master/controllers/achizitii_cop.py
>
>
> --
>
>
>
>

-- 





[web2py] Re: Visit Plugow on FISL13

2012-07-25 Thread Massimo Di Pierro
Can you tell us more hat it does?

On Wednesday, 25 July 2012 12:36:46 UTC-5, viniciusban wrote:
>
> Plugow is a totem developed by our team, at Agencia X4, using Python and 
> web2py. 
>
> It integrates several techologies like webcam, qrcode, social networks 
> (twitter and fb) and youtube. 
> We're on FISL 13 [1] (International Free Software Forum, 13th edition) 
> in Brazil. 
>
> If you understand Portuguese, see it: http://labs.agenciax4.com.br/fisl13 
> BTW, this hotsite is powered by web2py, too. ;-) I has been our main web 
> technology for about a year, now. 
>
>
> [1] http://softwarelivre.org/fisl13 
>
> -- 
> Vinicius Assef 
>

-- 





Re: [web2py] BR()

2012-07-25 Thread Massimo Di Pierro
Why not? Good idea. It is in trunk!

{{=BR()*5}}

On Wednesday, 25 July 2012 12:18:26 UTC-5, Lucas R. Martins wrote:
>
> You also can use {{=BR()*5}}  or {{=ANYTHING()*5}} 
>
> Em Qua 25 Jul 2012 13:51:38 BRT, Toby Shepard escreveu: 
> > In my own html generating libraries, I normally allow 
> > an integer argument to the  maker, which is a count 
> > of how many tags to put out. So: 
> > 
> > {{=BR(5)}} 
> > 
> > could output  
> > 
> > This works out since the BR tag can't have any components 
> > anyway. 
> > 
> > Just a thought. I find it useful at times. 
> > 
> > Tobiah 
> > 
>
>
>

-- 





Re: [web2py] how to use cache decorator within modules?

2012-07-25 Thread Massimo Di Pierro
Because while the cache decorator wraps the function once. The 
lazy_lazy_cache wraps cache once, therefore the function twice. This is 
because cache requires current.request but this is only available when the 
function is called, not when the module is first imported and the cache 
decorator executed. I am not attached to the name anyway, we can change it.

On Wednesday, 25 July 2012 09:44:20 UTC-5, Anthony wrote:
>
> Why is it called lazy_lazy_cache, as opposed to just lazy_cache?
>
> On Wednesday, July 25, 2012 10:36:50 AM UTC-4, villas wrote:
>>
>> Hi All,
>>
>> For anyone who was interested in this thread,  Massimo did implement 
>> cache decorators for use *inside modules* and this is now available in 
>> trunk.  It seemed to work OK for me and for anyone else wishing to test 
>> this, here is the description
>>
>> Example Code for use inside your module:
>>
>> from gluon.cache import lazy_lazy_cache
>> @lazy_lazy_cache('key', time_expire=10, cache_model='ram')
>> def myfunction():
>>  import time
>>  return time.time()  
>>
>> 'key' is optional
>> time_expire defaults to 300 seconds. 
>> cache_model defaults to 'ram'. 
>>
>> Note the system is the same as regular cache except that cache_model is 
>> 'ram, not cache.ram.  You cannot use current.cache because cache.ram only 
>> exists per-request. 
>>
>>
>>
>>
>> On Monday, July 16, 2012 4:05:38 AM UTC+1, villas wrote:
>>>
>>> Ok as you asked,  I raised it as issue 
>>> 895so you can ponder 
>>> on it.
>>> As I think this might be a tricky issue,  I shall pass the cache in as 
>>> Bruno suggested and I am happy with that solution.  Please mark as wontfix 
>>> if you don't see an obvious way to implement this.
>>> Thanks
>>>
>>>
>>> On Monday, July 16, 2012 2:33:46 AM UTC+1, Massimo Di Pierro wrote:

 Not yet. Please open a ticket about this.

 On Mar 1, 2011, at 5:05 AM, Carl Roach wrote:

 thanks Massimo.
 The ability to have cache decorators in modules would be great.

 On 1 March 2011 02:09, Massimo Di Pierro wrote:

> Jonathan and I have a plan to make this easy but it will not be in
> until 1.93 or 1.94.
>
> On Feb 28, 3:12 pm, pbreit  wrote:
> > Yeah, I'm having a hard time figuring out when and how to put stuff 
> in
> > modules. And what the implications are of putting functions in 
> /models.
>




-- 





Re: [web2py] Re: Empty Database value is not None, but an empty string

2012-07-25 Thread Mark Li
I'm using SQLite3 on Windows (running from source). I didn't install 
anything extra, just been using SQLite that came with web2py

I attempted 

 
try: 
   db.testtable.import_from_csv_file('example.csv', null='')
 
except: 
   print db._lastsql 
   db.rollback()




However, print db._lastsql doesn't print anything.

I made a new app and the problem still exists (can't import CSV from shell 
and importing from database administration still gives empty string instead 
of None).


Here is my db.py code:


db = DAL('sqlite://storage.sqlite')
 
db.define_table('testtable',
Field('column1'),
Field('column2'),
Field('column3','string'))

>From the web2py shell, I use:

db.testtable.import_from_csv_file('example.csv', null='')

which gives me the following error

Traceback (most recent call last):
  File "c:\Users\Mark\Documents\dubliners\web2py\gluon\contrib\shell.py",line 
233, in run
exec compiled in statement_module.__dict__
  File "", line 1, in 
  File "c:\Users\Mark\Documents\dubliners\web2py\gluon\dal.py", line 6955, 
in import_from_csv_file
new_id = self.insert(**dict(items))
  File "c:\Users\Mark\Documents\dubliners\web2py\gluon\dal.py", line 6829, 
in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "c:\Users\Mark\Documents\dubliners\web2py\gluon\dal.py", line 928, 
ininsert
raise e
OperationalError: near ")": syntax error

The 'example.csv' file is located in my web2py folder.





On Wednesday, July 25, 2012 6:23:56 AM UTC-7, Anthony wrote:
>
> Can you attach a sample CSV file that fails, and show your table model 
> code as well as any code used to do the import?
>
> Anthony
>
> On Tuesday, July 24, 2012 11:31:27 PM UTC-4, Mark Li wrote:
>>
>> Anthony, I tried
>>
>> db.mytable.import_from_csv_file([file object], null='')
>>
>> from the web2py shell, but it gave me an error:
>>
>> OperationalError: near ")": syntax error
>>
>>
>> In fact, trying to import from csv using the book's method does not work 
>> at all, although exporting works fine.
>>
>>
>> Viniciusban, I'm inserting data through the database administation 
>> interface (filling out the form). I've also tried importing the CSV file 
>> through the administrative interface as well, where all blank spaces in the 
>> csv some out to empty strings (unless the field type is 'integer').
>>
>>
>>
>> On Monday, July 23, 2012 10:47:24 PM UTC-7, viniciusban wrote:
>>>
>>> Yes, they are default settings. 
>>>
>>> It's quite strange you get empty strings instead null (None, in Python). 
>>>
>>> How are you inserting data into db? Are you using a SQLFORM or 
>>> my_table.validate_and_insert() or simply mytable.insert()? 
>>>
>>> Do you get same results (blank values) inserting it from web2py shell 
>>> using simply mytable.insert()? 
>>>
>>> -- 
>>> Vinicius Assef 
>>>
>>>
>>> > On Monday, July 23, 2012 5:58:19 PM UTC-4, Mark Li wrote: 
>>> > 
>>> > Aren't those the default values for a Field Contructor? I tried 
>>> > explicitly adding "notnull=False" and "required=False", and didn't 
>>> > set the default property, but empty values still come out as an 
>>> > empty string instead of None. 
>>> > 
>>> > On Monday, July 23, 2012 2:48:56 PM UTC-7, viniciusban wrote: 
>>> > 
>>> > As far as I know, let "notnull=False" and "required=False" for 
>>> your 
>>> > fields and don't set "default" property. 
>>> > 
>>> > 
>>> > 
>>> > On 07/23/2012 06:32 PM, Mark Li wrote: 
>>> > > Unfortunately the lambda method didn't work, Anthony. Any 
>>> other ideas 
>>> > > for having a None default for empty entries? 
>>> > > 
>>> > > 
>>> > > On a side note, if the 'integer' field type is used, then a 
>>> blank entry 
>>> > > results in a None. Don't know if that helps but it's 
>>> something I've noticed. 
>>> > > 
>>> > > On Monday, July 23, 2012 2:07:51 PM UTC-7, Anthony wrote: 
>>> > > 
>>> > > To enter a value of None, this might work: 
>>> > > 
>>> > > | 
>>> > > default=lambda:None 
>>> > > | 
>>> > > 
>>> > > Anthony 
>>> > > 
>>> > > On Monday, July 23, 2012 5:04:44 PM UTC-4, Anthony 
>>> wrote: 
>>> > > 
>>> > > default=None means that no default is specified, not 
>>> that a 
>>> > > default value of None will be inserted. 
>>> > > 
>>> > > Anthony 
>>> > > 
>>> > > On Monday, July 23, 2012 5:02:33 PM UTC-4, Mark Li 
>>> wrote: 
>>> > > 
>>> > > I have a table defined in the following manner: 
>>> > > 
>>> > > db.define_table('songinfo', 
>>> > > Field('songtitle'), 
>>> > > Field('artist')) 
>>> > > 
>>> > > When I add an empty entry, or upload a CSV with 
>>> empty 
>>> > > val

Re: [web2py] User accessed site without logging in

2012-07-25 Thread Massimo Di Pierro
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
>>
>

-- 





  1   2   >