Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42688
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Neil Cerutti <neilc@norwich.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: Mixin way? |
| Date | 3 Apr 2013 17:16:07 GMT |
| Organization | Norwich University |
| Lines | 35 |
| Message-ID | <as36enFrk8aU1@mid.individual.net> (permalink) |
| References | <mailman.60.1364997899.3114.python-list@python.org> <515c4f07$0$29966$c3e8da3$5496439d@news.astraweb.com> <mailman.64.1365006544.3114.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net Xb/aRAX/yu2SWJ4JI+kjGgmPs7NT2scUoayggFYwsJWZnh/11f |
| Cancel-Lock | sha1:9MTO66liFoMOKO/Jo3iPQ5fQBi0= |
| User-Agent | slrn/0.9.9p1/mm/ao (Win32) |
| Xref | csiph.com comp.lang.python:42688 |
Show key headers only | View raw
On 2013-04-03, andrea crotti <andrea.crotti.0@gmail.com> wrote:
> Well I can explain better the situation to make it more clear.
>
> We are using CouchDb and so far it has been (sigh) a brutal
> manipulation of dictionaries everywhere, with code duplication
> and so on.
>
> Now I wanted to encapsulate all the entities in the DB in
> proper objects, so I have a CouchObject:
>
>
> class CouchObject(object) :
> """
> Encapsulate an object which has the ability to be saved to a couch
> database.
> """
> #: list of fields that get filled in automatically if not passed in
> AUTO = ['created_datetime', 'doc_type', '_id', '_rev']
> #: dictionary with some extra fields with default values if not
> # passed in the constructor the default value gets set to the attribute
> DEFAULTS = {}
> REQUIRED = []
> OPTIONAL = []
> TO_RESOLVE = []
> MIXINS = []
>
> Where every subclass can redefine these attributes to get
> something done automatically by the constructor for
> convenience.
Hopefully someone with experience with them can help you further,
but this seems like a job for a metaclass.
--
Neil Cerutti
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Mixin way? andrea crotti <andrea.crotti.0@gmail.com> - 2013-04-03 15:04 +0100
Re: Mixin way? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-03 15:47 +0000
Re: Mixin way? andrea crotti <andrea.crotti.0@gmail.com> - 2013-04-03 17:29 +0100
Re: Mixin way? Neil Cerutti <neilc@norwich.edu> - 2013-04-03 17:16 +0000
csiph-web