[google-appengine] Re: What does Model.to_xml() returns?

2009-03-23 Thread Marcelo Sena

So I tried a more direct approach to this problem:

function stateChanged()
{
if (xmlHttp.readyState==4)
{
if (xmlHttp.responseXML==null)alert("Null");
var xmlDoc=xmlHttp.responseXML.documentElement;
document.getElementById("companyname").innerHTML=
xmlDoc.getElementsByTagName("compname")[0].childNodes[0].nodeValue;
document.getElementById("contactname").innerHTML=
xmlDoc.getElementsByTagName("contname")[0].childNodes[0].nodeValue;
document.getElementById("address").innerHTML=
xmlDoc.getElementsByTagName("address")[0].childNodes[0].nodeValue;
document.getElementById("city").innerHTML=
xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue;
document.getElementById("country").innerHTML=
xmlDoc.getElementsByTagName("country")[0].childNodes[0].nodeValue;
}
}

The responseXML is always null so the line after the alert box always
crashes.

Here is the response handler I'm using:

class getANote(webapp.RequestHandler):
def get(self):
#query=Models.NoteModel.all()
#fnote=query.get()

self.response.out.write('''

Foo
bar
ball
bwal
XD

''')

The xml is said well formatted using w3c validator. Now what I'm doing
wrong, is this a app engine error? Help please!


On Mar 20, 9:53 pm, Marcelo Sena  wrote:
> Here is my model:
> class NoteModel(db.Model):
>     title = db.StringProperty(multiline=False)
>     content = db.ListProperty(type('string'))
> And the values are:
> title:'Foo'
> content: ['bar']
>
> And the result of:
>
> class getANote(webapp.RequestHandler):
>     def get(self):
>         query=Models.NoteModel.all()
>         fnote=query.get()
>         xmlrep=fnote.to_xml()
>
>         self.response.out.write(xmlrep)
>
> called from:
>
> function stateChanged()
> {
>         if (xmlHttp.readyState==4)
>         {
>                 var xmlDoc=xmlHttp.responseXML;
>                 document.getElementById("txtHint").innerHTML=xmlDoc;
>
>         }
>
> }
>
> But the result is:
>
> Exactly, nothing. What am I doing wrong?
>
> On Mar 20, 4:25 pm, Marcelo Sena  wrote:
>
> > I know what the docs say, but what kind of xml is that, is a string or
> > a object and what is the type of that object? I tried  using type() on
> > it and it returned nothing.
> > I need to turn my model into a XML to use it in a javascript.
> > Regards,
> > Marcelo Sena.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: What does Model.to_xml() returns?

2009-03-20 Thread Marcelo Sena

Here is my model:
class NoteModel(db.Model):
title = db.StringProperty(multiline=False)
content = db.ListProperty(type('string'))
And the values are:
title:'Foo'
content: ['bar']

And the result of:

class getANote(webapp.RequestHandler):
def get(self):
query=Models.NoteModel.all()
fnote=query.get()
xmlrep=fnote.to_xml()

self.response.out.write(xmlrep)

called from:

function stateChanged()
{
if (xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML;
document.getElementById("txtHint").innerHTML=xmlDoc;

}
}

But the result is:

Exactly, nothing. What am I doing wrong?

On Mar 20, 4:25 pm, Marcelo Sena  wrote:
> I know what the docs say, but what kind of xml is that, is a string or
> a object and what is the type of that object? I tried  using type() on
> it and it returned nothing.
> I need to turn my model into a XML to use it in a javascript.
> Regards,
> Marcelo Sena.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] What does Model.to_xml() returns?

2009-03-20 Thread Marcelo Sena

I know what the docs say, but what kind of xml is that, is a string or
a object and what is the type of that object? I tried  using type() on
it and it returned nothing.
I need to turn my model into a XML to use it in a javascript.
Regards,
Marcelo Sena.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Problem when storing a integer into a model(GQL)

2009-03-15 Thread Marcelo Sena

There is only one instance of ManifestVersion. I used versionList.count
() and it returned 1. And I'm not really looking into ensuring the
uniqueness in ManifestVersion. Latter that model will disappear and
become just a variable in the user entity(which I haven't created
yet), but thanks for the suggestion.

On Mar 15, 9:33 am, Marcelo Sena  wrote:
> I found something interesting. If i don't try to commit the
> versionNumber, its value is set to 1. Could it be something wrong with
> in my model?
>
> On Mar 15, 8:03 am, Tim Hoffman  wrote:
>
> > Here's some things to look at.
>
> > versionumber must be 0 when you fetch it, are you sure there is only
> > one instance of ManifestVersion,
> > and if there is supposed to be only one, why the call to
> > ManifestVersion.all(), you should just get the object by id or key.
> > (Have you confirmed that there is only one instance returned from all
> > () ?)
> > my guess is you have more than one instance
>
> > T
>
> > On Mar 15, 1:55 pm, Marcelo Sena  wrote:
>
> > > Here is the model I'm trying to update:
>
> > > class ManifestVersion(db.Model):
> > >     versionNumber = db.IntegerProperty()
>
> > > Here is the method that should change the only instance of the
> > > previous model:
>
> > > def incrementVersion():
> > >     versionList = ManifestVersion.all()
> > >     num = versionList[0].versionNumber
> > >     num = num+1
> > >     versionList[0].versionNumber = num
> > >     versionList[0].put()
> > >     return versionList[0].versionNumber
>
> > > But the versionNumber value is never updated and this function always
> > > returns 1. On the other hand num is changed in this call.
> > > What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Problem when storing a integer into a model(GQL)

2009-03-15 Thread Marcelo Sena

I found something interesting. If i don't try to commit the
versionNumber, its value is set to 1. Could it be something wrong with
in my model?

On Mar 15, 8:03 am, Tim Hoffman  wrote:
> Here's some things to look at.
>
> versionumber must be 0 when you fetch it, are you sure there is only
> one instance of ManifestVersion,
> and if there is supposed to be only one, why the call to
> ManifestVersion.all(), you should just get the object by id or key.
> (Have you confirmed that there is only one instance returned from all
> () ?)
> my guess is you have more than one instance
>
> T
>
> On Mar 15, 1:55 pm, Marcelo Sena  wrote:
>
> > Here is the model I'm trying to update:
>
> > class ManifestVersion(db.Model):
> >     versionNumber = db.IntegerProperty()
>
> > Here is the method that should change the only instance of the
> > previous model:
>
> > def incrementVersion():
> >     versionList = ManifestVersion.all()
> >     num = versionList[0].versionNumber
> >     num = num+1
> >     versionList[0].versionNumber = num
> >     versionList[0].put()
> >     return versionList[0].versionNumber
>
> > But the versionNumber value is never updated and this function always
> > returns 1. On the other hand num is changed in this call.
> > What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Problem when storing a integer into a model(GQL)

2009-03-14 Thread Marcelo Sena

Here is the model I'm trying to update:

class ManifestVersion(db.Model):
versionNumber = db.IntegerProperty()

Here is the method that should change the only instance of the
previous model:

def incrementVersion():
versionList = ManifestVersion.all()
num = versionList[0].versionNumber
num = num+1
versionList[0].versionNumber = num
versionList[0].put()
return versionList[0].versionNumber

But the versionNumber value is never updated and this function always
returns 1. On the other hand num is changed in this call.
What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Getting __title__ is not defined error

2009-03-09 Thread Marcelo Sena

Hi, I'm getting the following error message when trying to run my
application:

   1 if __title__ == "__main__":
2   main()
__title__ undefined

: name '__title__' is not defined
  args = ("name '__title__' is not defined",)
  message = "name '__title__' is not defined"


Were is the URL I'm accessing :

http://127.0.0.1:8080/

Here is the content of my app.yaml file:

application: arcthingpad
version: 1
runtime: python
api_version: 1

handlers:

- url: /stylesheets
  static_dir: stylesheets


- url: /.*
  script: arcthingpad.py

And here is the content of my arcthingpad.py file:

if __title__ == "__main__":
  main()

I removed all the code logic, just to be sure I wasn't doing anything
stupid. Still I'm getting this error and the helloworld application
works normally.

Any ideas?

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