couchbasekit is a wrapper around CouchBase Python driver for document
validation and more
. It was inspired by
MongoKit <http://namlook.github.com/mongokit/>
_ and was developed by
the project coming soon?, which is also an open source project.
You can get detailed information about couchbase itself from http://www.couchbase.com/ and about its Python driver form http://www.couchbase.com/develop/python/next.
Documentation: https://couchbasekit.readthedocs.org/en/latest/
Source code: https://github.com/kirpit/couchbasekit
Less talk, more code. Set your authentication details first::
from couchbasekit import Connection
# you should do this somewhere beginning such as settings.py:
Connection.auth('myusername', '[email protected]')
Then define your model document.
author.py::
import datetime
from couchbasekit import Document, register_view
from couchbasekit.fields import EmailField, ChoiceField
from example.samples.publisher import Publisher
from example.samples.book import Book
class Gender(ChoiceField):
CHOICES = {
'M': 'Male',
'F': 'Female',
}
@register_view('dev_authors')
class Author(Document):
__bucket_name__ = 'couchbasekit_samples'
__key_field__ = 'slug' # optional
doc_type = 'author'
structure = {
'slug': unicode,
'first_name': unicode,
'last_name': unicode,
'gender': Gender,
'email': EmailField,
'publisher': Publisher, # kind of foreign key
'books': [Book], # 1-to-many
'has_book': bool,
'age': int,
'birthday': datetime.date,
'created_at': datetime.datetime,
}
default_values = { # optional
'has_book': False,
# don't worry about the timezone info!
# it's auto assigned as to UTC, so all you have to do is:
'created_at': datetime.datetime.utcnow,
}
required_fields = ( # optional
'slug',
'first_name',
'last_name',
'email',
)
Then use it as such;
from example.samples.author import Author, Gender from couchbasekit.fields import EmailField
douglas = Author() douglas.is_new_record True try: ... douglas.validate() ... except Author.StructureError as why: ... print why ... Key field 'slug' is defined but not provided.
douglas.slug = u'douglas_adams' try: ... douglas.validate() ... except Author.StructureError as why: ... print why ... Required field for 'first_name' is missing.
isinstance(douglas, dict) True douglas.update({ ... 'first_name': u'Douglas', ... 'last_name': u'Adams', ... 'gender': Gender('M'), ... 'email': EmailField('[email protected]'), ... }) ... douglas.validate() True douglas.save() 14379837794698 douglas.cas_value # CAS value (version) of the couchbase document 14379837794698 douglas.id u'douglas_adams' douglas.doc_id u'author_douglas_adams' douglas.birthday is None True douglas.non_exist_field Traceback (most recent call last): File "
", line 1, in File "couchbasekit/document.py", line 68, in getattr return super(Document, self).getattribute(item) AttributeError: 'Author' object has no attribute 'non_exist_field' dna = Author('douglas_adams') dna.is_new_record False douglas==dna True douglas.has_book = True douglas==dna False
because we set @register_view decorator, here are the CouchBase views:
douglas.view()
view = douglas.view('by_fullname') view view.results({'key': 'Douglas Adams'}) please refer to CouchBase views documentation for further usage..
and the bucket itself for advanced folks:
douglas.bucket
print [m for m in dir(douglas.bucket) if not m.startswith('_')] ['add', 'append', 'cas', 'decr', 'delete', 'design_docs', 'flush', 'gat', 'get', 'getl', 'incr', 'info', 'mc_client', 'name', 'password', 'prepend', 'replace', 'save', 'server', 'set', 'stats', 'touch', 'view'] nice!
Bumps requests from 0.14.2 to 2.20.0.
Sourced from requests's changelog.
2.20.0 (2018-10-18)
Bugfixes
- Content-Type header parsing is now case-insensitive (e.g. charset=utf8 v Charset=utf8).
- Fixed exception leak where certain redirect urls would raise uncaught urllib3 exceptions.
- Requests removes Authorization header from requests redirected from https to http on the same hostname. (CVE-2018-18074)
should_bypass_proxies
now handles URIs without hostnames (e.g. files).Dependencies
- Requests now supports urllib3 v1.24.
Deprecations
- Requests has officially stopped support for Python 2.6.
2.19.1 (2018-06-14)
Bugfixes
- Fixed issue where status_codes.py's
init
function failed trying to append to a__doc__
value ofNone
.2.19.0 (2018-06-12)
Improvements
- Warn user about possible slowdown when using cryptography version < 1.3.4
- Check for invalid host in proxy URL, before forwarding request to adapter.
- Fragments are now properly maintained across redirects. (RFC7231 7.1.2)
- Removed use of cgi module to expedite library load time.
- Added support for SHA-256 and SHA-512 digest auth algorithms.
- Minor performance improvement to
Request.content
.- Migrate to using collections.abc for 3.7 compatibility.
Bugfixes
- Parsing empty
Link
headers withparse_header_links()
no longer return one bogus entry.
... (truncated)
bd84045
v2.20.07fd9267
remove final remnants from 2.66ae8a21
Add myself to AUTHORS89ab030
Use comprehensions whenever possible2c6a842
Merge pull request #4827 from webmaven/patch-130be889
CVE URLs update: www sub-subdomain no longer valida6cd380
Merge pull request #4765 from requests/encapsulate_urllib3_excbbdbcc8
wrap url parsing exceptions from urllib3's PoolManagerff0c325
Merge pull request #4805 from jdufresne/httpsb0ad249
Prefer https:// for URLs throughout projectDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps ipython from 0.13.1 to 7.16.3.
Sourced from ipython's releases.
7.9.0
No release notes provided.
7.8.0
No release notes provided.
7.7.0
No release notes provided.
7.6.1
No release notes provided.
7.6.0
No release notes provided.
7.5.0
No release notes provided.
7.4.0
No release notes provided.
7.3.0
No release notes provided.
7.2.0
No release notes provided.
7.1.1
No release notes provided.
7.1.0
No release notes provided.
7.0.1
No release notes provided.
7.0.0
No release notes provided.
7.0.0-doc
No release notes provided.
7.0.0rc1
No release notes provided.
7.0.0b1
No release notes provided.
6.2.1
No release notes provided.
... (truncated)
d43c7c7
release 7.16.35fa1e40
Merge pull request from GHSA-pq7m-3gw7-gq5x8df8971
back to dev9f477b7
release 7.16.2138f266
bring back release helper from master branch5aa3634
Merge pull request #13341 from meeseeksmachine/auto-backport-of-pr-13335-on-7...bcae8e0
Backport PR #13335: What's new 7.16.28fcdcd3
Pin Jedi to <0.17.2.2486838
release 7.16.120bdc6f
fix conda buildDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps py-bcrypt from 0.2 to 0.3.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps pygments from 1.5 to 2.7.4.
Sourced from pygments's releases.
2.7.4
Updated lexers:
Fix infinite loop in SML lexer (#1625)
Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)
Limit recursion with nesting Ruby heredocs (#1638)
Fix a few inefficient regexes for guessing lexers
Fix the raw token lexer handling of Unicode (#1616)
Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!
Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)
Fix incorrect MATLAB example (#1582)
Thanks to Google's OSS-Fuzz project for finding many of these bugs.
2.7.3
... (truncated)
Sourced from pygments's changelog.
Version 2.7.4
(released January 12, 2021)
Updated lexers:
Fix infinite loop in SML lexer (#1625)
Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)
Limit recursion with nesting Ruby heredocs (#1638)
Fix a few inefficient regexes for guessing lexers
Fix the raw token lexer handling of Unicode (#1616)
Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!
Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)
Fix incorrect MATLAB example (#1582)
Thanks to Google's OSS-Fuzz project for finding many of these bugs.
Version 2.7.3
(released December 6, 2020)
... (truncated)
4d555d0
Bump version to 2.7.4.fc3b05d
Update CHANGES.ad21935
Revert "Added dracula theme style (#1636)"e411506
Prepare for 2.7.4 release.275e34d
doc: remove Perl 6 ref2e7e8c4
Fix several exponential/cubic complexity regexes found by Ben Caller/Doyenseceb39c43
xquery: fix pop from empty stack2738778
fix coding style in test_analyzer_lexer02e0f09
Added 'ERROR STOP' to fortran.py keywords. (#1665)c83fe48
support added for css variables (#1633)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps jinja2 from 2.6 to 2.11.3.
Sourced from jinja2's releases.
2.11.3
This contains a fix for a speed issue with the
urlize
filter.urlize
is likely to be called on untrusted user input. For certain inputs some of the regular expressions used to parse the text could take a very long time due to backtracking. As part of the fix, the email matching became slightly stricter. The various speedups apply tourlize
in general, not just the specific input cases.
- PyPI: https://pypi.org/project/Jinja2/2.11.3/
- Changes: https://jinja.palletsprojects.com/en/2.11.x/changelog/#version-2-11-3
2.11.2
2.11.1
This fixes an issue in async environment when indexing the result of an attribute lookup, like
{{ data.items[1:] }}
.2.11.0
- Changes: https://jinja.palletsprojects.com/en/2.11.x/changelog/#version-2-11-0
- Blog: https://palletsprojects.com/blog/jinja-2-11-0-released/
- Twitter: https://twitter.com/PalletsTeam/status/1221883554537230336
This is the last version to support Python 2.7 and 3.5. The next version will be Jinja 3.0 and will support Python 3.6 and newer.
2.10.3
2.10.2
2.10.1
- Changes: https://jinja.palletsprojects.com/en/2.10.x/changelog/#version-2-10-1
- Blog: https://palletsprojects.com/blog/jinja-2-10-1-released/
- Twitter: https://twitter.com/PalletsTeam/status/1114605127308992513
2.10
Primary changes
- A
NativeEnvironment
that renders Python types instead of strings. http://jinja.pocoo.org/docs/2.10/nativetypes/- A
namespace
object that works with{% set %}
. This replaces previous hacks for storing state across iterations or scopes. http://jinja.pocoo.org/docs/2.10/templates/#assignments- The
loop
object now hasnextitem
andprevitem
attributes, as well as achanged
method, for the common case of outputting something as a value in the loop changes. More complicated cases can use thenamespace
object. http://jinja.pocoo.org/docs/2.10/templates/#forInstall or upgrade
Install from PyPI with pip:
... (truncated)
Sourced from jinja2's changelog.
Version 2.11.3
Released 2021-01-31
- Improve the speed of the
urlize
filter by reducing regex backtracking. Email matching requires a word character at the start of the domain part, and only word characters in the TLD. :pr:1343
Version 2.11.2
Released 2020-04-13
- Fix a bug that caused callable objects with
__getattr__
, like :class:~unittest.mock.Mock
to be treated as a :func:contextfunction
. :issue:1145
- Update
wordcount
filter to trigger :class:Undefined
methods by wrapping the input in :func:soft_str
. :pr:1160
- Fix a hang when displaying tracebacks on Python 32-bit. :issue:
1162
- Showing an undefined error for an object that raises
AttributeError
on access doesn't cause a recursion error. :issue:1177
- Revert changes to :class:
~loaders.PackageLoader
from 2.10 which removed the dependency on setuptools and pkg_resources, and added limited support for namespace packages. The changes caused issues when using Pytest. Due to the difficulty in supporting Python 2 and :pep:451
simultaneously, the changes are reverted until 3.0. :pr:1182
- Fix line numbers in error messages when newlines are stripped. :pr:
1178
- The special
namespace()
assignment object in templates works in async environments. :issue:1180
- Fix whitespace being removed before tags in the middle of lines when
lstrip_blocks
is enabled. :issue:1138
- :class:
~nativetypes.NativeEnvironment
doesn't evaluate intermediate strings during rendering. This prevents early evaluation which could change the value of an expression. :issue:1186
Version 2.11.1
Released 2020-01-30
- Fix a bug that prevented looking up a key after an attribute (
{{ data.items[1:] }}
) in an async template. :issue:1141
... (truncated)
cf21539
release version 2.11.315ef8f0
Merge pull request #1343 from pallets/urlize-speedupef658dc
speed up urlize matchingeeca0fe
Merge pull request #1207 from mhansen/patch-12dd7691
Merge pull request #1209 from mhansen/patch-34892940
do_dictsort: update example ready to copy/paste7db7d33
api.rst: bugfix in docs, import PackageLoader9ec465b
fix changelog header737a4cd
release version 2.11.2179df6b
Merge pull request #1190 from pallets/native-evalDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.