The validation is fired when you call Project(), and since the
"required=True" attributes aren't yet present.

Try replacing:

       proj = Project()
       proj.ProjectId = self.request.get("txtProjectId")
       proj.ProjectName = self.request.get("txtProjectName")

with:

       proj = Project(ProjectId=self.request.get("txtProjectId"),
                            ProjectName =
self.request.get("txtProjectName"))





On Fri, Dec 24, 2010 at 8:59 AM, HsuCI <hsuci0...@gmail.com> wrote:

> Dear Guys
> I would like to test a db access function at localhost.
> I tried running my code on the Google App Engine Launcher.
> but it always show me an error message below:
>
> Traceback (most recent call last):
>  File "C:\Program Files\Google\google_appengine\google\appengine\ext
> \webapp\__init__.py", line 517, in __call__
>    handler.post(*groups)
>  File "D:\Regalscan\DevProject\PyProjects\rgsz\Default.py", line 20,
> in post
>    proj = Project()
>  File "C:\Program Files\Google\google_appengine\google\appengine\ext
> \db\__init__.py", line 812, in __init__
>    prop.__set__(self, value)
>  File "C:\Program Files\Google\google_appengine\google\appengine\ext
> \db\__init__.py", line 541, in __set__
>    value = self.validate(value)
>  File "C:\Program Files\Google\google_appengine\google\appengine\ext
> \db\__init__.py", line 2429, in validate
>    value = super(StringProperty, self).validate(value)
>  File "C:\Program Files\Google\google_appengine\google\appengine\ext
> \db\__init__.py", line 568, in validate
>    raise BadValueError('Property %s is required' % self.name)
> BadValueError: Property ProjectId is required
>
> Does anyone can tell me what is my next step?
>
> Here are my code:
> Default.py
> =======================================================================
> import os
> from google.appengine.ext import webapp
> from google.appengine.ext.webapp import template
> from google.appengine.ext.webapp.util import run_wsgi_app
> from django.template import Context
> from google.appengine.ext import db
>
> class Project(db.Model):
>    ProjectId = db.StringProperty(required=True)
>    ProjectName = db.StringProperty(required=True)
>
> class MainPage(webapp.RequestHandler):
>    def get(self):
>        path = os.path.join(os.path.dirname(__file__), 'Default.html')
>        self.response.out.write(template.render(path, []))
>
> class PutDataStore(webapp.RequestHandler):
>    def post(self):
>
> #self.response.out.write("<script>alert('"+self.request.get("txtProjectId")
> +"');</script>")
>        proj = Project()
>        proj.ProjectId = self.request.get("txtProjectId")
>        proj.ProjectName = self.request.get("txtProjectName")
>        proj.put()
>        self.response.out.write("<script>alert('OK');</
> script>")
>
>
> application = webapp.WSGIApplication(
>                                     [('/',MainPage),
>                                      ('/putDB', PutDataStore)],
>                                     debug=True
>                                     )
>
> def main():
>    run_wsgi_app(application)
>
> if __name__ == "__main":
>    main()
>
> ======================================================================
> Default.html
> ======================================================================
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> <head></head>
> <html>
>  <body>
>        <form action="/putDB" method="post">
>          <span>1234567</span>
>          <br />
>          <span>Project ID:</span><input type='text' name='txtProjectId' /
> ><br/>
>          <span>Project Name:</span><input type='text' name='txtProjectName'
> /
> ><br/>
>          <span>Customer ID:</span><input type='text' name='txtCustomerId' /
> ><br/>
>          <span>Customer Name:</span><input type='text'
> name='txtCustomerName' />
>          <input type='submit' value='Save' />
>        </form>
>  </body>
> </html>
>
>
> --
> 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-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>


-- 
Ross M Karchner
http://eventgrinder.com

-- 
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-appeng...@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.

Reply via email to