How to design data model

57 views
Skip to first unread message

fhucho

unread,
Nov 15, 2009, 5:48:15 PM11/15/09
to Google App Engine
Hi,
I am developing a web app, where users should be able to (in this
order):
1) create their item type (item type can be everything - car,
book, movie..., item type has some user defined parameters,
like price, rating)
2) add items of their type - e.g. they can create book type (with
title, author, rating parameters) and then add books
3) view, filter (at least by one parameter), delete, edit their
items

How should I design the data model? Is this even posible in App
Engine?

Thanks in advance

风笑雪

unread,
Nov 15, 2009, 11:28:05 PM11/15/09
to google-a...@googlegroups.com
It can be done in Python version by using eval statement or
type()/classobj() function:

from google.appengine.ext import db

property = {'string': db.StringProperty, 'rating': db.RatingProperty}

Book = type('Book', (db.Model,), {'title': property['string'](),
'author': property['string'](), 'rating': property['rating']()})

new_book = Book(title='Harry James Potter', author='Joanne Kathleen
Rowling', rating=100)

new_book.put()

book = Book.all().filter('title =', 'Harry James Potter').get()

print book.title
print book.author
print book.rating


result:
Harry James Potter
Joanne Kathleen Rowling
100

2009/11/16 fhucho <fhu...@gmail.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-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=.
>
>
>

N. Rosencrantz

unread,
Nov 15, 2009, 11:38:04 PM11/15/09
to Google App Engine
django has impressive builtin editor for our models with
djangoforms.ModelForm seen on
http://code.google.com/appengine/articles/djangoforms.html
Theoretically the create "CRUD" and/or factory pattern
http://en.wikipedia.org/wiki/Factory_method_pattern
I recommend and use for likewise. The categoryproperty.db
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#Category
seems obvious choice which needs documention how it differs from a
word. app I maintain has similar function, create item, add item,
edit, view, filter by longitude latitude and/or category
(www.koolbusiness.com/ai) sourced montao.googlecode.com
Sincerely
Nick RTZ

fhucho

unread,
Nov 16, 2009, 6:11:01 AM11/16/09
to Google App Engine
Unfortunately, I'm not using Python... is there a way to make this
work in Java?

On Nov 16, 5:38 am, niklasr <nikla...@gmail.com> wrote:
> On Nov 15, 5:48 pm, fhucho <fhu...@gmail.com> wrote:> Hi,
> > I am developing a web app, where users should be able to (in this
> > order):
> >     1) create their item type (item type can be everything - car,
> > book, movie..., item type has some user defined parameters,
> > like                                        price, rating)
> >     2) add items of their type - e.g. they can create book type (with
> > title, author, rating parameters) and then add books
> >     3) view, filter (at least by one parameter), delete, edit their
> > items
>
> > How should I design the data model? Is this even posible in App
> > Engine?
>
> > Thanks in advance
>
> django has impressive builtin editor for our models with
> djangoforms.ModelForm seen onhttp://code.google.com/appengine/articles/djangoforms.html
> Theoretically the create "CRUD" and/or factory patternhttp://en.wikipedia.org/wiki/Factory_method_pattern
> I recommend and use for likewise. The categoryproperty.dbhttp://code.google.com/appengine/docs/python/datastore/typesandproper...

N. Rosencrantz

unread,
Nov 22, 2009, 7:59:45 AM11/22/09
to Google App Engine


On Nov 16, 6:11 am, fhucho <fhu...@gmail.com> wrote:
> Unfortunately, I'm not using Python... is there a way to make this
> work in Java?

Absolutely. Even more (and harder) ways in Java. Most of the project
("CRUD") create update delete a.k.a view add delete edit is available
via montao.googlecode.com welcome view live montao.com.br migr8ing to
gae web.montao.com.br and Indian version Fridge.Koolbusiness.com

thebrianschott

unread,
May 28, 2012, 2:40:52 PM5/28/12
to google-a...@googlegroups.com
Niklas (et al),

I am very pleased to find your link below of djangoforms because it seems so promising for my app.

But when I enter the code for the app I get lots of warnings and finally the shopping list app stops with the following messages in the log.

INFO     2012-05-28 18:27:04,446 dev_appserver_multiprocess.py:647] Running application dev~shoppinglist on port 8083: http://localhost:8083

INFO     2012-05-28 18:27:04,447 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8083/_ah/admin

INFO     2012-05-28 18:27:29,059 dev_appserver.py:2904] "GET / HTTP/1.1" 200 -


I am using Python2.7 and webapp2 for the first time and I fear there is some conflict with this django forms example. I seem to remember reading that webapp2 does not support cgi, for example. 

Btw, I am getting the following warnings also in the log. Can they be ignored?

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/search/search.py:232: UserWarning: DocumentOperationResult._CODES is deprecated. Use OperationResult._CODES instead.

  'Use OperationResult.%s instead.' % (name, name))

WARNING  2012-05-28 18:27:04,346 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.

WARNING  2012-05-28 18:27:04,438 datastore_file_stub.py:518] Could not read datastore data from /var/folders/cm/fffkv5rd69j054q9yr1vg38h0000gn/T/dev_appserver.datastore

WARNING  2012-05-28 18:27:04,440 dev_appserver.py:3423] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging


Thanks very much,

Brian in Atlanta
Reply all
Reply to author
Forward
0 new messages