Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit af07c04

Browse files
committed
Add warning to document CM documentation.
1 parent 467dff2 commit af07c04

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
2222
#sys.path.insert(0, os.path.abspath('.'))
2323

24+
sys.path.insert(0, os.path.abspath('../src'))
25+
2426
# -- General configuration ------------------------------------------------
2527

2628
# If your documentation needs a minimal Sphinx version, state it here.

docs/getting_started.rst

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -441,41 +441,45 @@ multiple updates to a single document. Note that we don't save to the server
441441
after each update. We only save once to the server upon exiting the ``Document``
442442
context manager.
443443

444-
.. code-block:: python
444+
.. warning:: Uncaught exceptions inside the ``with`` block will prevent your
445+
document changes being saved to the remote server. However, changes
446+
will still be applied to your local document object.
445447

446-
from cloudant import cloudant
447-
from cloudant.document import Document
448+
.. code-block:: python
448449
449-
with cloudant(USERNAME, PASSWORD, account=ACCOUNT_NAME) as client:
450+
from cloudant import cloudant
451+
from cloudant.document import Document
450452
451-
my_database = client.create_database('my_database')
453+
with cloudant(USERNAME, PASSWORD, account=ACCOUNT_NAME) as client:
452454
453-
# Upon entry into the document context, fetches the document from the
454-
# remote database, if it exists. Upon exit from the context, saves the
455-
# document to the remote database with changes made within the context
456-
# or creates a new document.
457-
with Document(database, 'julia006') as document:
458-
# If document exists, it's fetched from the remote database
459-
# Changes are made locally
460-
document['name'] = 'Julia'
461-
document['age'] = 6
462-
# The document is saved to the remote database
463-
464-
# Display a Document
465-
print(my_database['julia30'])
466-
467-
# Delete the database
468-
client.delete_database('my_database')
455+
my_database = client.create_database('my_database')
469456
470-
print('Databases: {0}'.format(client.all_dbs()))
457+
# Upon entry into the document context, fetches the document from the
458+
# remote database, if it exists. Upon exit from the context, saves the
459+
# document to the remote database with changes made within the context
460+
# or creates a new document.
461+
with Document(database, 'julia006') as document:
462+
# If document exists, it's fetched from the remote database
463+
# Changes are made locally
464+
document['name'] = 'Julia'
465+
document['age'] = 6
466+
# The document is saved to the remote database
467+
468+
# Display a Document
469+
print(my_database['julia30'])
470+
471+
# Delete the database
472+
client.delete_database('my_database')
473+
474+
print('Databases: {0}'.format(client.all_dbs()))
471475
472476
Always use the ``_deleted`` document property to delete a document from within
473477
a ``Document`` context manager. For example:
474478

475-
.. code-block:: python
479+
.. code-block:: python
476480
477-
with Document(my_database, 'julia30') as doc:
478-
doc['_deleted'] = True
481+
with Document(my_database, 'julia30') as doc:
482+
doc['_deleted'] = True
479483
480484
*You can also delete non underscore prefixed document keys to reduce the size of the request.*
481485

0 commit comments

Comments
 (0)