Your Ad Here

Monday, January 2, 2012

Re: Creating clean URLS

Yes I am using form to send values..

and here is the view code:-

----------------------------------------------------------------------------------------------------------------------
views.py
----------------------------------------------------------------------------------------------------------------------

# /return Called back by Twitter after the authorization
#this is where the twitter callbacks the application.

from tweety.models import Customer
import twitter

def twitter_after_auth(request):
token = oauth.Token(request.GET['oauth_token'],
request.GET['oauth_verifier'])
_consumer = oauth.Consumer(CONSUMER_KEY, CONSUMER_SECRET)

client = oauth.Client(_consumer, token)

resp, content = client.request(ACCESS_TOKEN_URL, 'POST')
access_token = dict(urlparse.parse_qsl(content))

token = oauth.Token(access_token['oauth_token'],
access_token['oauth_token_secret'])

t_api = twitter.Api(CONSUMER_KEY, CONSUMER_SECRET,
access_token['oauth_token'], access_token['oauth_token_secret'])

#add code here to store token in database.
customer = Customer()

customer.customer_id = access_token['user_id'] #user.id
customer.customer_handle= access_token['screen_name']
customer.token_auth_key = access_token['oauth_token']
customer.token_sec_key = access_token['oauth_token_secret']
customer.company_name = access_token['screen_name']

customer.save()
#this is the url to which i want to direct the user to
return render_to_response('http://brainslane.no-ip.info/
create_cr')

# /create_cr
#this url contains html forms for cr registration
#but it has the url problem i have mentioned
def create_cr(request):
return render_to_response('register_cr.html')

----------------------------------------------------------------------------------------------------------------------


On Jan 2, 5:37 am, Lie Ryan <lie.1...@gmail.com> wrote:
> On 01/02/2012 07:53 AM, lankesh87 wrote:
>
>
>
>
>
>
>
>
>
> > I want my url to be free from parameters being passed.
>
> > I have handled the request in "twitter_after_auth" function of view
> > and
>
> > I am redirecting user to the new url "http://localhost/create_cr/"
>
> > but instead the url shows some additional parameters that I have
> > already handled.
>
> > something like below:-
>
> > "http://localhost/create_cr/?
> > oauth_token=SOME_VALUE&oauth_verifier=SOME_VALUE"
>
> > I just want my url to be of something like below:-
>
> > "http://localhost/create_cr/"
>
> > please help..
>
> What kind of redirect are you issuing (i.e. what is the HTTP status
> code)? Some kinds of redirects will command the browser to pass GET/POST
> parameters to the new URL since those redirect is meant to be issued
> when the request failed to be processed here but can be processed in the
> new URL.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 comments:

Post a Comment