[Schevo-devel] Couple more questions

Matthew Scott mscott at goldenspud.com
Tue Dec 6 16:38:54 EST 2005


On 12/6/05, Tom Locke <tom at livelogix.com> wrote:
> > Is _key(firstField, secondField) what you're looking for?
> Sounds right. Can you explain what the _key is doing? Apart from (I
> assume) enforcing uniqueness.
>
> Thanks

A description of the usage of "key" and "index" can be found here:

http://schevo.org/reference-indices.html#specification-in-schema

For example:

class Person(E.Entity):
  name = f.unicode()
  age = f.integer()
  _key(name)
  _index(age, name)

This extent will enforce uniqueness in the 'name' field, and also
provide a non-unique index by 'age' and 'name'.

Using the 'by' method (see
http://schevo.org/class-schevo.extent.Extent.html#by) you can obtain
sorted results by either index spec:

by_name = db.Person.by('name')
by_age_name = db.Person.by('age', 'name')
oldest_first = db.Person.by('-age', 'name')

--
Matthew R. Scott



More information about the Schevo-devel mailing list