[web2py] GAE Channel API and web2py mapping

2012-08-22 Thread Sushant Taneja
Hi,

As per the GAE channel API documentation, for tracking client connections, 
I need to monitor the URLs /_ah/channel/connected and 
/_ah/channel/disconnected.
How do I map these to web2py URLs ?

I am guessing some changes will be needed in routes.py.
I am currently using web2py 1.99.7 (latest stable version)

Thanks,
Sushant

-- 





Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Yes, I have the controller with the name view.py and the function user

On Wednesday, July 11, 2012 10:14:17 PM UTC+5:30, pbreit wrote:
>
> I guess this is the key line:
> ('/$anything','404->/devekayan/view/user/$anything')
>
> That would require a controller file called "view.py" and a function "def 
> user():"
>


Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Oh... that might be the problem since I am not using the source from the 
trunk. I am using the current stable version 1.99.7 available at :
http://www.web2py.com/examples/default/download



On Wednesday, July 11, 2012 10:12:28 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Are you sure you are sing web2py trunk? Earlier version do not support the 
> 404->
>
> On Wednesday, 11 July 2012 09:24:03 UTC-5, Sushant Taneja wrote:
>>
>> Yes, sure. I have attached my routes.py with this reply.
>>
>> On Wednesday, July 11, 2012 7:49:12 PM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> Can I see your full routes?
>>>
>>> On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:
>>>>
>>>> I wrote the below line in routes.py. But I am getting a server response 
>>>> of 400 instead of 404.
>>>>
>>>> INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
>>>> HTTP/1.1" 400 -
>>>>
>>>> So I tried after changing 404 to 400 but it is still the same. No 
>>>> redirection or request for the target URL is made.
>>>>
>>>> What might be causing the problem ?
>>>>
>>>> I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)
>>>>
>>>> On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>>>>>
>>>>> It can be done already
>>>>>
>>>>> ('/$anything','404->/myapp/default/catchall/$anything')
>>>>>
>>>>> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>>>>>
>>>>>> I wonder if we should try to support this formally. Perhaps if as a 
>>>>>> "catchall" if the router doesn't find any valid routes and before it 
>>>>>> returns a 404?
>>>>>
>>>>>

Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Yes, sure. I have attached my routes.py with this reply.

On Wednesday, July 11, 2012 7:49:12 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Can I see your full routes?
>
> On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:
>>
>> I wrote the below line in routes.py. But I am getting a server response 
>> of 400 instead of 404.
>>
>> INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
>> HTTP/1.1" 400 -
>>
>> So I tried after changing 404 to 400 but it is still the same. No 
>> redirection or request for the target URL is made.
>>
>> What might be causing the problem ?
>>
>> I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)
>>
>> On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> It can be done already
>>>
>>> ('/$anything','404->/myapp/default/catchall/$anything')
>>>
>>> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>>>
>>>> I wonder if we should try to support this formally. Perhaps if as a 
>>>> "catchall" if the router doesn't find any valid routes and before it 
>>>> returns a 404?
>>>
>>>#!/usr/bin/python
# -*- coding: utf-8 -*-

# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'devekayan'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

# routes_app is a tuple of tuples.  The first item in each is a regexp that will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:


#routers = dict(
  #BASE  = dict(default_application='devekayan'),
#)


#routes_app = ((r'/(?Pwelcome|admin|app)\b.*', r'\g'),
  #(r'(.*)', r'devekayan'),
  #(r'/?(.*)', r'devekayan'))

# routes_in is a tuple of tuples.  The first item in each is a regexp that will
# be used to match the incoming request URL. The second item in the tuple is
# what it will be replaced with.  This mechanism allows you to redirect incoming
# routes to different web2py locations
#
# Example: If you wish for your entire website to use init's static directory:
#
#   routes_in=( (r'/static/(?P[\w./-]+)', r'/init/static/\g') )
#

routes_in = (
  ('/$anything','404->/devekayan/view/user/$anything'),
)

routes_out = [(x, y) for (y, x) in routes_in]

# routes_out, like routes_in translates URL paths created with the web2py URL()
# function in the same manner that route_in translates inbound URL paths.
#

#routes_out = ((r'.*http://otherdomain.com.* /app/ctr(?P.*)', r'\g'),
  #(r'/app(?P.*)', r'\g'))

# Specify log level for rewrite's debug logging
# Possible values: debug, info, warning, error, critical (loglevels),
#  off, print (print uses print statement rather than logging)
# GAE users may want to use 'off' to suppress routine logging.
#
logging = 'debug'

# Error-handling redirects all HTTP errors (status codes >= 400) to a specified
# path.  If you wish to use error-handling redirects, uncomment the tuple
# below.  You can customize responses by adding a tuple entry with the first
# value in 'appName/HTTPstatusCode' format. ( Only HTTP codes >= 400 are
# routed. ) and the value as a path to redirect the user to.  You may also use
# '*' as a wildcard.
#
# The error handling page is also passed the error code and ticket as
# variables.  Traceback information will be stored in the ticket.
#
# routes_onerror = [
# (r'init/400', r'/init/default/login')
#,(r'init/*', r'/init/static/fail.html')
#,(r'*/404', r'/init/static/cantfind.html')
#,(r'*/*', r'/init/error/index')
# ]

# specify action in charge of error handling
#
# error_handler = dict(application='error',
#  controller='default',
#  function='index')

# In the event that the error-handling page itself returns an error, web2py will
# fall back to its old static responses.  You can customize them here.
# ErrorMessageTicket takes a string format dictionary containing (only) the
# &qu

Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
I wrote the below line in routes.py. But I am getting a server response of 
400 instead of 404.

INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
HTTP/1.1" 400 -

So I tried after changing 404 to 400 but it is still the same. No 
redirection or request for the target URL is made.

What might be causing the problem ?

I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)

On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>
> It can be done already
>
> ('/$anything','404->/myapp/default/catchall/$anything')
>
> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>
>> I wonder if we should try to support this formally. Perhaps if as a 
>> "catchall" if the router doesn't find any valid routes and before it 
>> returns a 404?
>
>

[web2py] Vanity URLs

2012-07-07 Thread Sushant Taneja
Hi,

I want to generate vanity urls for my users. For example: 
www.domain.com/user_first_name
The above URL should actually point to the 
www.domain.com/appname/view/user/user_first_name 

How should I configure my routes.py so that I can achieve the above without 
disturbing other URLs ?
Also I would like to remove the application name from all the URLs.

I read about routes.py from the web2py online book. But was unable to form 
routes_in and routes_out correctly.

PS: My application is deployed on AppEngine

Thanks,
Sushant



[web2py] Re: Using admin interface on GAE, getting errors on update or insert

2012-07-03 Thread Sushant Taneja
Whenever any query in run on GAE which involves usage of two or more 
properties, App engine forces you to define the index for those properties 
of the entity type. You need to modify the index.yaml file to achieve this.

Take a look at this:
https://developers.google.com/appengine/docs/python/config/indexconfig

I hope it clears your confusion.

On Saturday, June 23, 2012 2:59:33 AM UTC+5:30, mike haberman wrote:
>
> New to web2py and GAE.  But with a very simple example, I 
> am unable to use web2py admin interface to modify the database
>
> Using the admin interface for an application,
> I can navigate to 'Administrative Interface' --> Applications --> (blog) 
>  Edit --> Models --> database administration
>
> I can update/insert on any of the auth_ tables
> but I get the following error on any table that I create within models for 
> web2py
>
>  no matching 
> index found. 
> The suggested index for this query is: - kind: auth_user properties: - 
> name: first_name - name: last_name
>
> Is there something I need to do to the model definition to avoid this 
> error ?
>
> (Also when trying to create a new entity via GAE's Datastore viewer, some 
> fields are missing 
> even though it displays all the fields for each entity from a query.  Is 
> there something by default that
> makes some fields not show up?)
>
>
> thanks
>
> mike
>
>

[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
Sorry got confused.
Made it work !

Here is the final code :

dal_db.UserImageStore.insert(profile_image = 
dal_db.UserImageStore.profile_image.store(profile_image,),
profile_blob = profile_image,
upload_ts = datetime.now(),
change_ts = datetime.now()
)

Thanks Anthony !

On Monday, June 18, 2012 8:28:25 PM UTC+5:30, Sushant Taneja wrote:
>
> Will this work on AppEngine ? Since there is no filesystem
>
> The code for manual uploads is :
>
> stream = open(filename,'rb')
>
> Will this not give error since it will not be able to find the file ? 
>
> On Monday, June 18, 2012 6:52:02 PM UTC+5:30, Anthony wrote:
>>
>> and the my show_image function is :
>>>
>>> def show_image():
>>> return response.download(request,dal_db)
>>>
>>
>> That's the problem -- response.download() calls dal.Field.retrieve(), 
>> which assumes the filename is encoded via base64.b16encode (i.e., it 
>> assumes the file was stored using dal.Field.store(), which encodes the 
>> filename). Instead of manually creating the filename, you could use this 
>> procedure: http://web2py.com/books/default/chapter/29/6#Manual-uploads. 
>> Just make the filename exactly what you want the downloaded filename to be 
>> (including the extension), and do the insert into the upload field -- it 
>> should automatically create the encoded name, store the name in the upload 
>> field, and store the image in the blob field. In this case, the image 
>> should be a file stream, and I think fetch will return a string, so you 
>> might need to do:
>>
>> import cStringIO
>> profile_image = cStringIO.StringIO(result.content)
>>
>> Anthony
>>
>

[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
Will this work on AppEngine ? Since there is no filesystem

The code for manual uploads is :

stream = open(filename,'rb')

Will this not give error since it will not be able to find the file ? 

On Monday, June 18, 2012 6:52:02 PM UTC+5:30, Anthony wrote:
>
> and the my show_image function is :
>>
>> def show_image():
>> return response.download(request,dal_db)
>>
>
> That's the problem -- response.download() calls dal.Field.retrieve(), 
> which assumes the filename is encoded via base64.b16encode (i.e., it 
> assumes the file was stored using dal.Field.store(), which encodes the 
> filename). Instead of manually creating the filename, you could use this 
> procedure: http://web2py.com/books/default/chapter/29/6#Manual-uploads. 
> Just make the filename exactly what you want the downloaded filename to be 
> (including the extension), and do the insert into the upload field -- it 
> should automatically create the encoded name, store the name in the upload 
> field, and store the image in the blob field. In this case, the image 
> should be a file stream, and I think fetch will return a string, so you 
> might need to do:
>
> import cStringIO
> profile_image = cStringIO.StringIO(result.content)
>
> Anthony
>


[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
The code for the model UserImageStore is :

dal_db.define_table('UserImageStore',
Field('profile_image','upload',uploadfield='profile_blob'),
Field('profile_blob','blob'),
Field('upload_ts','datetime'),
Field('change_ts','datetime')
)

and the my show_image function is :

def show_image():
return response.download(request,dal_db)




On Monday, June 18, 2012 5:58:27 PM UTC+5:30, Anthony wrote:
>
> What is your db.UserImageStore model, and what is the code for downloading 
> the image?
>
> On Monday, June 18, 2012 7:49:58 AM UTC-4, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I am building an app using AppEngine + Web2py
>>
>> A user's profile image is retrieved from his Facebook profile via the 
>> Graph API and stored in database.
>> The image is stored and displayed correctly. 
>> But whenever I right-click and save the image, the saved file name is 
>> just some set unicode characters I guess and not the name from which the 
>> image is saved.
>>
>> *Eg:  *-îÏìÄÊ-¨-¢‚H-¦_â.jpg
>>
>> How do I correct this file name ? Below is the code which I am using to 
>> generate image names:
>>
>>
>> def create_user_pic_fb():
>> """
>> This method fetches the FB profile image of the user and sets it 
>> as user profile image
>> """
>>
>> from google.appengine.api import urlfetch
>> from random import randint
>>
>> user_fb_id = request.args[0]
>> user_profile_image_url = 
>> FB_PROFILE_IMAGE_URL.replace('USER_FB_ID',user_fb_id)
>>
>> random_str = str(randint(1,))
>> logger.debug(random_str)
>>
>> # Get profile image blob from facebook
>> result = urlfetch.fetch(user_profile_image_url)
>> logger.debug("Read profile image")
>> profile_image = result.content
>>
>> profile_image_name = 'UserImageStore.profile_image.' + random_str + 
>> '_' + user_fb_id + '.' + result.headers['Content-Type'].split('/').pop()
>>
>> # Insert the images in DB
>> dal_db.UserImageStore.insert(profile_image=profile_image_name,
>> profile_blob=profile_image,
>> upload_ts = datetime.now(),
>> change_ts = datetime.now()
>> )
>> 
>>
>>
>> The same result is received from using urllib2 instead of urlfetch.
>>
>

[web2py] Auto Login Redirect Failure

2012-06-14 Thread Sushant Taneja
r bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];
$('#photocoord').show();

$('#photoUpload').css({'margin-left':-($('#photoUpload').width()/2+30)});
});
$('#previewBox').css({width:'300px', height:'300px', 
overflow:'hidden'});

$('#photoUpload').css({'margin-left':-($('#photoUpload').width()/2+30)});
$('#photocoord a').click(function(){
//$('span.temp').html('Saving Image');
ajax('create_profile_pic', ['x','y','w','h'], ':eval');
return false;
});
{{pass}}
});



*The Problem:*

When the user clicks on "Complete Registration" button, the code redirects 
to the profile page as we can see in the GAE server logs

INFO 2012-06-14 15:43:31,057 dev_appserver.py:2891] "POST 
/devekayan*/registration/activate?email=sushant.tanej...@gmail.com&id=755047905ed0e8df1d90cfa687ca0f4986d1e946
 
HTTP/1.1" 303 -*
INFO 2012-06-14 15:43:31,242 gaehandler.py:69]  Request: 
149.23ms/150.00ms (real time/cpu time)
INFO 2012-06-14 15:43:31,248 recording.py:486] Saved; key: 
__appstats__:011000, part: 60 bytes, full: 6092 bytes, overhead: 0.000 + 
0.005; link: http://localhost:8080/_ah/stats/details?time=1339688611093
INFO 2012-06-14 15:43:31,266 dev_appserver.py:2891] "GET 
/devekayan*/user/profile 
HTTP/1.1" 200 -*
INFO 2012-06-14 15:43:31,322 dev_appserver.py:2891] "GET 
/devekayan/static/js/jquery.js?_=1339688611296 HTTP/1.1" 200 -
INFO 2012-06-14 15:43:31,460 dev_appserver.py:2891] "GET 
/devekayan/static/js/web2py.js?_=1339688611425 HTTP/1.1" 200 -
INFO 2012-06-14 15:43:31,508 dev_appserver.py:2891] "GET 
/devekayan/static/js/jquery.easing.js?_=1339688611466 HTTP/1.1" 200 -
INFO 2012-06-14 15:43:31,547 dev_appserver.py:2891] "GET 
/devekayan/static/js/jquery.form.js?_=1339688611518 HTTP/1.1" 200 -


But on the client side nothing happens. (i.e. the user remains on the 
registration page itself). The profile page is not loaded at all.
The problem started occurring only after we integrated the blobstore 
service. Earlier we were storing images in datastore and everything was 
working fine.

I have reproduced the problem in production and on both Chrome and Firefox 
browers.

Can anyone tell me what might be the problem ?

Thanks,
Sushant Taneja





[web2py] Re: HTML in context_dict for sending mails

2012-06-05 Thread Sushant Taneja
This does not work. Still facing the same issue.

On Monday, June 4, 2012 8:57:34 PM UTC+5:30, Anthony wrote:
>
> By default, the template engine escapes everything -- to avoid that, do:
>
> links = XML("user_a")
>
> See http://web2py.com/books/default/chapter/29/5#XML.
>
> Anthony
>
> On Monday, June 4, 2012 10:52:07 AM UTC-4, Sushant Taneja wrote:
>>
>> Hi All,
>>
>> I have a string var containing some HTML code
>>
>> links = "user_a"
>> I am passing this variable to response.render function as: 
>>
>> context_dict = dict(links=links)
>> message = response.render("invite_friend.html",context_dict)
>>
>> # Send mail code below
>>
>> In invite_friend.html I have the code:
>>
>> 
>> Hello there, 
>> 
>> {{=links}}
>> 
>> 
>>
>> When the mail is sent, the email message is rendered as below:
>>
>> Hello there, 
>> user_a
>>
>> instead of
>>
>> Hello there,
>>
>>- user_a 
>>
>>
>> How to render the above mail properly ?? I am working on GAE and 
>> mail.settings.server is set to 'gae'
>>
>>

[web2py] Re: web2py + GAE memory usage

2012-05-28 Thread Sushant Taneja
I am not sure, as I am not well versed with how python handles memory but 
does the following link help :

https://developers.google.com/appengine/docs/python/runtime#App_Caching

Please let me know if you have found any solution.

Thanks,
Sushant

On Monday, May 28, 2012 9:44:20 PM UTC+5:30, Sushant Taneja wrote:
>
> Did you find the solution to the problem ? 
> I am facing the same issue.
>
> Thanks,
> Sushant
>
> On Tuesday, February 21, 2012 2:02:08 AM UTC+5:30, howesc wrote:
>>
>> it does not seem to make a difference, so it is something else...
>
>

[web2py] Re: web2py + GAE memory usage

2012-05-28 Thread Sushant Taneja
Did you find the solution to the problem ? 
I am facing the same issue.

Thanks,
Sushant

On Tuesday, February 21, 2012 2:02:08 AM UTC+5:30, howesc wrote:
>
> it does not seem to make a difference, so it is something else...



[web2py] Re: Integrating error pages in web2py on app engine

2012-05-11 Thread Sushant Taneja
Yes I did configure the routes_onerror in routes.py
But whenever I entered the URL of the page which does not exist, it would 
still return me *invalid request.*


On Saturday, May 12, 2012 8:40:35 AM UTC+5:30, Anthony wrote:
>
> There's no such thing as routers.py -- if using the parameter-based 
> rewrite system, you still use routes.py. Anyway, did you try adding 
> routes_onerror to routes.py: 
> http://web2py.com/books/default/chapter/29/4#Routes-on-error? Note, you 
> have to restart the app for routes changes to take effect.
>
> Anthony
>
> On Friday, May 11, 2012 11:06:18 PM UTC-4, Sushant Taneja wrote:
>>
>> Hi All,
>>
>> I have two static custom errors pages for all 4XX and 5XX error codes.
>> I want to integrate them with my web2py application which needs to be 
>> deployed on app engine.
>>
>> I tried playing around with routes.py as well as routers.py but still 
>> couldn't fix the same.
>>
>> Can anyone please tell me the correct way to achieve the above ?
>>
>> Thanks and Regards,
>> Sushant Taneja
>>
>

[web2py] Integrating error pages in web2py on app engine

2012-05-11 Thread Sushant Taneja
Hi All,

I have two static custom errors pages for all 4XX and 5XX error codes.
I want to integrate them with my web2py application which needs to be 
deployed on app engine.

I tried playing around with routes.py as well as routers.py but still 
couldn't fix the same.

Can anyone please tell me the correct way to achieve the above ?

Thanks and Regards,
Sushant Taneja


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
Thanks. Got that reply sometime after I posted. 
I have changed my code. I have now created an upload image component with a 
form and am using the LOAD() feature with ajax=False to get it working.

Thanks again for the reply. Helped a lot ! :)

On Monday, April 2, 2012 7:20:24 PM UTC+5:30, Anthony wrote:
>
> But as I stated above, the problem is the  element which contains the 
>> _formname and _formkey is not getting generated on the page for the image 
>> upload form and I think that it might be creating the problem.
>>
>> What can be the reason for it ?
>>
>
> Did you see my other reply? It sounds like you are not calling 
> form.accepts (or .process or .validate) when the form is initially created. 
> It will help if you show your current code.
>
> Anthony 
>


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
Thanks Anthony. 

But as I stated above, the problem is the  element which contains the 
_formname and _formkey is not getting generated on the page for the image 
upload form and I think that it might be creating the problem.

What can be the reason for it ?


On Monday, April 2, 2012 6:29:41 PM UTC+5:30, Anthony wrote:
>
> I tried with form.validate() and also with form.process().accepted. Can 
>> you provide some sample code on how do I achieve the above ?
>> I am already providing the name of the form while declaring it. How is it 
>> different from web2py generated _formname ?
>>
>
> Your original code simply set the "name" attribute of the HTML  
> element (i.e., SQLFORM(..., _name=...)). However, that doesn't affect the 
> _formname hidden element. To set that, you have to set the "formname" 
> argument to the accepts() method (or process() or validate()).  Anyway, 
> I'm not sure you need to set your own formname -- web2py will automatically 
> generate a formname based on the db table name and type of form, so two 
> forms on the same page based on different tables will have different names 
> anyway. See 
> http://web2py.com/books/default/chapter/29/7#Multiple-forms-per-page.
>
> Anthony
>


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
I also checked using chrome developer tools that the  which contains 
the _formkey and _formname is not getting generated (missing from HTML). 
May be that is the reason the form is not working.

What may be the reason for this ? and what is a feasible solution ? 

On Monday, April 2, 2012 10:55:51 AM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> I tried with form.validate() and also with form.process().accepted. Can 
> you provide some sample code on how do I achieve the above ?
> I am already providing the name of the form while declaring it. How is it 
> different from web2py generated _formname ?
>
> On Monday, April 2, 2012 5:07:14 AM UTC+5:30, Anthony wrote:
>>
>> In the method which defines the registration form, I return upload_form 
>>> alongside as :
>>>
>>> return(reg_form=reg_form,upload_form=upload_form)
>>>
>>> The problem is that the _formkey and _formname hidden fields are created 
>> when you call form.accepts() -- so you have to call form.accepts() both 
>> when the form is first created and returned to the view and when the form 
>> is submitted. The form object that you are returning to the view does not 
>> include those hidden fields, but the form processing code in upload_image() 
>> is expecting those fields to be there. Also, it is recommended that you use 
>> the newer form.process() or form.validate() API rather than form.accepts().
>>
>> Anthony
>>
>>

[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-01 Thread Sushant Taneja
Hi,

I tried with form.validate() and also with form.process().accepted. Can you 
provide some sample code on how do I achieve the above ?
I am already providing the name of the form while declaring it. How is it 
different from web2py generated _formname ?

On Monday, April 2, 2012 5:07:14 AM UTC+5:30, Anthony wrote:
>
> In the method which defines the registration form, I return upload_form 
>> alongside as :
>>
>> return(reg_form=reg_form,upload_form=upload_form)
>>
>> The problem is that the _formkey and _formname hidden fields are created 
> when you call form.accepts() -- so you have to call form.accepts() both 
> when the form is first created and returned to the view and when the form 
> is submitted. The form object that you are returning to the view does not 
> include those hidden fields, but the form processing code in upload_image() 
> is expecting those fields to be there. Also, it is recommended that you use 
> the newer form.process() or form.validate() API rather than form.accepts().
>
> Anthony
>
>

[web2py] Re: executing javascript after accepting a form

2012-03-27 Thread Sushant Taneja
Hi,

If you are submitting your form via ajax then you can use eval to call a JS 
function.
You can check out the syntax here : 
http://web2py.com/books/default/chapter/29/11#Eval-target

create a JS function 
showDialog(){

// write code here
}

in the controller write the return statement as :

return "showDialog()"

Hope it helps !


On Tuesday, March 27, 2012 6:01:14 PM UTC+5:30, José L. wrote:
>
> Hi, I'm having problems trying to show a modal window after the user 
> submits correctly a form.
> I've tried to do it with:
>
> def index():
> 
> if form.accepts(request.vars):
> response.js='$( "#dialog-message" ).dialog({ modal: true   });'
> ...
>
> being #dialog-message a div in the same index.html page, but response.js 
> doesn't do anything, and it seems to work only inside componentes.
>
> Any idea to get this funcionality working?
> Thanks.
>


[web2py] Re: Acces a page with @auth.requires_login() don't work

2012-03-25 Thread Sushant Taneja
Just a thought here, but have you tried logging out and logging in again 
with the same password. Does it work ?

On Sunday, March 25, 2012 3:47:53 PM UTC+5:30, bussiere adrien wrote:
>
> i've created and logged my user with :
>
> password="toto"
> my_crypt = CRYPT(key=auth.settings.hmac_​key)
> crypt_pass = my_crypt(password)[0]
> user = db.auth_user.insert(
>Surnom="Surnom",
>email="email",
>password=crypt_pass​,
>)
> db.commit()
> session.auth = 
> Storage(user=user,expiration=a​uth.settings.expiration,hmac_​key=str(uuid4()))
> auth.login_bare(user,password)
> and i have no error
>
> but when i wan to access a page with :
> @auth.requires_login()
>
> it don't work
> Ragrds
> Bussiere
>
>

[web2py] Re: Using Blobstore API

2012-03-24 Thread Sushant Taneja
Hi,

Thanks for the help. I had too much to work on, so I left the problem for 
the time.
Now I am back working on blobstore module.

I was looking at the code in web2py slices and in other threads in the 
group and got confused again.
I think the problem is too many versions/parts of the code here and there. 
Like on web2pyslices itself, there are 3 versions, the slice itself and the 
code in the comments. Now assuming the latest comment is the updated code, 
I find many things different from the code of the slice and very less 
documentation/changelog on it. 

I tried running the code in the latest comment but could not get it working.

I hope you understand my problem. I would really appreciate if somebody 
could compile the code (which would include the DB structure, the 
controller methods and the view) at one place, a new slice maybe.

Thanks.

On Thursday, March 8, 2012 1:07:41 PM UTC+5:30, howesc wrote:
>
> looking at my code that i shared in your other thread, it seems that you 
> are missing the redirect to signal to GAE that your handler did what it 
> needed to do and GAE should commit the blob to the blobstore.  i assume my 
> comment here was important to me when i set this up:
>
> #Raise the HTTP exception so that the response content stays empty.
> #calling redirect puts content in the body which fails the blob 
> upload
> raise HTTP(303,
>Location= URL(r=request,f='upload_image'​, 
> args=form.vars.id))
>
>
> while the example here 
> http://code.google.com/​appengine/docs/python/​blobstore/overview.html<http://code.google.com/appengine/docs/python/blobstore/overview.html>shows
>  the redirect, they neglect to state that it is requiredthough i 
> think it might be.
>
>
> On Wednesday, March 7, 2012 1:36:40 AM UTC-8, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I am trying to use the Google Blobstore API for uploading images. I also 
>> checked the link: 
>> http://www.web2pyslices.​com/main/slices/take_slice/63<http://www.web2pyslices.com/main/slices/take_slice/63>
>>  ​for 
>> the help but couldn't understand much.
>>
>> In my application's (uploadPic) default controller I have the code as 
>> follows:
>>
>> from google.appengine.ext import blobstore
>>
>> def index():
>> """
>> This provides the upload_url to the upload form
>> """
>> 
>> upload_url=blobstore.create_​upload_url(URL('uploadPic','​default','pic'))
>> return dict(upload_url=upload_url)
>>
>> def pic():
>> """
>> This method stores the bolb key in a table and is used for serving 
>> the BLOB images
>> """
>> response.write(request)
>>
>> In the view index.html, I have a simple form
>>
>> 
>> 
>> > enctype='multipart/form-data'>
>> 
>> 
>> 
>> 
>> 
>>
>> As per my understanding, when the upload is successful, GAE automatically 
>> redirects to the URL provided in the create_upload_url function with the 
>> request containing the blob_key.
>>
>> But when I execute the above, all I get in the page is None. The log is 
>> showing the following:
>>
>> INFO 2012-03-07 09:30:31,188 dev_appserver.py:2865] "GET 
>> /uploadPic/default/index HTTP/1.1" 200 -
>> INFO 2012-03-07 09:30:37,558 dev_appserver.py:687] Internal 
>> redirection to /uploadPic/default/pic
>> INFO 2012-03-07 09:30:37,681 gaehandler.py:69]  Request: 
>> 104.29ms/100.00ms (real time/cpu time)
>> INFO 2012-03-07 09:30:37,686 recording.py:372] Saved; key: 
>> __appstats__:037500, part: 20 bytes, full: 1234 bytes, overhead: 0.000 + 
>> 0.004; link: 
>> http://localhost:8080/_ah/​stats/details?time=​1331112637576<http://localhost:8080/_ah/stats/details?time=1331112637576>
>> INFO 2012-03-07 09:30:37,695 dev_appserver_blobstore.py:​447] Upload 
>> handler returned 200
>> INFO 2012-03-07 09:30:37,723 dev_appserver.py:2865] "POST 
>> /_ah/upload/ag9kZXZ-​aW1hZ2V1cGxvYWRyGwsSFV9fQmxvYl​VwbG9hZFNlc3Npb25fXxggDA 
>> HTTP/1.1" 200 -
>>
>> Can someone please help me understand it ? 
>>
>> Thanks,
>> Sushant
>>
>>
>>

[web2py] Re: Auto Login on Google App engine

2012-03-23 Thread Sushant Taneja
Thanks. 
I have a user object in the memory, may be I can use it to store the data 
in session. Let me try this out.
In the meantime, can you explain what does the line no: 1959 (as below) 
does ??

1959 user = 
Storage<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
(table_user._filter_​​fields<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
(user, id=True)) 

On Saturday, March 24, 2012 4:17:29 AM UTC+5:30, howesc wrote:
>
> can you disable auto-login, and then in your wrapping controller (or 
> perhaps there is an onaccept handler) manually add the user data to the 
> session?  "login" really just means 'verify that the user exists in the db 
> with the right credentials and then copy some stuff to the session' so you 
> have done the first parts and could manually copy stuff to the session 
> perhaps.
>
> On Friday, March 23, 2012 5:55:33 AM UTC-7, Sushant Taneja wrote:
>>
>> Hi,
>>
>> As per the source code of the auth.register(), if auto-login is enabled, 
>> another DAL query is executed to get the user from auth_user table. 
>>
>> 1958 user = self.db(table_user[username] == 
>> form.vars[username]).select<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> ().​​first<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> () 
>>
>> This user object is then set in the session and user is redirected to the 
>> page specified.
>>
>> 1959 user = 
>> Storage<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> (table_user._filter_​​fields<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> (user, id=True)) 1960 
>> session<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> .auth = 
>> Storage<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> (user=user, 
>> last_visit=request<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> .now, 1961 
>> expiration=self.settings<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> .expir​​ation, 1962 hmac_key = 
>> web2py_uuid<http://www.web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>
>> ()) 
>>
>> But on App engine's HRD, this read (line no: 1958 as above) fails.
>> As per my understanding, this is because the write operation of the 
>> auth_user table is still not complete so the query returns None and thus 
>> the code in line 1959/1960 fails.
>>
>> Can somebody suggest a workaround for this problem ?
>> I would really like to include the auto login feature in my app. 
>>
>> Also what does the line of code in *line number: 1959* exactly does ?
>>
>> Thanks,
>> Sushant
>>
>

[web2py] Auto Login on Google App engine

2012-03-23 Thread Sushant Taneja
Hi,

As per the source code of the auth.register(), if auto-login is enabled, 
another DAL query is executed to get the user from auth_user table. 

1958 user = self.db(table_user[username] == 
form.vars[username]).select
().first
() 

This user object is then set in the session and user is redirected to the 
page specified.

1959 user = 
Storage
(table_user._filter_fields
(user, id=True)) 1960 
session
.auth = 
Storage
(user=user, 
last_visit=request
.now, 1961 
expiration=self.settings
.expiration, 1962 hmac_key = 
web2py_uuid
()) 

But on App engine's HRD, this read (line no: 1958 as above) fails.
As per my understanding, this is because the write operation of the 
auth_user table is still not complete so the query returns None and thus 
the code in line 1959/1960 fails.

Can somebody suggest a workaround for this problem ?
I would really like to include the auto login feature in my app. 

Also what does the line of code in *line number: 1959* exactly does ?

Thanks,
Sushant


Re: [web2py] Correct way to use memcache on GAE with web2py

2012-03-18 Thread Sushant Taneja
Thanks for the info.

On Saturday, March 17, 2012 4:11:40 AM UTC+5:30, howesc wrote:
>
> 1. that is how GAE queries works.  it's GAE's fault, not web2py's. 
> 2. correct.  Rows objects are not pickelable.  as_list() or as_dict() are 
> your friend.  this is not just for GAE but all environments i believe.
>
> On Friday, March 16, 2012 10:03:36 AM UTC-7, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I am stuck here, I tried the mentioned code, there are 2 problems I am 
>> facing:
>>
>> 1. All the table columns are extracted rather than only the two columns 
>> in the select()
>> 2. I get pickling error when I try to add the Rows object to memcache
>>
>> *PicklingError: Can't pickle : attribute lookup 
>> __builtin__.function failed*
>>
>> but once I use the as_list() function it works fine.
>>
>> Any thoughts ?
>>
>> On Friday, March 16, 2012 1:07:58 PM UTC+5:30, Sushant Taneja wrote:
>>>
>>> Thanks ! 
>>>
>>> On Friday, March 16, 2012 2:04:42 AM UTC+5:30, Jonathan Lundell wrote:
>>>>
>>>> On Mar 15, 2012, at 1:15 PM, Sushant Taneja wrote:
>>>> > I have a tags table which will be available to all logged in users. 
>>>> The table has the following structure:
>>>> > 
>>>> > db.define_table('META_TAG',
>>>> > Field('tag','string',notnull=True),
>>>> > Field('root_tag','string',notnull=True),
>>>> > Field('active_ind','string',length=1,default='Y')
>>>> > )
>>>> > 
>>>> > This table will be rarely (once a month) updated via an 
>>>> administrative interface.
>>>> > I read various web2py based examples and gae examples on using 
>>>> memcache. Each followed a different approach.
>>>> > As per my understanding from appengine documentation, I have written 
>>>> the following helper function in a controller to use memcache:
>>>> > 
>>>> > from google.appengine.api import memcache
>>>> > 
>>>> > def get_tags():
>>>> > """This function returns cached value for META_TAG table"""
>>>> > tags = memcache.get("tags")
>>>> > if not words:
>>>> > words = 
>>>> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
>>>> > memcache.add("tags",tags)
>>>> > return tags
>>>> > else:
>>>> > return tags
>>>> > 
>>>> > Will the above code ensure that the correct data is always available 
>>>> in the memcache ?
>>>>
>>>> You seem to be mixing the names 'words' and 'tags'.
>>>>
>>>> As a matter of style, I'd move the return outside the if/else.
>>>>
>>>> Don't forget to set the cache when you update the tags.
>>>>
>>>> It's best to test for 'is None', in case your cached object can 
>>>> legitimately evaluate to False (an empty list or string, for example). So 
>>>> more like:
>>>>
>>>> from google.appengine.api import memcache
>>>>
>>>> def get_tags():
>>>> """This function returns cached value for META_TAG table"""
>>>> tags = memcache.get("tags")
>>>> if tags is None:
>>>> tags = 
>>>> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
>>>> memcache.add("tags",tags)
>>>> return tags
>>>>
>>>>

Re: [web2py] Correct way to use memcache on GAE with web2py

2012-03-16 Thread Sushant Taneja
Hi,

I am stuck here, I tried the mentioned code, there are 2 problems I am 
facing:

1. All the table columns are extracted rather than only the two columns in 
the select()
2. I get pickling error when I try to add the Rows object to memcache

*PicklingError: Can't pickle : attribute lookup 
__builtin__.function failed*

but once I use the as_list() function it works fine.

Any thoughts ?

On Friday, March 16, 2012 1:07:58 PM UTC+5:30, Sushant Taneja wrote:
>
> Thanks ! 
>
> On Friday, March 16, 2012 2:04:42 AM UTC+5:30, Jonathan Lundell wrote:
>>
>> On Mar 15, 2012, at 1:15 PM, Sushant Taneja wrote:
>> > I have a tags table which will be available to all logged in users. The 
>> table has the following structure:
>> > 
>> > db.define_table('META_TAG',
>> > Field('tag','string',notnull=True),
>> > Field('root_tag','string',notnull=True),
>> > Field('active_ind','string',length=1,default='Y')
>> > )
>> > 
>> > This table will be rarely (once a month) updated via an administrative 
>> interface.
>> > I read various web2py based examples and gae examples on using 
>> memcache. Each followed a different approach.
>> > As per my understanding from appengine documentation, I have written 
>> the following helper function in a controller to use memcache:
>> > 
>> > from google.appengine.api import memcache
>> > 
>> > def get_tags():
>> > """This function returns cached value for META_TAG table"""
>> > tags = memcache.get("tags")
>> > if not words:
>> > words = 
>> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
>> > memcache.add("tags",tags)
>> > return tags
>> > else:
>> > return tags
>> > 
>> > Will the above code ensure that the correct data is always available in 
>> the memcache ?
>>
>> You seem to be mixing the names 'words' and 'tags'.
>>
>> As a matter of style, I'd move the return outside the if/else.
>>
>> Don't forget to set the cache when you update the tags.
>>
>> It's best to test for 'is None', in case your cached object can 
>> legitimately evaluate to False (an empty list or string, for example). So 
>> more like:
>>
>> from google.appengine.api import memcache
>>
>> def get_tags():
>> """This function returns cached value for META_TAG table"""
>> tags = memcache.get("tags")
>> if tags is None:
>> tags = 
>> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
>> memcache.add("tags",tags)
>> return tags
>>
>>

Re: [web2py] Correct way to use memcache on GAE with web2py

2012-03-16 Thread Sushant Taneja
Thanks ! 

On Friday, March 16, 2012 2:04:42 AM UTC+5:30, Jonathan Lundell wrote:
>
> On Mar 15, 2012, at 1:15 PM, Sushant Taneja wrote:
> > I have a tags table which will be available to all logged in users. The 
> table has the following structure:
> > 
> > db.define_table('META_TAG',
> > Field('tag','string',notnull=True),
> > Field('root_tag','string',notnull=True),
> > Field('active_ind','string',length=1,default='Y')
> > )
> > 
> > This table will be rarely (once a month) updated via an administrative 
> interface.
> > I read various web2py based examples and gae examples on using memcache. 
> Each followed a different approach.
> > As per my understanding from appengine documentation, I have written the 
> following helper function in a controller to use memcache:
> > 
> > from google.appengine.api import memcache
> > 
> > def get_tags():
> > """This function returns cached value for META_TAG table"""
> > tags = memcache.get("tags")
> > if not words:
> > words = 
> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
> > memcache.add("tags",tags)
> > return tags
> > else:
> > return tags
> > 
> > Will the above code ensure that the correct data is always available in 
> the memcache ?
>
> You seem to be mixing the names 'words' and 'tags'.
>
> As a matter of style, I'd move the return outside the if/else.
>
> Don't forget to set the cache when you update the tags.
>
> It's best to test for 'is None', in case your cached object can 
> legitimately evaluate to False (an empty list or string, for example). So 
> more like:
>
> from google.appengine.api import memcache
>
> def get_tags():
> """This function returns cached value for META_TAG table"""
> tags = memcache.get("tags")
> if tags is None:
> tags = 
> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
> memcache.add("tags",tags)
> return tags
>
>

[web2py] Correct way to use memcache on GAE with web2py

2012-03-15 Thread Sushant Taneja
Hi,

I have a tags table which will be available to all logged in users. The 
table has the following structure:

db.define_table('META_TAG',
Field('tag','string',notnull=True),
Field('root_tag','string',notnull=True),
Field('active_ind','string',length=1,default='Y')
)

This table will be rarely (once a month) updated via an administrative 
interface.
I read various web2py based examples and gae examples on using memcache. 
Each followed a different approach.
As per my understanding from appengine documentation, I have written the 
following helper function in a controller to use memcache:

*from google.appengine.api import memcache*

def get_tags():
"""This function returns cached value for META_TAG table"""
tags = memcache.get("tags")
if not words:
words = 
db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
memcache.add("tags",tags)
return tags
else:
return tags

Will the above code ensure that the correct data is always available in the 
memcache ?


Re: [web2py] LOAD() function breaking CSS animation

2012-03-13 Thread Sushant Taneja
Thanks to both Bruno and Anthony !
It is working now :)

On Wednesday, March 14, 2012 2:05:42 AM UTC+5:30, Anthony wrote:
>
> Although the component (i.e., LOAD) is not initially an Ajax component, 
> because you have ajax_trap=True, it becomes an Ajax component upon form 
> submission (i.e., the form is submitted via Ajax, and the post-submission 
> response is loaded into the component target via Ajax). Your "click" event 
> handler is only set once when the page initially loads, so after a form 
> submission, the new content of the component has no "click" handler 
> attached. Instead, you should use the new jQuery.on() (which is recommended 
> instead of .live() or .delegate() -- see http://api.jquery.com/on/) to 
> attached the click event.
>
> Anthony
>
> On Tuesday, March 13, 2012 4:15:57 PM UTC-4, Sushant Taneja wrote:
>>
>> Sorry, but I didn't get you.
>>
>> As per my understanding the component is loaded with option ajax=False, 
>> thus it will load with rest of the page.
>> The 

Re: [web2py] LOAD() function breaking CSS animation

2012-03-13 Thread Sushant Taneja
Does this mean that I have to reload the JS again with the form as it is 
reloaded after submit ?

On Wednesday, March 14, 2012 1:45:57 AM UTC+5:30, Sushant Taneja wrote:
>
> Sorry, but I didn't get you.
>
> As per my understanding the component is loaded with option ajax=False, 
> thus it will load with rest of the page.
> The 

Re: [web2py] LOAD() function breaking CSS animation

2012-03-13 Thread Sushant Taneja
Sorry, but I didn't get you.

As per my understanding the component is loaded with option ajax=False, 
thus it will load with rest of the page.
The 

Re: [web2py] LOAD() function breaking CSS animation

2012-03-13 Thread Sushant Taneja
Hi,

Below is the CSS Code:

#formContainer{
width:288px;
min-height:100px;
margin:0 auto;
position:relative;
z-index:1;

-moz-perspective: 800px;
-webkit-perspective: 800px;
perspective: 800px;
}

#formContainer table{
width:100%;
height:100%;
position:absolute;
top:0;
left:0;

/* Enabling 3d space for the transforms */
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;

/* When the forms are flipped, they will be hidden */
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;

/* Enabling a smooth animated transition */
-moz-transition:0.666s;
-webkit-transition:0.666s;
transition:0.666s;

}

#login{
z-index:2;
}

#recover{
z-index:1;
opacity:0;
visibility: hidden;

/* Rotating the recover password form by default */
-moz-transform:rotateX(180deg);
-moz-transform:rotateX(180deg);
-webkit-transform:rotateX(180deg);
transform:rotateX(180deg);
}

#formContainer.flipped #login{

opacity:0;
visibility:hidden;
z-index:1;
/**
 * Rotating the login form when the
 * flipped class is added to the container
 */

-moz-transform:rotateX(-180deg);
-webkit-transform:rotateX(-180deg);
transform:rotateX(-180deg);
}

#formContainer.flipped #recover{

opacity:1;
z-index:2;
visibility: visible;
/* Rotating the recover div into view */
-moz-transform:rotateX(0deg);
-webkit-transform:rotateX(0deg);
transform:rotateX(0deg);

}

The following is the JS:

$(function(){
$('.flipLink').click(function(e){
$('#formContainer').toggleClass('flipped');
$('.flash').hide('slow');
})});

And the following is the html code:


{{=login_form.custom.begin}}


{{=login_form.custom.widget.email}}


{{=login_form.custom.widget.password}}


Forgot Password?
{{=login_form.custom.submit}}


{{=response.flash}}


{{=login_form.custom.end}}

{{=LOAD('user','request_reset_password.load',ajax=False,ajax_trap=True)}}


On Wednesday, March 14, 2012 12:53:28 AM UTC+5:30, rochacbruno wrote:
>
> can you share your CSS/ Javascript code regarding the *flipLink and 
> **flipToLogin 
> objects?
>
>
> *
> On Tue, Mar 13, 2012 at 4:04 PM, Sushant Taneja <
> sushant.tanej...@gmail.com> wrote:
>
>> Hi,
>>
>> In my view index.html, I have two forms: auth.login() and custom forgot 
>> password form.
>> Initially the login form is displayed with a Forgot Password link. When 
>> we click on the link the form flips(rotates using CSS) and the forgot 
>> password form is now displayed.
>>
>> The forgot password form is a SQLFORM.factory generated form and is 
>> loaded in the page via the following line of code:
>>
>> {{=LOAD('user','request_reset_password.load',ajax=False,ajax_trap=True)}}
>>
>> The flip animation i.e. CSS rotation works fine until the forgot password 
>> form is submitted.
>> After submission, the CSS breaksWARNING with import and 
>> threading.local(): they were hot topics on the
>> pycon webdev summit, and other frameworks are facing problems with
>> them.
>>
>> They could be memory hungry and contention problems could arise, so
>> they could have scalabillity issues too.
>>
>> I think the web2py way is not so bad, but we should find some way to
>>
>> The .load component is as follows:
>>
>>
>> {{=forgot_pass_form.custom.begin}}
>> 
>> 
>> Give us your email id and we will send you a link 
>> to reset your password
>> 
>> 
>> {{=forgot_pass_form.custom.widget.email_id}}
>> 
>> 
>> *Back to 
>> Login*
>> {{=forgot_pass_form.custom.submit}}
>> 
>> 
>> 
>> {{if forgot_pass_form.errors:}}
>> > class="error">{{=forgot_pass_form.errors.email_id}}
>> {{pass}}
>> 
>> 
>> 
>> {{=forgot_pass_form.custom.end}}
>>
>> The bold code above is the link which causes the CSS rotation but after 
>> submission fails to do so
>>
>> Can somebody help me understand on what's happening ?
>>
>> Thanks,
>> Sushant
>>
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

[web2py] LOAD() function breaking CSS animation

2012-03-13 Thread Sushant Taneja
Hi,

In my view index.html, I have two forms: auth.login() and custom forgot 
password form.
Initially the login form is displayed with a Forgot Password link. When we 
click on the link the form flips(rotates using CSS) and the forgot password 
form is now displayed.

The forgot password form is a SQLFORM.factory generated form and is loaded 
in the page via the following line of code:

{{=LOAD('user','request_reset_password.load',ajax=False,ajax_trap=True)}}

The flip animation i.e. CSS rotation works fine until the forgot password 
form is submitted.
After submission, the CSS breaks

The .load component is as follows:


{{=forgot_pass_form.custom.begin}}


Give us your email id and we will send you a link 
to reset your password


{{=forgot_pass_form.custom.widget.email_id}}


*Back to Login
*
{{=forgot_pass_form.custom.submit}}



{{if forgot_pass_form.errors:}}
{{=forgot_pass_form.errors.email_id}}
{{pass}}



{{=forgot_pass_form.custom.end}}

The bold code above is the link which causes the CSS rotation but after 
submission fails to do so

Can somebody help me understand on what's happening ?

Thanks,
Sushant


[web2py] Re: Auth.user is still NULL after a successful login

2012-03-13 Thread Sushant Taneja
Hi,

I studied the source code of auth.login() and found that all the 
validations are applied within the login method itself. The error message 
is automatically written to an element of class flash via setting 
session.flash to auth.messages.invalid_login.

I modified my view code to include the class attribute of the  and set 
its value to "flash" as below:

{{=response.flash}}

Now one can modify the CSS and JS to control how the element is displayed.

As far as I understand, to achieve the required functionality of displaying 
form errors via form.errors.email etc., one can either extend Auth and 
override the login() method or build a custom login functionality.

Let me know if there is an easier way

On Tuesday, March 13, 2012 11:02:54 AM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> Ah, I forget that form.custom.begin is an XML object (more like a string) 
>> and doesn't change when you directly manipulate the form object itself. You 
>> could do:
>>
>> f.custom.begin = '%s id="login">' % f.custom.begin[:-1]
>>
>
>  I added the above code line in controller. The attribute id was added to 
> the form element, but the whole  being tag was rendered as :
>
> *"*
> *"*
> *
> *
> i.e form is displayed a text element and hence JS was not working on it.
>
>  
>
>> if login_form.errors:
>>> login_form.errors.email='Email/Password does not match'
>>>
>>> return dict(login_form=login_form)
>>>
>>> In the view I have :
>>>
>>> 
>>> 
>>> 
>>>
>>
>> Maybe something like:
>>
>> {{if login_form.errors.email:}}
>> 
>> {{=login_form.errors.email}}
>> 
>> {{pass}}
>>
>>
> I didn't want to render the  element dynamically, so I tried the 
> following:
>
> 
> 
> {{if login_form.errors:}}
> {{=login_form.errors.email}}
> {{pass}}
> 
> 
>
> But nothing is happening. 
> In usual cases, if I leave the field empty or enter an invalid email 
> address, an error is displayed but not in this case.
> Even if there are errors, the *login_form.errors* object is empty and 
> nothing is displayed.
>
> How does auth handle authentication errors ?
>
>

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

Ah, I forget that form.custom.begin is an XML object (more like a string) 
> and doesn't change when you directly manipulate the form object itself. You 
> could do:
>
> f.custom.begin = '%s id="login">' % f.custom.begin[:-1]
>

 I added the above code line in controller. The attribute id was added to 
the form element, but the whole  being tag was rendered as :

*"*
*"*
*
*
i.e form is displayed a text element and hence JS was not working on it.

 

> if login_form.errors:
>> login_form.errors.email='Email/Password does not match'
>>
>> return dict(login_form=login_form)
>>
>> In the view I have :
>>
>> 
>> 
>> 
>>
>
> Maybe something like:
>
> {{if login_form.errors.email:}}
> 
> {{=login_form.errors.email}}
> 
> {{pass}}
>
>
I didn't want to render the  element dynamically, so I tried the 
following:



{{if login_form.errors:}}
{{=login_form.errors.email}}
{{pass}}



But nothing is happening. 
In usual cases, if I leave the field empty or enter an invalid email 
address, an error is displayed but not in this case.
Even if there are errors, the *login_form.errors* object is empty and 
nothing is displayed.

How does auth handle authentication errors ?



[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

I found a workaround to the problem. I need to assign the id "login" to the 
form so that certain CSS and JS can be applied to the form elements. Since 
I was unable to assign id to the form, I assigned the id "login" to the 
table element. The login is now working.

But another problem has surfaced. Now whenever I enter correct the 
credentials I am successfully able to login but whenever I enter 
false credentials, I am unable to see any form errors. 
How invalid login is handled by Auth ? 
I want to show the error "Email/Password not matching" below my form. How 
could I do that ? 

My controller code is :

def index():

login_form = auth.login()

# Configure form fields
login_form.custom.widget.email['_value']='Email'
login_form.custom.widget.email['_data']='Email'
login_form.custom.widget.password['_value']='Password'
login_form.custom.widget.password['_data']='Password'
login_form.custom.submit['_value']='Login'

# Configure form properties
# login_form['_id']='login'

if login_form.errors:
login_form.errors.email='Email/Password does not match'

return dict(login_form=login_form)

In the view I have :

{{=login_form.custom.begin}}


{{=login_form.custom.widget.email}}


{{=login_form.custom.widget.password}}


Forgot Password?
{{=login_form.custom.submit}}






{{=login_form.custom.end}}


On Tuesday, March 13, 2012 12:25:53 AM UTC+5:30, Anthony wrote:
>
> Hmm, works when I try it. Can you show the full controller code you have 
> now?
>
> On Monday, March 12, 2012 2:46:57 PM UTC-4, Sushant Taneja wrote:
>>
>> The rendered form is as:
>>
>> 
>> ...
>> 
>>
>> It has no attribute id.
>>
>> On Tuesday, March 13, 2012 12:05:02 AM UTC+5:30, Anthony wrote:
>>>
>>> What's not working? When you view the HTML code of the rendered page in 
>>> the browser, is the id not there, or is it just that some client-side CSS 
>>> or JS isn't working as expected? If the latter, the problem could be that 
>>> you have put the form beginning and ending code inside the  
>>> tags rather than outside, where they belong. Should be:
>>>
>>> {{=login_form.custom.begin}} 
>>> 
>>> [snip]
>>> 
>>> {{=login_form.custom.end}}
>>>
>>> Anthony
>>>
>>> On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>>>>
>>>> Hi,
>>>>
>>>> I tried both but none seems to be working. Here's my view code:
>>>>
>>>> 
>>>> 
>>>> {{=login_form.custom.begin}}
>>>> 
>>>> >>> colspan='2'>{{=login_form.custom.widget.email}}
>>>> 
>>>> 
>>>> >>> colspan='2'>{{=login_form.custom.widget.password}}
>>>> 
>>>> 
>>>> >>> class="flipLink">Forgot Password?
>>>> {{=login_form.custom.submit}}
>>>> 
>>>> {{=login_form.custom.end}}
>>>> 
>>>>
>>>> Please suggest.
>>>>
>>>> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>>>>>
>>>>> That should work. Can you show the view code? Also, note you can just 
>>>>> do:
>>>>>
>>>>> login_form['_id'] = 'login'
>>>>>
>>>>> Anthony
>>>>>
>>>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>>>>
>>>>>> I tried customizing the form. I have to set the id of the form 
>>>>>> element to login.
>>>>>> To achieve the above I used the following statement in controller:
>>>>>>
>>>>>> login_form = auth.login()
>>>>>>
>>>>>> # Configure form properties
>>

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
The rendered form is as:


...


It has no attribute id.

On Tuesday, March 13, 2012 12:05:02 AM UTC+5:30, Anthony wrote:
>
> What's not working? When you view the HTML code of the rendered page in 
> the browser, is the id not there, or is it just that some client-side CSS 
> or JS isn't working as expected? If the latter, the problem could be that 
> you have put the form beginning and ending code inside the  
> tags rather than outside, where they belong. Should be:
>
> {{=login_form.custom.begin}} 
> 
> [snip]
> 
> {{=login_form.custom.end}}
>
> Anthony
>
> On Monday, March 12, 2012 2:07:20 PM UTC-4, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I tried both but none seems to be working. Here's my view code:
>>
>> 
>> 
>> {{=login_form.custom.begin}}
>> 
>> > colspan='2'>{{=login_form.custom.widget.email}}
>> 
>> 
>> > colspan='2'>{{=login_form.custom.widget.password}}
>> 
>> 
>> > class="flipLink">Forgot Password?
>> {{=login_form.custom.submit}}
>> 
>> {{=login_form.custom.end}}
>> 
>>
>> Please suggest.
>>
>> On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>>>
>>> That should work. Can you show the view code? Also, note you can just do:
>>>
>>> login_form['_id'] = 'login'
>>>
>>> Anthony
>>>
>>> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>>>
>>>> I tried customizing the form. I have to set the id of the form element 
>>>> to login.
>>>> To achieve the above I used the following statement in controller:
>>>>
>>>> login_form = auth.login()
>>>>
>>>> # Configure form properties
>>>> login_form.attributes['_id']='login'
>>>>
>>>> But it's not working. The generated form does not contain any id 
>>>> attribute.
>>>> Is there another way to do it ?
>>>>
>>>> Thanks,
>>>> Sushant
>>>>
>>>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>>>
>>>>> Thanks for an explanatory answer.
>>>>> I will try this out.
>>>>>
>>>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>>>>
>>>>>> def index():
>>>>>>>
>>>>>>> login_form = auth.login()
>>>>>>> if login_form.process(session=None,formname='login').accepted:
>>>>>>> pass
>>>>>>> elif login_form.errors:
>>>>>>> response.write(request.vars)
>>>>>>> return dict()
>>>>>>>
>>>>>>> to display the form I have used the SQLForm in HTML technique as 
>>>>>>> mentioned in the web2py book
>>>>>>>
>>>>>>> Whenever user enters the correct email and password. auth_event 
>>>>>>> registers a login event with the description *User 1 Logged In*.
>>>>>>> The next property redirects the URL to /user/profile but auth.user 
>>>>>>> object is *None.*
>>>>>>>
>>>>>>
>>>>>> auth.login() handles it's own form processing, and it uses the 
>>>>>> session when calling form.accepts (which adds a hidden _formkey field to 
>>>>>> the form, which must be present upon form submission). In your code, you 
>>>>>> do 
>>>>>> not return the form object to the view, which means your view cannot 
>>>>>> include the hidden _formkey field, which is therefore not submitted with 
>>>>>> the form. So, when the form is submitted, the form.accepts in 
>>>>>> auth.login() 
>>>>>> fails, which means the user object is never stored in session.auth.user 
>>>>>> -- 
>>>>>> hence, auth.user is None. The reason the login submission is successful 
>>>>>> is 
>>>>>> that your index() function then does its own processing of the login 
>>>>&

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

I tried both but none seems to be working. Here's my view code:



{{=login_form.custom.begin}}

{{=login_form.custom.widget.email}}


{{=login_form.custom.widget.password}}


Forgot Password?
{{=login_form.custom.submit}}

{{=login_form.custom.end}}


Please suggest.

On Monday, March 12, 2012 11:32:04 PM UTC+5:30, Anthony wrote:
>
> That should work. Can you show the view code? Also, note you can just do:
>
> login_form['_id'] = 'login'
>
> Anthony
>
> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>
>> I tried customizing the form. I have to set the id of the form element to 
>> login.
>> To achieve the above I used the following statement in controller:
>>
>> login_form = auth.login()
>>
>> # Configure form properties
>> login_form.attributes['_id']='login'
>>
>> But it's not working. The generated form does not contain any id 
>> attribute.
>> Is there another way to do it ?
>>
>> Thanks,
>> Sushant
>>
>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>
>>> Thanks for an explanatory answer.
>>> I will try this out.
>>>
>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>>>
>>>> def index():
>>>>>
>>>>> login_form = auth.login()
>>>>> if login_form.process(session=None,formname='login').accepted:
>>>>> pass
>>>>> elif login_form.errors:
>>>>> response.write(request.vars)
>>>>> return dict()
>>>>>
>>>>> to display the form I have used the SQLForm in HTML technique as 
>>>>> mentioned in the web2py book
>>>>>
>>>>> Whenever user enters the correct email and password. auth_event 
>>>>> registers a login event with the description *User 1 Logged In*.
>>>>> The next property redirects the URL to /user/profile but auth.user 
>>>>> object is *None.*
>>>>>
>>>>
>>>> auth.login() handles it's own form processing, and it uses the session 
>>>> when calling form.accepts (which adds a hidden _formkey field to the form, 
>>>> which must be present upon form submission). In your code, you do not 
>>>> return the form object to the view, which means your view cannot include 
>>>> the hidden _formkey field, which is therefore not submitted with the form. 
>>>> So, when the form is submitted, the form.accepts in auth.login() fails, 
>>>> which means the user object is never stored in session.auth.user -- hence, 
>>>> auth.user is None. The reason the login submission is successful is that 
>>>> your index() function then does its own processing of the login form, 
>>>> which 
>>>> is successful -- but your explicit call to login_form.process() does not 
>>>> do 
>>>> anything to set auth.user, so it is never set.
>>>>
>>>> In short, you should not be doing your own processing of the login form 
>>>> -- let auth.login() handle that. And if you want to customize the form 
>>>> display in the view, you still have to return the form to the view so you 
>>>> can include the hidden _formkey and _formname fields in the form (you can 
>>>> use form.custom.end to do that).
>>>>
>>>> Anthony
>>>>
>>>
> On Monday, March 12, 2012 1:19:45 PM UTC-4, Sushant Taneja wrote:
>>
>> I tried customizing the form. I have to set the id of the form element to 
>> login.
>> To achieve the above I used the following statement in controller:
>>
>> login_form = auth.login()
>>
>> # Configure form properties
>> login_form.attributes['_id']='login'
>>
>> But it's not working. The generated form does not contain any id 
>> attribute.
>> Is there another way to do it ?
>>
>> Thanks,
>> Sushant
>>
>> On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>>>
>>> Thanks for an explanatory answer.
>>> I will try this out.
>>>
>>> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>&

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
I tried customizing the form. I have to set the id of the form element to 
login.
To achieve the above I used the following statement in controller:

login_form = auth.login()

# Configure form properties
login_form.attributes['_id']='login'

But it's not working. The generated form does not contain any id attribute.
Is there another way to do it ?

Thanks,
Sushant

On Monday, March 12, 2012 8:01:33 PM UTC+5:30, Sushant Taneja wrote:
>
> Thanks for an explanatory answer.
> I will try this out.
>
> On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>>
>> def index():
>>>
>>> login_form = auth.login()
>>> if login_form.process(session=None,formname='login').accepted:
>>> pass
>>> elif login_form.errors:
>>> response.write(request.vars)
>>> return dict()
>>>
>>> to display the form I have used the SQLForm in HTML technique as 
>>> mentioned in the web2py book
>>>
>>> Whenever user enters the correct email and password. auth_event 
>>> registers a login event with the description *User 1 Logged In*.
>>> The next property redirects the URL to /user/profile but auth.user 
>>> object is *None.*
>>>
>>
>> auth.login() handles it's own form processing, and it uses the session 
>> when calling form.accepts (which adds a hidden _formkey field to the form, 
>> which must be present upon form submission). In your code, you do not 
>> return the form object to the view, which means your view cannot include 
>> the hidden _formkey field, which is therefore not submitted with the form. 
>> So, when the form is submitted, the form.accepts in auth.login() fails, 
>> which means the user object is never stored in session.auth.user -- hence, 
>> auth.user is None. The reason the login submission is successful is that 
>> your index() function then does its own processing of the login form, which 
>> is successful -- but your explicit call to login_form.process() does not do 
>> anything to set auth.user, so it is never set.
>>
>> In short, you should not be doing your own processing of the login form 
>> -- let auth.login() handle that. And if you want to customize the form 
>> display in the view, you still have to return the form to the view so you 
>> can include the hidden _formkey and _formname fields in the form (you can 
>> use form.custom.end to do that).
>>
>> Anthony
>>
>

[web2py] Re: Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Thanks for an explanatory answer.
I will try this out.

On Monday, March 12, 2012 7:49:28 PM UTC+5:30, Anthony wrote:
>
> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to display the form I have used the SQLForm in HTML technique as 
>> mentioned in the web2py book
>>
>> Whenever user enters the correct email and password. auth_event registers 
>> a login event with the description *User 1 Logged In*.
>> The next property redirects the URL to /user/profile but auth.user object 
>> is *None.*
>>
>
> auth.login() handles it's own form processing, and it uses the session 
> when calling form.accepts (which adds a hidden _formkey field to the form, 
> which must be present upon form submission). In your code, you do not 
> return the form object to the view, which means your view cannot include 
> the hidden _formkey field, which is therefore not submitted with the form. 
> So, when the form is submitted, the form.accepts in auth.login() fails, 
> which means the user object is never stored in session.auth.user -- hence, 
> auth.user is None. The reason the login submission is successful is that 
> your index() function then does its own processing of the login form, which 
> is successful -- but your explicit call to login_form.process() does not do 
> anything to set auth.user, so it is never set.
>
> In short, you should not be doing your own processing of the login form -- 
> let auth.login() handle that. And if you want to customize the form display 
> in the view, you still have to return the form to the view so you can 
> include the hidden _formkey and _formname fields in the form (you can use 
> form.custom.end to do that).
>
> Anthony
>


Re: [web2py] Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

I passed the session=None since I was following example in the book.
I removed it from the process method and now I am using 

   login_form = auth.login()
if login_form.process(formname='login').accepted:
pass
elif login_form.errors:
response.write(request.vars)
return dict()

but now when I try to login, nothing happens. No event is recorded in 
auth_event and there is also no redirection.

On Monday, March 12, 2012 7:20:01 PM UTC+5:30, rochacbruno wrote:
>
> Why are you passing session=None to .process ?
>
> http://zerp.ly/rochacbruno
> Em 12/03/2012 09:43, "Sushant Taneja"  
> escreveu:
>
>> Hi,
>>
>> Following is the snippet from my db.py global file:
>>
>> db = DAL('google:datastore')
>>
>> from gluon.tools import Auth
>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>
>> auth.settings.login_url = URL('default','index')
>> auth.settings.logged_url = URL('user','profile')
>> auth.settings.login_next = URL('user','profile')
>>
>> auth.define_tables()
>>
>>
>> In my controller default/index controller I have used the following:
>>
>> def index():
>>
>> login_form = auth.login()
>> if login_form.process(session=None,formname='login').accepted:
>> pass
>> elif login_form.errors:
>> response.write(request.vars)
>> return dict()
>>
>> to display the form I have used the SQLForm in HTML technique as 
>> mentioned in the web2py book
>>
>> Whenever user enters the correct email and password. auth_event registers 
>> a login event with the description *User 1 Logged In*.
>> The next property redirects the URL to /user/profile but auth.user object 
>> is *None.*
>> *
>> *
>> Is there some auth setting that I am missing or something else is the 
>> reason of this ?
>>
>> Thanks,
>> Sushant
>>
>>
>>

[web2py] Auth.user is still NULL after a successful login

2012-03-12 Thread Sushant Taneja
Hi,

Following is the snippet from my db.py global file:

db = DAL('google:datastore')

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())

auth.settings.login_url = URL('default','index')
auth.settings.logged_url = URL('user','profile')
auth.settings.login_next = URL('user','profile')

auth.define_tables()


In my controller default/index controller I have used the following:

def index():

login_form = auth.login()
if login_form.process(session=None,formname='login').accepted:
pass
elif login_form.errors:
response.write(request.vars)
return dict()

to display the form I have used the SQLForm in HTML technique as mentioned 
in the web2py book

Whenever user enters the correct email and password. auth_event registers a 
login event with the description *User 1 Logged In*.
The next property redirects the URL to /user/profile but auth.user object 
is *None.*
*
*
Is there some auth setting that I am missing or something else is the 
reason of this ?

Thanks,
Sushant




[web2py] Re: Key Error: auth_user on GAE

2012-03-09 Thread Sushant Taneja
Please ignore the above.
Found the error. I had a conditional model file for the controller which 
was shadowing the global db variable.
Removed it, now everything is working fine.

On Friday, March 9, 2012 9:31:40 PM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> I have extended the default auth_user table in my model file db.py as 
> follows:
>
> db = DAL('google:datastore')
>
> from gluon.tools import Auth
> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>
> auth.settings.extra_fields['auth_user'] = [
> Field('first_name','string',required=True, notnull=True),
> Field('last_name','string',default=''),
> Field('fb_id','string',length=512,required=True),
> Field('create_ts','datetime'),
> Field('change_ts','datetime')
> ]
>
> auth.define_tables()
>
> Also below this code I have also written an insert for inserting data in 
> the auth_user table as:
>
> def new_user(first_name, last_name, email, passw,fb_id):
> users = db(db.auth_user.email==email).select()
> if users:
> return users[0].id
> else:
> my_crypt = CRYPT(key=auth.settings.hmac_key)
> crypt_pass = my_crypt(passw)[0]
> id_user= db.auth_user.insert(
>first_name=first_name,
>last_name=last_name,
>email = email,
>password = crypt_pass,
>fb_id = fb_id
>)
> return id_user
>
> iduser = new_user('ABCD','EFGH','sushant.tanej...@gmail.com
> ','password','8345935345')
>
> This insert I got from some other post in the group. The insert was 
> successful and auth_user table has been created.
> Although no other auth table was created.
>
> Now in my controller function I check if fb_id of a user already exists in 
> my auth_user table or not 
>
> def get_existing_friends():
> """ This function returns a CSV text of FB_IDs of friends which 
> already exists """
>
> user_fb_id = request.vars.userFBID
> if db(db.auth_user.fb_id==user_fb_id).select():
> return "jQuery('.foundFriends').html('This facebook user is 
> already registered');"
>
> On execution nothing happens and GAE logs the following error message:
>
> Traceback (most recent call last):
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/restricted.py", 
> line 204, in restricted
> exec ccode in environment
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
>  
> line 63, in 
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/globals.py", 
> line 172, in 
> self._caller = lambda f: f()
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
>  
> line 19, in get_existing_friends
> if db(db.auth_user.fb_id==user_fb_id).select():
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", line 
> 5119, in __getattr__
> return self[key]
>   File 
> "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", line 
> 5113, in __getitem__
> return dict.__getitem__(self, str(key))
> KeyError: 'auth_user'
>
> Can somebody help me understand the above ?
>
> Thanks,
> Sushant
>


[web2py] Key Error: auth_user on GAE

2012-03-09 Thread Sushant Taneja
Hi,

I have extended the default auth_user table in my model file db.py as 
follows:

db = DAL('google:datastore')

from gluon.tools import Auth
auth = Auth(db, hmac_key=Auth.get_or_create_key())

auth.settings.extra_fields['auth_user'] = [
Field('first_name','string',required=True, notnull=True),
Field('last_name','string',default=''),
Field('fb_id','string',length=512,required=True),
Field('create_ts','datetime'),
Field('change_ts','datetime')
]

auth.define_tables()

Also below this code I have also written an insert for inserting data in 
the auth_user table as:

def new_user(first_name, last_name, email, passw,fb_id):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
   first_name=first_name,
   last_name=last_name,
   email = email,
   password = crypt_pass,
   fb_id = fb_id
   )
return id_user

iduser = 
new_user('ABCD','EFGH','sushant.tanej...@gmail.com','password','8345935345')

This insert I got from some other post in the group. The insert was 
successful and auth_user table has been created.
Although no other auth table was created.

Now in my controller function I check if fb_id of a user already exists in 
my auth_user table or not 

def get_existing_friends():
""" This function returns a CSV text of FB_IDs of friends which already 
exists """

user_fb_id = request.vars.userFBID
if db(db.auth_user.fb_id==user_fb_id).select():
return "jQuery('.foundFriends').html('This facebook user is already 
registered');"

On execution nothing happens and GAE logs the following error message:

Traceback (most recent call last):
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/restricted.py", 
line 204, in restricted
exec ccode in environment
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
 
line 63, in 
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/globals.py", 
line 172, in 
self._caller = lambda f: f()
  File 
"/home/sushant/Ekayan/src/dev/google_appengine/web2py/applications/devekayan/controllers/registration.py",
 
line 19, in get_existing_friends
if db(db.auth_user.fb_id==user_fb_id).select():
  File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", 
line 5119, in __getattr__
return self[key]
  File "/home/sushant/Ekayan/src/dev/google_appengine/web2py/gluon/dal.py", 
line 5113, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'auth_user'

Can somebody help me understand the above ?

Thanks,
Sushant


[web2py] Re: Obtaining URL to image blob in GAE

2012-03-07 Thread Sushant Taneja
As available in the google documentation, we need a UploadHandler ? How it 
is achieved in the above code ?

On Thursday, March 8, 2012 1:38:04 AM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> Can you explain some of the code like how and in which variable the 
> blob_key is saved after the image successfully uploaded in the blobstore ?  
>
> On Thursday, March 1, 2012 10:53:30 PM UTC+5:30, howesc wrote:
>>
>> my blobstore_image model:
>>
>> db.define_table('blobstore_image',
>>   db.version_info,
>>   Field('blob_key', 'upload', notnull=True, 
>> requires=IS_LENGTH(1048576),
>> represent=lambda image : A('download', _href=URL(
>> r=request, c='gae_blobstore', f='download', 
>> args=[image])),
>> label="Image"),
>>   Field('image_url', length=500),
>>   Field('name', length=128,
>> requires=IS_NOT_IN_DB(db, 'blobstore_image.name')),
>>   Field('type', length=128, requires=IS_IN_SET(['i_classify',
>> 'my_images',
>> 'by_type'],
>>zero=None)),
>>   migrate=True)
>>
>>
>> my upload controller:
>>
>> def upload_image():
>>   """
>>   This is the integration of the GAE blobstore with the image upload 
>> process
>>
>>   @TODO: figure out how to test this.  image upload is going to be kinda
>>difficult to spoof
>>   """
>>   #@TODO: how do we deal with deleting an image?
>>   logging.info(repr(request.post_vars))
>>
>>   fields=['name',
>>   'type',
>>   'blob_key']
>>
>>   form = SQLFORM(db.blobstore_image, fields=fields,
>>  formstyle='divs')
>>   if request.args and request.args[0]:
>> form = SQLFORM(db.blobstore_image, request.args[0], fields=fields,
>>upload=URL(r=request, c='gae_blobstore', f='preview'),
>>  formstyle='divs')
>>
>>   if request.env.web2py_runtime_gae:
>> from google.appengine.ext import blobstore
>> from google.appengine.api.images import get_serving_url
>> import uuid
>> #get the blob_info.  NOTE this MUST be done before any other 
>> operations on
>> # the request vars.  otherwise something modifies them (perhaps the 
>> form
>> # validators) in a way that makes this not work
>> blob_info = None
>> if request.vars.blob_key == '':
>> #it seems that prod blobstore returns empty string instead of 
>> None when
>> #there are no changes to the image
>> request.vars.blob_key = None
>> if request.vars.blob_key != None:
>> blob_info = blobstore.parse_blob_info(request.vars.blob_key)
>> del request.vars['blob_key']
>>
>> upload_url = 
>> blobstore.create_upload_url(URL(r=request,f='upload_image',
>>  args=request.args,
>> 
>>  vars={'redir':URL(r=request,c='dataadmin', f='index')}))
>>
>> form['_action']=upload_url
>> #since we are setting the action after the form was initially created 
>> we
>> # need to reset the form.custom.begin
>> (begin, end) = form._xml()
>> form.custom.begin = XML("<%s %s>" % (form.tag, begin))
>>
>> if form.accepts(request.vars,session, formname="uploadimage"):
>> #@TODO: can this be a post-validation function?
>> #get the record we just inserted/modified
>> row = db(db.blobstore_image.id == form.vars.id).select().first()
>> if request.vars.blob_key__delete == 'on' or \
>> (blob_info and (row and row.blob_key)):
>> #remove from blobstore because of delete or update of image
>> decoded_key = base64.b64decode(row.blob_key.split('.')[0])
>> blobstore.delete(decoded_key)
>> #remove reference in the artwork record
>> row.update_record(blob_key=None)
>> if blob_info:
>> logging.info("add

[web2py] Re: Obtaining URL to image blob in GAE

2012-03-07 Thread Sushant Taneja
Hi,

Can you explain some of the code like how and in which variable the 
blob_key is saved after the image successfully uploaded in the blobstore ?  

On Thursday, March 1, 2012 10:53:30 PM UTC+5:30, howesc wrote:
>
> my blobstore_image model:
>
> db.define_table('blobstore_image',
>   db.version_info,
>   Field('blob_key', 'upload', notnull=True, 
> requires=IS_LENGTH(1048576),
> represent=lambda image : A('download', _href=URL(
> r=request, c='gae_blobstore', f='download', 
> args=[image])),
> label="Image"),
>   Field('image_url', length=500),
>   Field('name', length=128,
> requires=IS_NOT_IN_DB(db, 'blobstore_image.name')),
>   Field('type', length=128, requires=IS_IN_SET(['i_classify',
> 'my_images',
> 'by_type'],
>zero=None)),
>   migrate=True)
>
>
> my upload controller:
>
> def upload_image():
>   """
>   This is the integration of the GAE blobstore with the image upload 
> process
>
>   @TODO: figure out how to test this.  image upload is going to be kinda
>difficult to spoof
>   """
>   #@TODO: how do we deal with deleting an image?
>   logging.info(repr(request.post_vars))
>
>   fields=['name',
>   'type',
>   'blob_key']
>
>   form = SQLFORM(db.blobstore_image, fields=fields,
>  formstyle='divs')
>   if request.args and request.args[0]:
> form = SQLFORM(db.blobstore_image, request.args[0], fields=fields,
>upload=URL(r=request, c='gae_blobstore', f='preview'),
>  formstyle='divs')
>
>   if request.env.web2py_runtime_gae:
> from google.appengine.ext import blobstore
> from google.appengine.api.images import get_serving_url
> import uuid
> #get the blob_info.  NOTE this MUST be done before any other 
> operations on
> # the request vars.  otherwise something modifies them (perhaps the 
> form
> # validators) in a way that makes this not work
> blob_info = None
> if request.vars.blob_key == '':
> #it seems that prod blobstore returns empty string instead of None 
> when
> #there are no changes to the image
> request.vars.blob_key = None
> if request.vars.blob_key != None:
> blob_info = blobstore.parse_blob_info(request.vars.blob_key)
> del request.vars['blob_key']
>
> upload_url = 
> blobstore.create_upload_url(URL(r=request,f='upload_image',
>  args=request.args,
> 
>  vars={'redir':URL(r=request,c='dataadmin', f='index')}))
>
> form['_action']=upload_url
> #since we are setting the action after the form was initially created 
> we
> # need to reset the form.custom.begin
> (begin, end) = form._xml()
> form.custom.begin = XML("<%s %s>" % (form.tag, begin))
>
> if form.accepts(request.vars,session, formname="uploadimage"):
> #@TODO: can this be a post-validation function?
> #get the record we just inserted/modified
> row = db(db.blobstore_image.id == form.vars.id).select().first()
> if request.vars.blob_key__delete == 'on' or \
> (blob_info and (row and row.blob_key)):
> #remove from blobstore because of delete or update of image
> decoded_key = base64.b64decode(row.blob_key.split('.')[0])
> blobstore.delete(decoded_key)
> #remove reference in the artwork record
> row.update_record(blob_key=None)
> if blob_info:
> logging.info("adding blob_key " + str(blob_info.key()))
> #add reference to image in this record
> key = base64.b64encode(str(blob_info.key())) +"." + 
> blob_info.content_type.split('/')[1]
> url = get_serving_url(str(blob_info.key()))
> 
> row.update_record(blob_key = key, image_url = url)
>
> crud.archive(form)
> session.flash="Image saved"
> #Raise the HTTP exception so that the response content stays empty.
> #calling redirect puts content in the body which fails the blob 
> upload
> raise HTTP(303,
>Location= URL(r=request,f='upload_image', args=
> form.vars.id))
> elif form.errors:
> #logging.info("form not accepted")
> logging.info(form.errors)
> session.flash=BEAUTIFY(form.errors)
> #there was an error, let's delete the newly uploaded image
> if blob_info:
> blobstore.delete(blob_info.key())
> #Raise the HTTP exception so that the response content stays empty.
> #calling redirect puts content in the body which fails the blob 
> upload
> redirvars = {}
> redirvars['form_errors']=True
> red

Re: [web2py] Update query failing on GAE

2012-03-07 Thread Sushant Taneja
The update() returns 0. I am now taking care of it.
But I still don't see any error logs corresponding to the updates etc. 

May be the reason is eventual consistency.

Thanks for the help

On Wednesday, March 7, 2012 10:16:32 AM UTC+5:30, Sushant Taneja wrote:
>
> As per my understanding, update statement returns the number of records 
> updated. 
> What does it return when no records are updated 0 or None ?
> Will have to modify my code accordingly
>
> On Wednesday, March 7, 2012 9:33:48 AM UTC+5:30, howesc wrote:
>>
>> you probably need to add some more logging to see what is happening.  
>> perhaps the row is not found?  (remember eventual consistency), perhaps 
>> there is some other error that is currently not being logged
>>
>> On Tuesday, March 6, 2012 7:18:36 AM UTC-8, Sushant Taneja wrote:
>>>
>>> Yes I did check GAE logs. 
>>> There are no logs with severity level error.
>>>  
>>> On Tuesday, March 6, 2012 7:46:52 PM UTC+5:30, yamandu wrote:
>>>>
>>>> I dont know, but have you examined the GAE log?
>>>>
>>>> 2012/3/6 Sushant Taneja :
>>>> > Hi,
>>>> >
>>>> > I thought the same but as you can see I have handled the Timeout 
>>>> exception
>>>> > in the code.
>>>> > If its the Timeout then why I am unable to catch the exception ?
>>>> >
>>>> > On Tuesday, March 6, 2012 7:30:38 PM UTC+5:30, yamandu wrote:
>>>> >>
>>>> >> Looks its a timeout.
>>>> >> Maybe I am wrong but you can state an update too many records. GAE 
>>>> has
>>>> >> time limitations, I dont know how much because I dont use it anymore.
>>>> >> Search for the GAE docs on these limitations.
>>>> >>
>>>> >> 2012/3/6 Sushant Taneja :
>>>> >> > Hi All,
>>>> >> >
>>>> >> > I am building a invite module.
>>>> >> > In the controller, I have the following code :
>>>> >> >
>>>> >> > try:
>>>> >> >  some initial stuff
>>>> >> >
>>>> >> >try:
>>>> >> >
>>>> >> >... some stuff
>>>> >> >
>>>> >> >update_request_query = (db.INVITE_SIGNUP.email_id ==
>>>> >> > request_email_id)
>>>> >> >
>>>> >> >
>>>> >> > 
>>>>  
>>>> db(update_request_query).update(activation_key=key,activation_url=activation_url)
>>>> >> >
>>>> >> > ... some other stuff
>>>> >> >
>>>> >> >except (Timeout,TransactionFailedError,InternalError), derr:
>>>> >> > logger.warn('Datastore exception for ID: '+
>>>> >> > request_email_id +': '+ str(derr))
>>>> >> > except (Error, Exception), ex:
>>>> >> > logger.error('Fatal Error: '+ request_email_id +': '+
>>>> >> > str(ex))
>>>> >> >
>>>> >> > The problem is that the update statement is not working on GAE. The
>>>> >> > fields
>>>> >> > which need to be updated are NULL and no error is thrown.
>>>> >> > From my observation, this is happening once a day approx around 
>>>> the time
>>>> >> > when daily quota is reset.
>>>> >> >
>>>> >> > Am I doing something wrong here ?
>>>> >> >
>>>> >> > Thanks,
>>>> >> > Sushant
>>>> >> >
>>>> >> >
>>>> >>
>>>> >> --
>>>> >> Carlos J. Costa
>>>> >> Cientista da Computação
>>>> >> Esp. Gestão em Telecom
>>>> >>
>>>> >> EL MELECH NEEMAN!
>>>> >> אָמֵן
>>>>
>>>> -- 
>>>> Carlos J. Costa
>>>> Cientista da Computação
>>>> Esp. Gestão em Telecom
>>>>
>>>> EL MELECH NEEMAN!
>>>> אָמֵן
>>>>
>>>>
>> On Tuesday, March 6, 2012 7:18:36 AM UTC-8, Sushant Taneja wrote:
>>>
>>> Yes I did check GAE logs. 
>>> There are no logs with severity level error.
>>

[web2py] Using Blobstore API

2012-03-07 Thread Sushant Taneja
Hi,

I am trying to use the Google Blobstore API for uploading images. I also 
checked the link: http://www.web2pyslices.com/main/slices/take_slice/63 for 
the help but couldn't understand much.

In my application's (uploadPic) default controller I have the code as 
follows:

from google.appengine.ext import blobstore

def index():
"""
This provides the upload_url to the upload form
"""
upload_url=blobstore.create_upload_url(URL('uploadPic','default','pic'))
return dict(upload_url=upload_url)

def pic():
"""
This method stores the bolb key in a table and is used for serving the 
BLOB images
"""
response.write(request)

In the view index.html, I have a simple form










As per my understanding, when the upload is successful, GAE automatically 
redirects to the URL provided in the create_upload_url function with the 
request containing the blob_key.

But when I execute the above, all I get in the page is None. The log is 
showing the following:

INFO 2012-03-07 09:30:31,188 dev_appserver.py:2865] "GET 
/uploadPic/default/index HTTP/1.1" 200 -
INFO 2012-03-07 09:30:37,558 dev_appserver.py:687] Internal redirection 
to /uploadPic/default/pic
INFO 2012-03-07 09:30:37,681 gaehandler.py:69]  Request: 
104.29ms/100.00ms (real time/cpu time)
INFO 2012-03-07 09:30:37,686 recording.py:372] Saved; key: 
__appstats__:037500, part: 20 bytes, full: 1234 bytes, overhead: 0.000 + 
0.004; link: http://localhost:8080/_ah/stats/details?time=1331112637576
INFO 2012-03-07 09:30:37,695 dev_appserver_blobstore.py:447] Upload 
handler returned 200
INFO 2012-03-07 09:30:37,723 dev_appserver.py:2865] "POST 
/_ah/upload/ag9kZXZ-aW1hZ2V1cGxvYWRyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxggDA 
HTTP/1.1" 200 -

Can someone please help me understand it ? 

Thanks,
Sushant




Re: [web2py] Update query failing on GAE

2012-03-06 Thread Sushant Taneja
As per my understanding, update statement returns the number of records 
updated. 
What does it return when no records are updated 0 or None ?
Will have to modify my code accordingly

On Wednesday, March 7, 2012 9:33:48 AM UTC+5:30, howesc wrote:
>
> you probably need to add some more logging to see what is happening.  
> perhaps the row is not found?  (remember eventual consistency), perhaps 
> there is some other error that is currently not being logged
>
> On Tuesday, March 6, 2012 7:18:36 AM UTC-8, Sushant Taneja wrote:
>>
>> Yes I did check GAE logs. 
>> There are no logs with severity level error.
>>  
>> On Tuesday, March 6, 2012 7:46:52 PM UTC+5:30, yamandu wrote:
>>>
>>> I dont know, but have you examined the GAE log?
>>>
>>> 2012/3/6 Sushant Taneja :
>>> > Hi,
>>> >
>>> > I thought the same but as you can see I have handled the Timeout 
>>> exception
>>> > in the code.
>>> > If its the Timeout then why I am unable to catch the exception ?
>>> >
>>> > On Tuesday, March 6, 2012 7:30:38 PM UTC+5:30, yamandu wrote:
>>> >>
>>> >> Looks its a timeout.
>>> >> Maybe I am wrong but you can state an update too many records. GAE has
>>> >> time limitations, I dont know how much because I dont use it anymore.
>>> >> Search for the GAE docs on these limitations.
>>> >>
>>> >> 2012/3/6 Sushant Taneja :
>>> >> > Hi All,
>>> >> >
>>> >> > I am building a invite module.
>>> >> > In the controller, I have the following code :
>>> >> >
>>> >> > try:
>>> >> >  some initial stuff
>>> >> >
>>> >> >try:
>>> >> >
>>> >> >... some stuff
>>> >> >
>>> >> >update_request_query = (db.INVITE_SIGNUP.email_id ==
>>> >> > request_email_id)
>>> >> >
>>> >> >
>>> >> > 
>>>  
>>> db(update_request_query).update(activation_key=key,activation_url=activation_url)
>>> >> >
>>> >> > ... some other stuff
>>> >> >
>>> >> >except (Timeout,TransactionFailedError,InternalError), derr:
>>> >> > logger.warn('Datastore exception for ID: '+
>>> >> > request_email_id +': '+ str(derr))
>>> >> > except (Error, Exception), ex:
>>> >> > logger.error('Fatal Error: '+ request_email_id +': '+
>>> >> > str(ex))
>>> >> >
>>> >> > The problem is that the update statement is not working on GAE. The
>>> >> > fields
>>> >> > which need to be updated are NULL and no error is thrown.
>>> >> > From my observation, this is happening once a day approx around the 
>>> time
>>> >> > when daily quota is reset.
>>> >> >
>>> >> > Am I doing something wrong here ?
>>> >> >
>>> >> > Thanks,
>>> >> > Sushant
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> Carlos J. Costa
>>> >> Cientista da Computação
>>> >> Esp. Gestão em Telecom
>>> >>
>>> >> EL MELECH NEEMAN!
>>> >> אָמֵן
>>>
>>> -- 
>>> Carlos J. Costa
>>> Cientista da Computação
>>> Esp. Gestão em Telecom
>>>
>>> EL MELECH NEEMAN!
>>> אָמֵן
>>>
>>>
> On Tuesday, March 6, 2012 7:18:36 AM UTC-8, Sushant Taneja wrote:
>>
>> Yes I did check GAE logs. 
>> There are no logs with severity level error.
>>  
>> On Tuesday, March 6, 2012 7:46:52 PM UTC+5:30, yamandu wrote:
>>>
>>> I dont know, but have you examined the GAE log?
>>>
>>> 2012/3/6 Sushant Taneja :
>>> > Hi,
>>> >
>>> > I thought the same but as you can see I have handled the Timeout 
>>> exception
>>> > in the code.
>>> > If its the Timeout then why I am unable to catch the exception ?
>>> >
>>> > On Tuesday, March 6, 2012 7:30:38 PM UTC+5:30, yamandu wrote:
>>> >>
>>> >> Looks its a timeout.
>>> >> Maybe I am wrong but you can state an update too many reco

Re: [web2py] Update query failing on GAE

2012-03-06 Thread Sushant Taneja
Yes I did check GAE logs. 
There are no logs with severity level error.
 
On Tuesday, March 6, 2012 7:46:52 PM UTC+5:30, yamandu wrote:
>
> I dont know, but have you examined the GAE log?
>
> 2012/3/6 Sushant Taneja :
> > Hi,
> >
> > I thought the same but as you can see I have handled the Timeout 
> exception
> > in the code.
> > If its the Timeout then why I am unable to catch the exception ?
> >
> > On Tuesday, March 6, 2012 7:30:38 PM UTC+5:30, yamandu wrote:
> >>
> >> Looks its a timeout.
> >> Maybe I am wrong but you can state an update too many records. GAE has
> >> time limitations, I dont know how much because I dont use it anymore.
> >> Search for the GAE docs on these limitations.
> >>
> >> 2012/3/6 Sushant Taneja :
> >> > Hi All,
> >> >
> >> > I am building a invite module.
> >> > In the controller, I have the following code :
> >> >
> >> > try:
> >> >  some initial stuff
> >> >
> >> >try:
> >> >
> >> >... some stuff
> >> >
> >> >update_request_query = (db.INVITE_SIGNUP.email_id ==
> >> > request_email_id)
> >> >
> >> >
> >> > 
>  
> db(update_request_query).update(activation_key=key,activation_url=activation_url)
> >> >
> >> > ... some other stuff
> >> >
> >> >except (Timeout,TransactionFailedError,InternalError), derr:
> >> > logger.warn('Datastore exception for ID: '+
> >> > request_email_id +': '+ str(derr))
> >> > except (Error, Exception), ex:
> >> > logger.error('Fatal Error: '+ request_email_id +': '+
> >> > str(ex))
> >> >
> >> > The problem is that the update statement is not working on GAE. The
> >> > fields
> >> > which need to be updated are NULL and no error is thrown.
> >> > From my observation, this is happening once a day approx around the 
> time
> >> > when daily quota is reset.
> >> >
> >> > Am I doing something wrong here ?
> >> >
> >> > Thanks,
> >> > Sushant
> >> >
> >> >
> >>
> >> --
> >> Carlos J. Costa
> >> Cientista da Computação
> >> Esp. Gestão em Telecom
> >>
> >> EL MELECH NEEMAN!
> >> אָמֵן
>
> -- 
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>
>

Re: [web2py] Update query failing on GAE

2012-03-06 Thread Sushant Taneja
Hi,

I thought the same but as you can see I have handled the Timeout exception 
in the code. 
If its the Timeout then why I am unable to catch the exception ?

On Tuesday, March 6, 2012 7:30:38 PM UTC+5:30, yamandu wrote:
>
> Looks its a timeout.
> Maybe I am wrong but you can state an update too many records. GAE has
> time limitations, I dont know how much because I dont use it anymore.
> Search for the GAE docs on these limitations.
>
> 2012/3/6 Sushant Taneja :
> > Hi All,
> >
> > I am building a invite module.
> > In the controller, I have the following code :
> >
> > try:
> >  some initial stuff
> >
> >try:
> >
> >... some stuff
> >
> >update_request_query = (db.INVITE_SIGNUP.email_id ==
> > request_email_id)
> >
> > 
>  
> db(update_request_query).update(activation_key=key,activation_url=activation_url)
> >
> > ... some other stuff
> >
> >except (Timeout,TransactionFailedError,InternalError), derr:
> > logger.warn('Datastore exception for ID: '+
> > request_email_id +': '+ str(derr))
> > except (Error, Exception), ex:
> > logger.error('Fatal Error: '+ request_email_id +': '+ 
> str(ex))
> >
> > The problem is that the update statement is not working on GAE. The 
> fields
> > which need to be updated are NULL and no error is thrown.
> > From my observation, this is happening once a day approx around the time
> > when daily quota is reset.
> >
> > Am I doing something wrong here ?
> >
> > Thanks,
> > Sushant
> >
> >
>
> -- 
> Carlos J. Costa
> Cientista da Computação
> Esp. Gestão em Telecom
>
> EL MELECH NEEMAN!
> אָמֵן
>
>

[web2py] Update query failing on GAE

2012-03-06 Thread Sushant Taneja
Hi All,

I am building a invite module.
In the controller, I have the following code :

try: 
 some initial stuff

   try:

   ... some stuff

   update_request_query = (db.INVITE_SIGNUP.email_id == 
request_email_id)
  
 
db(update_request_query).update(activation_key=key,activation_url=activation_url)

... some other stuff

   except (Timeout,TransactionFailedError,InternalError), derr:
logger.warn('Datastore exception for ID: '+ 
request_email_id +': '+ str(derr))
except (Error, Exception), ex:
logger.error('Fatal Error: '+ request_email_id +': '+ str(ex))
  
The problem is that the update statement is not working on GAE. The fields 
which need to be updated are NULL and no error is thrown.
>From my observation, this is happening once a day approx around the time 
when daily quota is reset.

Am I doing something wrong here ?

Thanks,
Sushant




[web2py] Re: Difference between storing session in memcache v/s DB

2012-03-06 Thread Sushant Taneja
Thanks.

On Monday, March 5, 2012 12:24:04 AM UTC+5:30, Massimo Di Pierro wrote:
>
> Sessions with web2py on GAE must go in DB, else they are not reliable (you 
> may find yourself logged out because cache is cleared).
>
> On Saturday, 3 March 2012 23:12:34 UTC-6, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I am creating an application for deployment on GAE.
>> I would like to know the advantages and disadvantages of storing sessions 
>> in memcache v/s google datastore.
>>
>> Thanks,
>> Sushant
>>
>

[web2py] Difference between storing session in memcache v/s DB

2012-03-03 Thread Sushant Taneja
Hi,

I am creating an application for deployment on GAE.
I would like to know the advantages and disadvantages of storing sessions 
in memcache v/s google datastore.

Thanks,
Sushant