Changeset - 2b8892f92b46
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2020-03-20 20:16:43
mads@kiilerich.com
docs: fix contributing.rst reference to Session.remove()

(Second to) last example of Session.remove was removed in 1a409593f352.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
docs/contributing.rst
Show inline comments
 
@@ -215,50 +215,50 @@ JavaScript must use ``;`` between/after 
 
multiline functions should be indented two levels -- one for the ``()`` and one for
 
``{}``.
 
Variables holding jQuery objects should be named with a leading ``$``.
 

	
 
Commit messages should have a leading short line summarizing the changes. For
 
bug fixes, put ``(Issue #123)`` at the end of this line.
 

	
 
Use American English grammar and spelling overall. Use `English title case`_ for
 
page titles, button labels, headers, and 'labels' for fields in forms.
 

	
 
.. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case
 

	
 
Template helpers (that is, everything in ``kallithea.lib.helpers``)
 
should only be referenced from templates. If you need to call a
 
helper from the Python code, consider moving the function somewhere
 
else (e.g. to the model).
 

	
 
Notes on the SQLAlchemy session
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Each HTTP request runs inside an independent SQLAlchemy session (as well
 
as in an independent database transaction). ``Session`` is the session manager
 
and factory. ``Session()`` will create a new session on-demand or return the
 
current session for the active thread. Many database operations are methods on
 
such session instances - only ``Session.remove()`` should be called directly on
 
the manager.
 
such session instances. The session will generally be removed by
 
TurboGears automatically.
 

	
 
Database model objects
 
(almost) always belong to a particular SQLAlchemy session, which means
 
that SQLAlchemy will ensure that they're kept in sync with the database
 
(but also means that they cannot be shared across requests).
 

	
 
Objects can be added to the session using ``Session().add``, but this is
 
rarely needed:
 

	
 
* When creating a database object by calling the constructor directly,
 
  it must explicitly be added to the session.
 

	
 
* When creating an object using a factory function (like
 
  ``create_repo``), the returned object has already (by convention)
 
  been added to the session, and should not be added again.
 

	
 
* When getting an object from the session (via ``Session().query`` or
 
  any of the utility functions that look up objects in the database),
 
  it's already part of the session, and should not be added again.
 
  SQLAlchemy monitors attribute modifications automatically for all
 
  objects it knows about and syncs them to the database.
 

	
 
SQLAlchemy also flushes changes to the database automatically; manually
 
calling ``Session().flush`` is usually only necessary when the Python
0 comments (0 inline, 0 general)