Skip to main content
QuickBean is a library that reduces the boilerplate code required to define beans.

Installation
============

Here is how to install QuickBean : ::

pip install quickbean

Starting with QuickBean
=======================

Suppose you have defined the following bean :

.. code:: python

>>> class MyObject(object):
>>> def __init__(self, my_property, my_other_property):
>>> self.my_property = my_property
>>> self.my_other_property = my_other_property

If you would like your bean to have a human-readable representation, you have to override the *__repr__* method :

.. code:: python

>>> class MyObject(object):
>>> def __init__(self, my_property, my_other_property):
>>> self.my_property = my_property
>>> self.my_other_property = my_other_property
>>>
>>> def __repr__(self):
>>> return 'MyObject(my_property=%s, my_other_property=%s)' % (self.my_property, self.my_other_property)

If you would like your bean to be equality comparable, you also have to override the *__eq__* and *__ne__* methods :

.. code:: python

>>> class MyObject(object):
>>> def __init__(self, my_property, my_other_property):
>>> self.my_property = my_property
>>> self.my_other_property = my_other_property
>>>
>>> def __repr__(self):
>>> return 'MyObject(my_property=%s, my_other_property=%s)' % (self.my_property, self.my_other_property)
>>>
>>> def __eq__(self, other):
>>> return other.__class__ is MyObject and other.__dict__ == self.__dict__
>>>
>>> def __ne__(self, other):
>>> return not self.__eq__(other)

Although there is nothing difficult here, it would be better if this boilerplate code could be automatically generated
for you. This is exactly what QuickBean brings to you :

.. code:: python

>>> import quickbean
>>>
>>> @quickbean.AutoBean
>>> class MyObject(object):
>>> def __init__(self, my_property, my_other_property):
>>> self.my_property = my_property
>>> self.my_other_property = my_other_property

You may even let QuickBean generate the *__init__* method for you :

.. code:: python

>>> import quickbean
>>>
>>> @quickbean.AutoInit('my_property', 'my_other_property')
>>> @quickbean.AutoBean
>>> class MyObject(object):
>>> pass

Documentation
=============

See the `online documentation`_ for more information on how to use QuickBean.

.. _`online documentation`: http://quickbean.readthedocs.org/en/latest/

Changelog
=========

QuickBean 1.2
-------------

**This release breaks compatibility with QuickBean 1.1.** See below for more information.

Here are the changes from QuickBean 1.1 :

- Changing how the *AutoInitFromJson*, *AutoBean*, *AutoEq*, *AutoRepr* and *AutoToJson* decorators are applied to
beans' classes (**breaks compatibility**).
- The decorators now modify beans' classes themselves instead of decorating them.
- Renaming all the *to_json* methods -including suffixed ones- to *to_json_str* (**breaks compatibility**).
- Ability to handle JSON with dictionaries instead of strings.

QuickBean 1.1
-------------

**This release breaks compatibility with QuickBean 1.0.** See below for more information.

Here are the changes from QuickBean 1.0 :

- Renaming the *AutoJson* decorator to *AutoToJson* (**breaks compatibility**).
- Implementation of the *AutoInitFromJson* decorator.
- Ability to define custom JSON types to encode and decode properties.
- Making the *_to_json* conversion method consistent with JSON types (**breaks compatibility**).

QuickBean 1.0
-------------

First release of QuickBean.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

QuickBean-1.2.0.tar.gz (20.5 kB view details)

Uploaded Source

File details

Details for the file QuickBean-1.2.0.tar.gz.

File metadata

  • Download URL: QuickBean-1.2.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for QuickBean-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ed9c007fa4d1f31a5de851beab07da00f18206f7f77fd6a4055617aec375ef66
MD5 bc63154dd67996609b9da64099765990
BLAKE2b-256 b09648d52cf4488a380aa3421fc1ae58c15b9a3ecc10817b8745aae8ce9b932b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page