Comments (3)
Possibly add sorting support
from python-adapters.
Hi alexei, ListField would be really welcome, but having the possibility of composing it with other fields would be nicer, like ListField(CharField(... or even (as in your examples) ListField(AddressAdapter( ...
from python-adapters.
Ok, I just monkey-patched the lib and added the following code:
adapters/fields.py
class ListField(BaseField):
def adapt(self, data):
ret = []
if isinstance(data, list):
if self.base:
for item in data:
res = self.base().adapt(item)
ret.append(res)
return ret
adapters/base.py
class BaseField(object):
def __init__(self, source=None, default=undefined, required=True, base=None):
self.source = source
self.default = default
self.required = required
self.base = base
from python-adapters.
Related Issues (20)
- Implement AdapterMethodField
- Allow optional fields
- Implement adapt_* HOT 2
- Set dict as default model
- Use collections.Iterable instead of (list, tuple) when checking if obj is iterable
- Required field with no (default) value should raise
- Write test for redundant source error
- Write test for required field with no default error
- Allow adapting data to existing resource i.e. instance kwarg
- Support editable kwarg HOT 1
- Write test for list adapter
- Update README with description and stuff
- Rename Adapter.Meta.model to something else
- Add omitempty option
- Add list adapter support
- AdapterMethodField should maybe accept the source kwarg
- Make get_attibute/set_attribute methods public
- Make adapters callable
- Use six string types
- Get_attribute method is misbehaving for every other Field except AdapterMethodField.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-adapters.