doc/api/predicates.rst
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 06 Aug 2019 14:26:17 +0200
branch3.26
changeset 12719 9fb4a71f119d
parent 10499 d0907690af55
child 12792 e2cdb1be6bd9
permissions -rw-r--r--
[py3] Pass bytes as "msg" to smtplib.SMTP.sendmail() When passing a unicode string to smtplib.SMTP.sendmail() as "msg" argument, there is an implicit bytes encoding using "ascii" encoding in python3. Of course this does not work if the string contains non-ASCII characters. In fact, config's sendmails method intent to pass bytes to smtplib.SMTP.sendmail() as it uses msg.as_string() method. Unfortunately, in python3, this method returns a unicode string whereas it returns a bytes string in python2; we thus fix this by calling as_bytes() method on python3. As there is no "as_bytes" method in python2, we need to handle python2 compatibility by hand and either call as_string() or as_bytes(). In testlib, where we mock smtplib.SMTP, we need to keep the "msg" argument of Email class (defined in testlib as well) a unicode string. Otherwise, it fails to be parsed by email.message_from_string() (from stdlib) if it is bytes on python3.

.. _predicates_module:

:mod:`cubicweb.predicates`
==========================

.. automodule:: cubicweb.predicates

   .. autoclass:: cubicweb.appobject.yes
   .. autoclass:: cubicweb.predicates.match_kwargs
   .. autoclass:: cubicweb.predicates.appobject_selectable
   .. autoclass:: cubicweb.predicates.adaptable
   .. autoclass:: cubicweb.predicates.configuration_values
   
   .. autoclass:: cubicweb.predicates.none_rset
   .. autoclass:: cubicweb.predicates.any_rset
   .. autoclass:: cubicweb.predicates.nonempty_rset
   .. autoclass:: cubicweb.predicates.empty_rset
   .. autoclass:: cubicweb.predicates.one_line_rset
   .. autoclass:: cubicweb.predicates.multi_lines_rset
   .. autoclass:: cubicweb.predicates.multi_columns_rset
   .. autoclass:: cubicweb.predicates.paginated_rset
   .. autoclass:: cubicweb.predicates.sorted_rset
   .. autoclass:: cubicweb.predicates.one_etype_rset
   .. autoclass:: cubicweb.predicates.multi_etypes_rset
   
   .. autoclass:: cubicweb.predicates.non_final_entity
   .. autoclass:: cubicweb.predicates.is_instance
   .. autoclass:: cubicweb.predicates.score_entity
   .. autoclass:: cubicweb.predicates.rql_condition
   .. autoclass:: cubicweb.predicates.relation_possible
   .. autoclass:: cubicweb.predicates.partial_relation_possible
   .. autoclass:: cubicweb.predicates.has_related_entities
   .. autoclass:: cubicweb.predicates.partial_has_related_entities
   .. autoclass:: cubicweb.predicates.has_permission
   .. autoclass:: cubicweb.predicates.has_add_permission
   .. autoclass:: cubicweb.predicates.has_mimetype
   .. autoclass:: cubicweb.predicates.is_in_state
   .. autofunction:: cubicweb.predicates.on_fire_transition
   
   .. autoclass:: cubicweb.predicates.match_user_groups
   
   .. autoclass:: cubicweb.predicates.no_cnx
   .. autoclass:: cubicweb.predicates.anonymous_user
   .. autoclass:: cubicweb.predicates.authenticated_user
   .. autoclass:: cubicweb.predicates.match_form_params
   .. autoclass:: cubicweb.predicates.match_search_state
   .. autoclass:: cubicweb.predicates.match_context_prop
   .. autoclass:: cubicweb.predicates.match_context
   .. autoclass:: cubicweb.predicates.match_view
   .. autoclass:: cubicweb.predicates.primary_view
   .. autoclass:: cubicweb.predicates.contextual
   .. autoclass:: cubicweb.predicates.specified_etype_implements
   .. autoclass:: cubicweb.predicates.attribute_edited
   .. autoclass:: cubicweb.predicates.match_transition
   
   .. autoclass:: cubicweb.predicates.match_exception
   .. autoclass:: cubicweb.predicates.debug_mode