Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64682
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <burak.arslan@arskom.com.tr> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'schema': 0.05; 'subject:Python': 0.06; 'column': 0.07; 'definitions': 0.07; 'element': 0.07; 'defines': 0.09; 'null,': 0.09; 'subset': 0.09; 'type,': 0.09; 'url:github': 0.09; 'python': 0.11; 'itself.': 0.14; "'title'": 0.16; 'burak': 0.16; 'columns': 0.16; 'from:addr:arskom.com.tr': 0.16; 'from:addr:burak.arslan': 0.16; 'from:name:burak arslan': 0.16; 'length,': 0.16; 'message- id:@arskom.com.tr': 0.16; 'received:arskomhosting.com': 0.16; 'wrote:': 0.18; 'app': 0.19; 'help.': 0.21; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'example.': 0.24; 'values': 0.27; 'header:In- Reply-To:1': 0.27; 'to:2**1': 0.27; 'wonder': 0.29; 'xml': 0.29; 'database,': 0.30; "skip:' 10": 0.31; 'that.': 0.31; 'etc.).': 0.31; 'class': 0.32; 'handled': 0.32; 'quite': 0.32; '(e.g.': 0.33; 'cases': 0.33; 'table': 0.34; 'problem': 0.35; "can't": 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'false': 0.36; 'doing': 0.36; 'list': 0.37; 'level': 0.37; 'e.g.': 0.38; 'to:addr:python- list': 0.38; 'that,': 0.38; 'use.': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'easy': 0.60; 'hope': 0.61; 'conversion': 0.61; 'simple': 0.61; 'information': 0.63; 'such': 0.63; 'maximum': 0.63; 'more': 0.64; 'between': 0.67; 'frank': 0.68; 'you:': 0.81; 'allowable': 0.84; 'atomic': 0.84; 'choices.': 0.84; 'column.': 0.84; "it'd": 0.84; 'adopt': 0.91 |
| Date | Fri, 24 Jan 2014 15:40:07 +0200 |
| From | Burak Arslan <burak.arslan@arskom.com.tr> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| MIME-Version | 1.0 |
| To | Frank Millman <frank@chagford.com>, python-list@python.org |
| Subject | Re: Python declarative |
| References | <mailman.5529.1389805825.18130.python-list@python.org> <8fde6d34-47c5-49a1-a6d0-9ffe3df2d401@googlegroups.com> <CAPTjJmokZUHta7Y3x_=6eUjKpv2Td2iaqro1su7NuLo+gfzwag@mail.gmail.com> <lbtb9r$ljd$1@ger.gmane.org> |
| In-Reply-To | <lbtb9r$ljd$1@ger.gmane.org> |
| X-Enigmail-Version | 1.6 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5940.1390571155.18130.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390571155 news.xs4all.nl 2940 [2001:888:2000:d::a6]:54316 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64682 |
Show key headers only | View raw
On 01/24/14 11:21, Frank Millman wrote:
> I store database metadata in the database itself. I have a table that
> defines each table in the database, and I have a table that defines each
> column. Column definitions include information such as data type, allow
> null, allow amend, maximum length, etc. Some columns require that the value
> is constrained to a subset of allowable values (e.g. 'title' must be one of
> 'Mr', 'Mrs', etc.). I know that this can be handled by a 'check' constraint,
> but I have added some additional features which can't be handled by that. So
> I have a column in my column-definition table called 'choices', which
> contains a JSON'd list of allowable choices. It is actually more complex
> than that, but this will suffice for a simple example.
I wonder whether your use cases can be fully handled by Xml Schema
standard. It's quite robust and easy to use. You are already doing
validation at the app level so I don't think it'd be much of a problem
for you to adopt it.
e.g.
>>> from spyne.model import *
>>> class C(ComplexModel):
... title = Unicode(values=['Mr', 'Mrs', 'Ms'])
...
>>> from lxml import etree
>>> from spyne.util.xml import get_validation_schema
>>> schema = get_validation_schema([C], 'some_ns')
>>> doc1 = etree.fromstring('<C xmlns="some_ns"><title>Mr</title></C>')
>>> print schema.validate(doc1)
True
>>> doc2 = etree.fromstring('<C xmlns="some_ns"><title>xyz</title></C>')
>>> print schema.validate(doc2)
False
>>> print schema.error_log
<string>:1:0:ERROR:SCHEMASV:SCHEMAV_CVC_ENUMERATION_VALID: Element
'{some_ns}title': [facet 'enumeration'] The value 'xyz' is not an
element of the set {'Mr', 'Mrs', 'Ms'}.
<string>:1:0:ERROR:SCHEMASV:SCHEMAV_CVC_DATATYPE_VALID_1_2_1: Element
'{some_ns}title': 'xyz' is not a valid value of the atomic type
'{some_ns}C_titleType'.
>>>
Also, if you need conversion between various serialization formats and
Python object hierarchies, I put together an example for you:
https://gist.github.com/plq/8596519
I hope these help.
Best,
Burak
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python declarative Sergio Tortosa Benedito <sertorbe@gmail.com> - 2014-01-15 18:02 +0100
Re: Python declarative Francesco Bochicchio <bieffe62@gmail.com> - 2014-01-17 06:22 -0800
Re: Python declarative Francesco Bochicchio <bieffe62@gmail.com> - 2014-01-19 23:25 -0800
Re: Python declarative sertorbe@gmail.com - 2014-01-17 06:47 -0800
Re: Python declarative Tim Roberts <timr@probo.com> - 2014-01-18 13:13 -0800
Re: Python declarative sertorbe@gmail.com - 2014-01-19 02:27 -0800
Re: Python declarative sertorbe@gmail.com - 2014-01-22 12:38 -0800
Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-01-22 13:16 -0800
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-23 13:29 +1100
Re: Python declarative Terry Reedy <tjreedy@udel.edu> - 2014-01-22 23:08 -0500
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 11:21 +0200
Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-24 01:53 -0800
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 15:06 +0200
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-24 22:18 +1100
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 14:49 +0200
Re: Python declarative Burak Arslan <burak.arslan@arskom.com.tr> - 2014-01-24 15:40 +0200
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 00:55 +1100
Re: Python declarative Matěj Cepl <mcepl@redhat.com> - 2014-01-24 17:28 +0100
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 03:33 +1100
Re: Python declarative sertorbe@gmail.com - 2014-01-24 10:51 -0800
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-25 09:18 +0200
Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 02:33 +0000
Re: Python declarative Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-26 02:45 +0000
Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-02-02 18:17 -0800
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 14:38 +1100
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 15:06 +1100
Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-25 20:47 -0800
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 16:23 +1100
Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-26 00:05 -0800
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-26 11:12 +0200
Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-26 06:36 -0800
Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 12:05 +0000
Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-26 08:03 +0200
Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 12:21 +0000
Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 18:33 +1100
Re: Python declarative matej@ceplovi.cz (Matěj Cepl) - 2014-01-25 12:23 +0100
Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-01-24 04:04 -0800
csiph-web