After having messed around with the template stuff, I am starting to
dig now into the db stuff, but with little success yet. I am trying to
setup a very simple contact form, but something goes wrong, I am
getting an error message like this:
TypeError: Cannot read property "name" from undefined : at /Users/
rsaccon/...../api/datastore/types.js:38
here is the relevant part of what I am doing in the controller:
....
var params = new Request(env).params();
print(
params.name); // gives expected result !!!
var contact = new Contact(
params.name, params.email);
contact.company = params.company;
contact.website = params.website;
contact.subject = params.subject;
contact.message = params.message;
contact.created = new Date();
contact.put();
...
and here is the relevant part of what I have in the model:
....
var db = require("google/appengine/ext/db")
var Contact = exports.Contact = function(name, email, company,
website, subject, message) {
this.name = name;
this.email = email;
this.company = company;
this.website = website;
this.subject = subject;
this.message = message;
this.created = new Date();
this.__key__ = db.key();
};
Contact.model = new db.Model(Contact, "Contact", {
name: new db.StringProperty({required: true}),
email: new db.StringProperty({required: true}),
company: new db.StringProperty(),
website: new db.StringProperty(),
subject: new db.StringProperty(),
message: new db.TextProperty({required: true}),
created: new db.DateTimeProperty({autoNowAdd: true})
});
....
I tried to do the same as in blog-gae example, and it looks to me that
there is some redundancy in controller and model which does not make
much sense to me, but the main problem, of course, is that this code
does not work. Anything obvious I misunderstood ?
--
Roberto