Skip to content

marquee/content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

droptype-content

Create an API wrapper instance for a specific user:

>>> co = ContentObjects(CONTENT_API_TOKEN)

Get all objects owned by the authenticated user:

>>> co.all()

Retrieve a listing of object, filtered by parameters:

>>> co.filter(content=some_id)
>>> co.filter(type=Text)
>>> # Can also use a string, but the class is preferred
>>> co.filter(type='text')

Retrieve a specific object by id:

>>> obj = co.fetch(obj_id)

Create a new Text object:

>>> text_obj = co.create(Text, obj_attrs)

Modify and save the text object:

>>> text_obj.content = 'New content'
>>> # Or more than one at a time (like a dictionary)
>>> text_obj.update({
...         'content'   : 'New content',
...         'role'      : 'quote',
...     })
>>> co.save(text_obj)

Or save a whole bunch of objects:

>>> co.save(obj1, obj2, obj3)
>>> co.save([obj1, obj2, obj3])

Add an annotation:

>>> text_obj.annotations = [{
...         'type'  : 'link',
...         'start' : 0,
...         'end'   : 3,
...         'url'   : 'http://example.com',
...     }]
>>> text_obj.content
u'New content'
>>> text_obj.toHTML()
u'<a href="http://example.com">New</a> content'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages