def _create_property(field_name, docstring,
                     read_only=False, closed_only=False):

    def getter(self):
        if closed_only and not self._closed:
            raise AttributeError(
                "TxMongo: can only get {0} on a closed file.".format(repr(field_name)))
        return self._file.get(field_name, None)

    def setter(self, value):
        if self._closed:
            raise AttributeError(
                "TxMongo: cannot set {0} on a closed file.".format(repr(field_name)))
        self._file[field_name] = value

    if read_only:
        docstring += "\n\nThis attribute is read-only."
    elif not closed_only:
        docstring = "%s\n\n%s" % (docstring, "This attribute can only be "
                                             "set before :meth:`close` has been called.")
    else:
        docstring = "%s\n\n%s" % (docstring, "This attribute is read-only and "
                                             "can only be read after :meth:`close` "
                                             "has been called.")

    if not read_only and not closed_only:
        return property(getter, setter, doc=docstring)
    return property(getter, doc=docstring)
Basic data instances.
dataset/ETHPy150Open twisted/txmongo/txmongo/_gridfs/grid_file.py/_create_property--crossover with--dataset/ETHPy150Open renatopp/liac-arff/tests/test_data.py/TestLODData.test_conversor