Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use domains for fields #127

Open
josejachuf opened this issue Apr 5, 2015 · 1 comment
Open

Use domains for fields #127

josejachuf opened this issue Apr 5, 2015 · 1 comment

Comments

@josejachuf
Copy link

Do not think it's very difficult to implement the use of domains in the definition of the fields.

A domain is a user-defined custom data type. It is used for defining the format and range of field

Now it can be implemented through a dictionary:

person_name = dict(
type='string',
length=100,
requires=IS_NOT_EMPTY(),
etc,
etc
)
db.define_table('my_table',
Field('name', **dict(person_name))
)

but the proposal is to make it more explicit:

person_name = Domain(
type='string',
length=100,
requires=IS_NOT_EMPTY(),
etc,
etc
)

db.define_table('my_table',
Field('name', domain=person_name)
)

db.define_table('other_table',
Field('other_name', domain=person_name)
)

This is very comfortable when you want to change data types from many fields at once

@ilvalle
Copy link
Contributor

ilvalle commented Apr 6, 2015

Please, open discussion in the forum.

This can be a starting point
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?#Custom-Field-types--experimental-

Paolo

2015-04-05 18:40 GMT+02:00 josejachuf [email protected]:

Do not think it's very difficult to implement the use of domains in the
definition of the fields.

A domain is a user-defined custom data type. It is used for defining the
format and range of field

Now it can be implemented through a dictionary:

person_name = dict(
type='string',
length=100,
requires=IS_NOT_EMPTY(),
etc,
etc
)
db.define_table('my_table',
Field('name', **dict(person_name))
)

but the proposal is to make it more explicit:

person_name = Domain(
type='string',
length=100,
requires=IS_NOT_EMPTY(),
etc,
etc
)

db.define_table('my_table',
Field('name', domain=person_name)
)

db.define_table('other_table',
Field('other_name', domain=person_name)
)

This is very comfortable when you want to change data types from many
fields at once


Reply to this email directly or view it on GitHub
#127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants