Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Allright, working :)

Thank you all!
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 4:09 PM, Dhruv Adhia  wrote:

> Just ignore past messages. I got successful posting of data from unity to
> django localhost server. Now I am creating POST request from unity thats why
> I am doing request.POST if condition.
>
> I could see that through print statements inside this code
>
>  if request.POST:
>name = request.POST['name']
>print name
>score = request.POST['score']
>print score
>hash = request.POST['hash']
>print hash
>
> before there was no output. So now I am sure that I am getting values.
>
> Can anybody help in storing name and score into database?
>
> i have models setup as follows.
>
> from django.db import models
> # Create your models here.
>
> class Scores(models.Model):
> name = models.CharField(max_length=100)
> score = models.IntegerField()
>
> class Meta:
> verbose_name_plural ="Scores"
>
> Thanks a ton!
>
> Dhruv Adhia
> http://thirdimension.com
>
>
>
> On Thu, Oct 22, 2009 at 2:54 PM, Dhruv Adhia  wrote:
>
>> here is the version I thought should have worked, but its not quite there
>>
>> def add_score(request):
>>#response_dict ={}
>>secret_key = "asdf789as7df89asdf87ds89a8f7sfd8"
>> name =""
>> score=0
>> hash=""
>>
>> # getting the posted data
>>if request.GET:
>>name = request.POST['name']
>>print name
>>score = request.POST['score']
>>print score
>>hash = request.POST['hash']
>>print hash
>>#leaderboard = {'name': name, 'score': score, 'hash': hash}
>>
>>  #hashlib stuff for encryption
>>m = hashlib.md5()
>>m.update(name+str(score)+secret_key)
>>real_hash = m.hexdigest()
>>
>>   #storing it into database
>>if real_hash == hash:
>># store the name and score into the database
>>leaderboard = Scores(name = request.POST['name'] ,score =
>> request.POST['score'])
>>leaderboard.save
>>
>>leaderboard = Scores.objects.all()
>>return render_to_response('add_score.html', {'leaderboard':
>> leaderboard})
>>
>>
>> This version does not do what i wanted it do. which is 1) Read the posted
>> data 2) Store it into database
>>
>> Any help would be appreciated.
>>
>> Thanks
>>
>> Dhruv Adhia
>> http://thirdimension.com
>>
>>
>>
>> On Thu, Oct 22, 2009 at 1:05 PM, Dhruv Adhia  wrote:
>>
>>> Allright, I get that part.
>>>
>>> the url is coming from unity
>>>
>>> javascript part inside unity
>>>
>>> the part in bold is doing the post data.
>>>
>>> private var secretKey="mySecretKey";
>>> function postScore(name, score) {
>>> //This connects to a server side php script that will add the name
>>> and score to a MySQL DB.
>>> // Supply it with a string representing the players name and the
>>> players score.
>>> var hash=Md5.Md5Sum(name +""+ score + ""+ secretKey);
>>>
>>> *var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) +
>>> "&score=" + score + "&hash=" + hash;
>>>
>>> // Post the URL to the site and create a download object to get the
>>> result.
>>> hs_post = WWW(highscore_url);*
>>> yield hs_post; // Wait until the download is done
>>> if(hs_post.error) {
>>> print("There was an error posting the high score: " +
>>> hs_post.error);
>>> }
>>> }
>>>
>>>
>>> >>
>>> $db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password'
>>> ) or die ('Could not
>>> connect: ' . mysql_error());
>>> mysql_select_db('my_database') or 
>>> die
>>> ('Could not select database');
>>>
>>> // Strings must be escaped to prevent SQL injection attack.
>>> $name = mysql_real_escape_string($_GET['name'], $db);
>>> $score = mysql_real_escape_string($_GET['score'], $db);
>>> $hash = $_GET['hash'];
>>>
>>> $secretKey="mySecretKey"; # Change this value to match the value
>>> stored in the client javascript below
>>>
>>> $real_hash = md5($name . $score . $secretKey);
>>> if($real_hash == $hash) {
>>> // Send variables for the MySQL database class.
>>> $query = "insert into scores values (NULL, '$name',
>>> '$score');";
>>> $result = mysql_query($query) or 
>>> die
>>> ('Query failed: ' . mysql_error());
>>> }
>>>  ?>
>>>
>>> This is the php side of things that I found online. Basically I am trying
>>> to convert that to python code as you can see.
>>>
>>> I wrote the getting part of the data and the rest is what I am working on
>>> right now.
>>>
>>> It would be nice,
>>>
>>> if I could read values sent by unity(which is fine) and store them into
>>> database rather than just displaying.
>>>
>>> Thanks Karen.
>>>
>>> Dhruv Adhia
>>> http://thirdimension.com
>>>
>>>
>>>
>>> On Thu, Oct 22, 2009 at 12:46 PM, Ka

Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Just ignore past messages. I got successful posting of data from unity to
django localhost server. Now I am creating POST request from unity thats why
I am doing request.POST if condition.

I could see that through print statements inside this code

 if request.POST:
   name = request.POST['name']
   print name
   score = request.POST['score']
   print score
   hash = request.POST['hash']
   print hash

before there was no output. So now I am sure that I am getting values.

Can anybody help in storing name and score into database?

i have models setup as follows.

from django.db import models
# Create your models here.

class Scores(models.Model):
name = models.CharField(max_length=100)
score = models.IntegerField()

class Meta:
verbose_name_plural ="Scores"

Thanks a ton!

Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 2:54 PM, Dhruv Adhia  wrote:

> here is the version I thought should have worked, but its not quite there
>
> def add_score(request):
>#response_dict ={}
>secret_key = "asdf789as7df89asdf87ds89a8f7sfd8"
> name =""
> score=0
> hash=""
>
> # getting the posted data
>if request.GET:
>name = request.POST['name']
>print name
>score = request.POST['score']
>print score
>hash = request.POST['hash']
>print hash
>#leaderboard = {'name': name, 'score': score, 'hash': hash}
>
>  #hashlib stuff for encryption
>m = hashlib.md5()
>m.update(name+str(score)+secret_key)
>real_hash = m.hexdigest()
>
>   #storing it into database
>if real_hash == hash:
># store the name and score into the database
>leaderboard = Scores(name = request.POST['name'] ,score =
> request.POST['score'])
>leaderboard.save
>
>leaderboard = Scores.objects.all()
>return render_to_response('add_score.html', {'leaderboard':
> leaderboard})
>
>
> This version does not do what i wanted it do. which is 1) Read the posted
> data 2) Store it into database
>
> Any help would be appreciated.
>
> Thanks
>
> Dhruv Adhia
> http://thirdimension.com
>
>
>
> On Thu, Oct 22, 2009 at 1:05 PM, Dhruv Adhia  wrote:
>
>> Allright, I get that part.
>>
>> the url is coming from unity
>>
>> javascript part inside unity
>>
>> the part in bold is doing the post data.
>>
>> private var secretKey="mySecretKey";
>> function postScore(name, score) {
>> //This connects to a server side php script that will add the name and
>> score to a MySQL DB.
>> // Supply it with a string representing the players name and the
>> players score.
>> var hash=Md5.Md5Sum(name +""+ score + ""+ secretKey);
>>
>> *var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) +
>> "&score=" + score + "&hash=" + hash;
>>
>> // Post the URL to the site and create a download object to get the
>> result.
>> hs_post = WWW(highscore_url);*
>> yield hs_post; // Wait until the download is done
>> if(hs_post.error) {
>> print("There was an error posting the high score: " +
>> hs_post.error);
>> }
>> }
>>
>>
>> >
>> $db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
>> or die ('Could not
>> connect: ' . mysql_error());
>> mysql_select_db('my_database') or 
>> die
>> ('Could not select database');
>>
>> // Strings must be escaped to prevent SQL injection attack.
>> $name = mysql_real_escape_string($_GET['name'], $db);
>> $score = mysql_real_escape_string($_GET['score'], $db);
>> $hash = $_GET['hash'];
>>
>> $secretKey="mySecretKey"; # Change this value to match the value
>> stored in the client javascript below
>>
>> $real_hash = md5($name . $score . $secretKey);
>> if($real_hash == $hash) {
>> // Send variables for the MySQL database class.
>> $query = "insert into scores values (NULL, '$name',
>> '$score');";
>> $result = mysql_query($query) or 
>> die
>> ('Query failed: ' . mysql_error());
>> }
>>  ?>
>>
>> This is the php side of things that I found online. Basically I am trying
>> to convert that to python code as you can see.
>>
>> I wrote the getting part of the data and the rest is what I am working on
>> right now.
>>
>> It would be nice,
>>
>> if I could read values sent by unity(which is fine) and store them into
>> database rather than just displaying.
>>
>> Thanks Karen.
>>
>> Dhruv Adhia
>> http://thirdimension.com
>>
>>
>>
>> On Thu, Oct 22, 2009 at 12:46 PM, Karen Tracey wrote:
>>
>>> On Thu, Oct 22, 2009 at 3:25 PM, Dhruv Adhia  wrote:
>>>
 Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
 explained it
 http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log

 so for '?' then should my url pattern for add_Score l

Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
here is the version I thought should have worked, but its not quite there

def add_score(request):
   #response_dict ={}
   secret_key = "asdf789as7df89asdf87ds89a8f7sfd8"
name =""
score=0
hash=""

# getting the posted data
   if request.GET:
   name = request.POST['name']
   print name
   score = request.POST['score']
   print score
   hash = request.POST['hash']
   print hash
   #leaderboard = {'name': name, 'score': score, 'hash': hash}

 #hashlib stuff for encryption
   m = hashlib.md5()
   m.update(name+str(score)+secret_key)
   real_hash = m.hexdigest()

  #storing it into database
   if real_hash == hash:
   # store the name and score into the database
   leaderboard = Scores(name = request.POST['name'] ,score =
request.POST['score'])
   leaderboard.save

   leaderboard = Scores.objects.all()
   return render_to_response('add_score.html', {'leaderboard': leaderboard})


This version does not do what i wanted it do. which is 1) Read the posted
data 2) Store it into database

Any help would be appreciated.

Thanks

Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 1:05 PM, Dhruv Adhia  wrote:

> Allright, I get that part.
>
> the url is coming from unity
>
> javascript part inside unity
>
> the part in bold is doing the post data.
>
> private var secretKey="mySecretKey";
> function postScore(name, score) {
> //This connects to a server side php script that will add the name and
> score to a MySQL DB.
> // Supply it with a string representing the players name and the
> players score.
> var hash=Md5.Md5Sum(name +""+ score + ""+ secretKey);
>
> *var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) +
> "&score=" + score + "&hash=" + hash;
>
> // Post the URL to the site and create a download object to get the
> result.
> hs_post = WWW(highscore_url);*
> yield hs_post; // Wait until the download is done
> if(hs_post.error) {
> print("There was an error posting the high score: " +
> hs_post.error);
> }
> }
>
>
> 
> $db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
> or die ('Could not
> connect: ' . mysql_error());
> mysql_select_db('my_database') or 
> die
> ('Could not select database');
>
> // Strings must be escaped to prevent SQL injection attack.
> $name = mysql_real_escape_string($_GET['name'], $db);
> $score = mysql_real_escape_string($_GET['score'], $db);
> $hash = $_GET['hash'];
>
> $secretKey="mySecretKey"; # Change this value to match the value
> stored in the client javascript below
>
> $real_hash = md5($name . $score . $secretKey);
> if($real_hash == $hash) {
> // Send variables for the MySQL database class.
> $query = "insert into scores values (NULL, '$name',
> '$score');";
> $result = mysql_query($query) or 
> die
> ('Query failed: ' . mysql_error());
> }
>  ?>
>
> This is the php side of things that I found online. Basically I am trying
> to convert that to python code as you can see.
>
> I wrote the getting part of the data and the rest is what I am working on
> right now.
>
> It would be nice,
>
> if I could read values sent by unity(which is fine) and store them into
> database rather than just displaying.
>
> Thanks Karen.
>
> Dhruv Adhia
> http://thirdimension.com
>
>
>
> On Thu, Oct 22, 2009 at 12:46 PM, Karen Tracey  wrote:
>
>> On Thu, Oct 22, 2009 at 3:25 PM, Dhruv Adhia  wrote:
>>
>>> Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
>>> explained it
>>> http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log
>>>
>>> so for '?' then should my url pattern for add_Score look like this
>>>   (r'^add_score/?', 'carbon_chaos.highscore.views.add_score'),
>>>
>>>
>>>
>> No, query strings don't play any part in the url matching.  You might want
>> to add a $ to the end of your existing pattern, to indicate that the inbound
>> URL path must end after the slash after add_score...as it is your requested
>> URL is only matching because that $ is missing from your pattern, allowing
>> any URL path that starts with add_score/ to get routed to your add_score
>> view, even if there is more after the add_score/ element of the URL path.
>>
>> What you need to do to be able to access the query string values from the
>> request.GET dictionary is change whatever is generating that URL to generate
>> it properly, with the ? separating the URL path from the query string.  But
>> near as I can tell you have not said anything about where that URL is coming
>> from, so I don't know what to tell you tot fix.  You need the request coming
>> in to the server to have the ? in its proper place, you do not need the ? in
>> the pattern.
>>
>> Karen
>>
>> >>
>>
>

--~--~

Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Allright, I get that part.

the url is coming from unity

javascript part inside unity

the part in bold is doing the post data.

private var secretKey="mySecretKey";
function postScore(name, score) {
//This connects to a server side php script that will add the name and
score to a MySQL DB.
// Supply it with a string representing the players name and the players
score.
var hash=Md5.Md5Sum(name +""+ score + ""+ secretKey);

*var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) +
"&score=" + score + "&hash=" + hash;

// Post the URL to the site and create a download object to get the
result.
hs_post = WWW(highscore_url);*
yield hs_post; // Wait until the download is done
if(hs_post.error) {
print("There was an error posting the high score: " +
hs_post.error);
}
}


http://www.perldoc.com/perl5.6/pod/func/die.html>('Could not
connect: '. mysql_error
());
mysql_select_db('my_database') or
die
('Could not select database');

// Strings must be escaped to prevent SQL injection attack.
$name = mysql_real_escape_string($_GET['name'], $db);
$score = mysql_real_escape_string($_GET['score'], $db);
$hash = $_GET['hash'];

$secretKey="mySecretKey"; # Change this value to match the value
stored in the client javascript below

$real_hash = md5($name . $score . $secretKey);
if($real_hash == $hash) {
// Send variables for the MySQL database class.
$query = "insert into scores values (NULL, '$name', '$score');";

$result = mysql_query($query) or
die
('Query failed: ' . mysql_error());
}
 ?>

This is the php side of things that I found online. Basically I am trying to
convert that to python code as you can see.

I wrote the getting part of the data and the rest is what I am working on
right now.

It would be nice,

if I could read values sent by unity(which is fine) and store them into
database rather than just displaying.

Thanks Karen.

Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 12:46 PM, Karen Tracey  wrote:

> On Thu, Oct 22, 2009 at 3:25 PM, Dhruv Adhia  wrote:
>
>> Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
>> explained it
>> http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log
>>
>> so for '?' then should my url pattern for add_Score look like this
>>   (r'^add_score/?', 'carbon_chaos.highscore.views.add_score'),
>>
>>
>>
> No, query strings don't play any part in the url matching.  You might want
> to add a $ to the end of your existing pattern, to indicate that the inbound
> URL path must end after the slash after add_score...as it is your requested
> URL is only matching because that $ is missing from your pattern, allowing
> any URL path that starts with add_score/ to get routed to your add_score
> view, even if there is more after the add_score/ element of the URL path.
>
> What you need to do to be able to access the query string values from the
> request.GET dictionary is change whatever is generating that URL to generate
> it properly, with the ? separating the URL path from the query string.  But
> near as I can tell you have not said anything about where that URL is coming
> from, so I don't know what to tell you tot fix.  You need the request coming
> in to the server to have the ? in its proper place, you do not need the ? in
> the pattern.
>
> Karen
>
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Karen Tracey
On Thu, Oct 22, 2009 at 3:25 PM, Dhruv Adhia  wrote:

> Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
> explained it
> http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log
>
> so for '?' then should my url pattern for add_Score look like this
>
>   (r'^add_score/?', 'carbon_chaos.highscore.views.add_score'),
>
>
>
No, query strings don't play any part in the url matching.  You might want
to add a $ to the end of your existing pattern, to indicate that the inbound
URL path must end after the slash after add_score...as it is your requested
URL is only matching because that $ is missing from your pattern, allowing
any URL path that starts with add_score/ to get routed to your add_score
view, even if there is more after the add_score/ element of the URL path.

What you need to do to be able to access the query string values from the
request.GET dictionary is change whatever is generating that URL to generate
it properly, with the ? separating the URL path from the query string.  But
near as I can tell you have not said anything about where that URL is coming
from, so I don't know what to tell you tot fix.  You need the request coming
in to the server to have the ? in its proper place, you do not need the ? in
the pattern.

Karen

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
explained it
http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log

so for '?' then should my url pattern for add_Score look like this
  (r'^add_score/?', 'carbon_chaos.highscore.views.add_score'),


Thanks Karen.
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 12:17 PM, Karen Tracey  wrote:

> On Thu, Oct 22, 2009 at 2:35 PM, Dhruv Adhia  wrote:
>
>> Allright, I see some progress, so now my views looks like this with that
>> little modification
>>
>> def add_score(request):
>>response_dict ={}
>>if request.POST:
>>name = request.POST['name']
>>score = request.POST['score']
>>hash = request.POST['hash']
>>response_dict = {'name': name, 'score': score, 'hash': hash}
>>return render_to_response('add_score.html', response_dict)
>>
>>
>> From unity I am getting scores and names and I am also posting it onto the
>> webserver. The getting part is fine as I could read it from the database.
>> But when I post , the server is getting the posted values but it also gives
>> 200 69 which is internal server error
>>
>>
> 200 is not internal server error, it is HTTP OK.  (500 is internal server
> error.) 69 is the number of bytes returned in the response.
>
>
>> here is what I see in terminal
>>
>> [22/Oct/2009 13:30:36] "GET
>> /add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f
>> HTTP/1.1" 200 69
>> [22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187
>>
>
> This shows you are not posting the data, rather you are getting it.  The
> request says GET and the parameters you are looking for are almost encoded
> into a query string, except it's missing the leading ? which signals the end
> of the url path and the beginning of the query string.  How is that request
> being generated?  It should be:
>
> /add_score/?name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f
>
>
> Without the ? the values will not be available in the request.GET
> dictionary, as they appear to be part of the URL path.
>
> Karen
>
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Karen Tracey
On Thu, Oct 22, 2009 at 2:35 PM, Dhruv Adhia  wrote:

> Allright, I see some progress, so now my views looks like this with that
> little modification
>
>
> def add_score(request):
>response_dict ={}
>if request.POST:
>name = request.POST['name']
>score = request.POST['score']
>hash = request.POST['hash']
>
>response_dict = {'name': name, 'score': score, 'hash': hash}
>return render_to_response('add_score.html', response_dict)
>
>
> From unity I am getting scores and names and I am also posting it onto the
> webserver. The getting part is fine as I could read it from the database.
> But when I post , the server is getting the posted values but it also gives
> 200 69 which is internal server error
>
>
200 is not internal server error, it is HTTP OK.  (500 is internal server
error.) 69 is the number of bytes returned in the response.


> here is what I see in terminal
>
> [22/Oct/2009 13:30:36] "GET
> /add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f
> HTTP/1.1" 200 69
> [22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187
>

This shows you are not posting the data, rather you are getting it.  The
request says GET and the parameters you are looking for are almost encoded
into a query string, except it's missing the leading ? which signals the end
of the url path and the beginning of the query string.  How is that request
being generated?  It should be:

/add_score/?name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f


Without the ? the values will not be available in the request.GET
dictionary, as they appear to be part of the URL path.

Karen

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
ohk , corrected. But then why am I not getting to see the values on browser?
is it because the url pattern is not matching?

Thanks Daniel.
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 12:05 PM, Daniel Roseman wrote:

>
> On Oct 22, 7:35 pm, Dhruv Adhia  wrote:
> > Allright, I see some progress, so now my views looks like this with that
> > little modification
> >
> > def add_score(request):
> >response_dict ={}
> >if request.POST:
> >name = request.POST['name']
> >score = request.POST['score']
> >hash = request.POST['hash']
> >response_dict = {'name': name, 'score': score, 'hash': hash}
> >return render_to_response('add_score.html', response_dict)
> >
> > From unity I am getting scores and names and I am also posting it onto
> the
> > webserver. The getting part is fine as I could read it from the database.
> > But when I post , the server is getting the posted values but it also
> gives
> > 200 69 which is internal server error
> >
> > here is what I see in terminal
> >
> > [22/Oct/2009 13:30:36] "GET
> >
> /add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06
> f
> > HTTP/1.1" 200 69
> > [22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187
> >
> > as you will see name = carbon_chaos and score=100 and some hash value...
> I
> > am posting those data from unity and when I load the scene I see that
> > activity happening inside the terminal. But it does not display the
> values
> > inside in the browser.
> >
> > What is the mistake?
> >
> > Thanks
> > Dhruv Adhiahttp://thirdimension.com
>
> You are using GET after all! As you can see from the console, it is a
> GET request, not a POST. So you should have been using request.GET
> ['whatever'] all along.
>
> I've no idea why you think '200 69' is an internal server error. On
> the contrary. The 200 part of that is the code for 'OK'. The 69 is
> just the length of the content that was returned.
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Daniel Roseman

On Oct 22, 7:35 pm, Dhruv Adhia  wrote:
> Allright, I see some progress, so now my views looks like this with that
> little modification
>
> def add_score(request):
>    response_dict ={}
>    if request.POST:
>        name = request.POST['name']
>        score = request.POST['score']
>        hash = request.POST['hash']
>        response_dict = {'name': name, 'score': score, 'hash': hash}
>    return render_to_response('add_score.html', response_dict)
>
> From unity I am getting scores and names and I am also posting it onto the
> webserver. The getting part is fine as I could read it from the database.
> But when I post , the server is getting the posted values but it also gives
> 200 69 which is internal server error
>
> here is what I see in terminal
>
> [22/Oct/2009 13:30:36] "GET
> /add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06 f
> HTTP/1.1" 200 69
> [22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187
>
> as you will see name = carbon_chaos and score=100 and some hash value... I
> am posting those data from unity and when I load the scene I see that
> activity happening inside the terminal. But it does not display the values
> inside in the browser.
>
> What is the mistake?
>
> Thanks
> Dhruv Adhiahttp://thirdimension.com

You are using GET after all! As you can see from the console, it is a
GET request, not a POST. So you should have been using request.GET
['whatever'] all along.

I've no idea why you think '200 69' is an internal server error. On
the contrary. The 200 part of that is the code for 'OK'. The 69 is
just the length of the content that was returned.
--
DR.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Inside my urls,

I have the url pattern as

(r'^add_score/', 'carbon_chaos.highscore.views.add_score'), # for displaying
posted data from unity..

is the url pattern wrong?
Thanks
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 11:35 AM, Dhruv Adhia  wrote:

> Allright, I see some progress, so now my views looks like this with that
> little modification
>
> def add_score(request):
>response_dict ={}
>if request.POST:
>name = request.POST['name']
>score = request.POST['score']
>hash = request.POST['hash']
>response_dict = {'name': name, 'score': score, 'hash': hash}
>return render_to_response('add_score.html', response_dict)
>
>
> From unity I am getting scores and names and I am also posting it onto the
> webserver. The getting part is fine as I could read it from the database.
> But when I post , the server is getting the posted values but it also gives
> 200 69 which is internal server error
>
> here is what I see in terminal
>
> [22/Oct/2009 13:30:36] "GET
> /add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f
> HTTP/1.1" 200 69
> [22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187
>
> as you will see name = carbon_chaos and score=100 and some hash value... I
> am posting those data from unity and when I load the scene I see that
> activity happening inside the terminal. But it does not display the values
> inside in the browser.
>
> What is the mistake?
>
> Thanks
> Dhruv Adhia
> http://thirdimension.com
>
>
>
> On Thu, Oct 22, 2009 at 11:30 AM, Daniel Roseman wrote:
>
>>
>> On Oct 22, 7:19 pm, Dhruv Adhia  wrote:
>> > oops that was a typo.. thanks for pointing that out... Yep I see atleast
>> the
>> > html elements getting displayed like those arrows...
>> >
>> > on the views side I didnt get what f4nt meant.. can you show me an
>> example?
>> >
>>
>> You had it right in your reply to him: request.POST['name']
>>
>> request.GET['whatever'] is for elements that are passed in as GET
>> parameters, eg /myurl/?param1=value1
>> --
>> DR.
>> >>
>>
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
Allright, I see some progress, so now my views looks like this with that
little modification

def add_score(request):
   response_dict ={}
   if request.POST:
   name = request.POST['name']
   score = request.POST['score']
   hash = request.POST['hash']
   response_dict = {'name': name, 'score': score, 'hash': hash}
   return render_to_response('add_score.html', response_dict)


>From unity I am getting scores and names and I am also posting it onto the
webserver. The getting part is fine as I could read it from the database.
But when I post , the server is getting the posted values but it also gives
200 69 which is internal server error

here is what I see in terminal

[22/Oct/2009 13:30:36] "GET
/add_score/name=carbon_chaos&score=100&hash=56ee224509ffd27920e64189cab9a06f
HTTP/1.1" 200 69
[22/Oct/2009 13:30:36] "GET /display_score/ HTTP/1.1" 200 187

as you will see name = carbon_chaos and score=100 and some hash value... I
am posting those data from unity and when I load the scene I see that
activity happening inside the terminal. But it does not display the values
inside in the browser.

What is the mistake?

Thanks
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 11:30 AM, Daniel Roseman wrote:

>
> On Oct 22, 7:19 pm, Dhruv Adhia  wrote:
> > oops that was a typo.. thanks for pointing that out... Yep I see atleast
> the
> > html elements getting displayed like those arrows...
> >
> > on the views side I didnt get what f4nt meant.. can you show me an
> example?
> >
>
> You had it right in your reply to him: request.POST['name']
>
> request.GET['whatever'] is for elements that are passed in as GET
> parameters, eg /myurl/?param1=value1
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Daniel Roseman

On Oct 22, 7:19 pm, Dhruv Adhia  wrote:
> oops that was a typo.. thanks for pointing that out... Yep I see atleast the
> html elements getting displayed like those arrows...
>
> on the views side I didnt get what f4nt meant.. can you show me an example?
>

You had it right in your reply to him: request.POST['name']

request.GET['whatever'] is for elements that are passed in as GET
parameters, eg /myurl/?param1=value1
--
DR.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
oops that was a typo.. thanks for pointing that out... Yep I see atleast the
html elements getting displayed like those arrows...

on the views side I didnt get what f4nt meant.. can you show me an example?

Thanks
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 11:05 AM, Daniel Roseman wrote:

>
> On Oct 22, 6:20 pm, Dhruv Adhia  wrote:
> > Hello,
> >
> > Quite a basic question.. I am posting data from Unity, its like name
> > and score. I want to read the posted data and display it.
> >
> > Here is the code that I currently have inside views.py
> >
> > def add_score(request):
> >response_dict ={}
> >if request.POST:
> >name = request.GET['name']
> >score = request.GET['score']
> >hash = request.GET['hash']
> >response_dict = {'name': name, 'score': score, 'hash': hash}
> >return render_to_response('add_score.html', response_dict)
> >
> > and template part
> >
> > Carbon Chaos leader board
> >
> > 
> > {% for carbon_chaos in response_dict %}
> > {{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
> > {{carbon_chaos.hash}}
> > {% endfor %}
> >
> > Can somebody point out what is the mistake?
> >
> > Thanks,
> > Dhruv
>
> As well as the view issue noted by f4nt, there are two further
> mistakes in the template:
> * response_dict is not an element in the context, it's what you have
> called the context within your view. In the template itself, the
> context elements are the keys/values in that dictionary.
> * There is no 'carbon_chaos' item in your context, so it doesn't make
> sense to iterate through it.
>
> So the template should look like this:
> 
> {{name}} >>> {{score}} >>> {{hash}}
> 
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Daniel Roseman

On Oct 22, 6:20 pm, Dhruv Adhia  wrote:
> Hello,
>
> Quite a basic question.. I am posting data from Unity, its like name
> and score. I want to read the posted data and display it.
>
> Here is the code that I currently have inside views.py
>
> def add_score(request):
>    response_dict ={}
>    if request.POST:
>        name = request.GET['name']
>        score = request.GET['score']
>        hash = request.GET['hash']
>        response_dict = {'name': name, 'score': score, 'hash': hash}
>    return render_to_response('add_score.html', response_dict)
>
> and template part
>
> Carbon Chaos leader board
>
> 
> {% for carbon_chaos in response_dict %}
> {{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
> {{carbon_chaos.hash}}
> {% endfor %}
>
> Can somebody point out what is the mistake?
>
> Thanks,
> Dhruv

As well as the view issue noted by f4nt, there are two further
mistakes in the template:
* response_dict is not an element in the context, it's what you have
called the context within your view. In the template itself, the
context elements are the keys/values in that dictionary.
* There is no 'carbon_chaos' item in your context, so it doesn't make
sense to iterate through it.

So the template should look like this:

{{name}} >>> {{score}} >>> {{hash}}

--
DR.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread Dhruv Adhia
do you mean name = request.POST['name'] ?

Thanks
Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 10:48 AM, f4nt  wrote:

>
> You're initting your variables from request.GET instead of
> request.POST.
>
> On Oct 22, 12:20 pm, Dhruv Adhia  wrote:
> > Hello,
> >
> > Quite a basic question.. I am posting data from Unity, its like name
> > and score. I want to read the posted data and display it.
> >
> > Here is the code that I currently have inside views.py
> >
> > def add_score(request):
> >response_dict ={}
> >if request.POST:
> >name = request.GET['name']
> >score = request.GET['score']
> >hash = request.GET['hash']
> >response_dict = {'name': name, 'score': score, 'hash': hash}
> >return render_to_response('add_score.html', response_dict)
> >
> > and template part
> >
> > Carbon Chaos leader board
> >
> > 
> > {% for carbon_chaos in response_dict %}
> > {{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
> > {{carbon_chaos.hash}}
> > {% endfor %}
> >
> > Can somebody point out what is the mistake?
> >
> > Thanks,
> > Dhruv
>
> >
>

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: displaying posted data

2009-10-22 Thread f4nt

You're initting your variables from request.GET instead of
request.POST.

On Oct 22, 12:20 pm, Dhruv Adhia  wrote:
> Hello,
>
> Quite a basic question.. I am posting data from Unity, its like name
> and score. I want to read the posted data and display it.
>
> Here is the code that I currently have inside views.py
>
> def add_score(request):
>    response_dict ={}
>    if request.POST:
>        name = request.GET['name']
>        score = request.GET['score']
>        hash = request.GET['hash']
>        response_dict = {'name': name, 'score': score, 'hash': hash}
>    return render_to_response('add_score.html', response_dict)
>
> and template part
>
> Carbon Chaos leader board
>
> 
> {% for carbon_chaos in response_dict %}
> {{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
> {{carbon_chaos.hash}}
> {% endfor %}
>
> Can somebody point out what is the mistake?
>
> Thanks,
> Dhruv

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



displaying posted data

2009-10-22 Thread Dhruv Adhia

Hello,

Quite a basic question.. I am posting data from Unity, its like name
and score. I want to read the posted data and display it.

Here is the code that I currently have inside views.py


def add_score(request):
   response_dict ={}
   if request.POST:
   name = request.GET['name']
   score = request.GET['score']
   hash = request.GET['hash']
   response_dict = {'name': name, 'score': score, 'hash': hash}
   return render_to_response('add_score.html', response_dict)


and template part

Carbon Chaos leader board


{% for carbon_chaos in response_dict %}
{{carbon_chaos.name}} >>> {{carbon_chaos.score}} >>>
{{carbon_chaos.hash}}
{% endfor %}


Can somebody point out what is the mistake?

Thanks,
Dhruv
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---