core.db.utils ============= .. py:module:: core.db.utils Functions --------- .. autoapisummary:: core.db.utils.fix_unindexable_properties core.db.utils.normalize_key core.db.utils.normalizeKey core.db.utils.key_helper core.db.utils.keyHelper core.db.utils.is_in_transaction core.db.utils.IsInTransaction core.db.utils.get_or_insert core.db.utils.GetOrInsert core.db.utils.encodeKey core.db.utils.acquire_transaction_success_marker core.db.utils.start_data_access_log core.db.utils.startDataAccessLog core.db.utils.end_data_access_log core.db.utils.endDataAccessLog Module Contents --------------- .. py:function:: fix_unindexable_properties(entry) Recursively walk the given Entity and add all properties to the list of unindexed properties if they contain a string longer than 1500 bytes (which is maximum size of a string that can be indexed). The datastore would return an error otherwise. https://cloud.google.com/datastore/docs/concepts/limits?hl=en#limits :param entry: The entity to fix (inplace) :return: The fixed entity .. py:function:: normalize_key(key) Normalizes a datastore key (replacing _application with the current one) :param key: Key to be normalized. :return: Normalized key in string representation. .. py:function:: normalizeKey(key) .. py:function:: key_helper(in_key, target_kind, additional_allowed_kinds = (), adjust_kind = False) .. py:function:: keyHelper(inKey, targetKind, additionalAllowedKinds = (), adjust_kind = False) .. py:function:: is_in_transaction() .. py:function:: IsInTransaction() .. py:function:: get_or_insert(key, **kwargs) Either creates a new entity with the given key, or returns the existing one. Its guaranteed that there is no race-condition here; it will never overwrite a previously created entity. Extra keyword arguments passed to this function will be used to populate the entity if it has to be created; otherwise they are ignored. :param key: The key which will be fetched or created. :returns: Returns the fetched or newly created Entity. .. py:function:: GetOrInsert(key, **kwargs) .. py:function:: encodeKey(key) Return the given key encoded as string (mimicking the old str() behaviour of keys) .. py:function:: acquire_transaction_success_marker() Generates a token that will be written to the datastore (under "viur-transactionmarker") if the transaction completes successfully. Currently only used by deferredTasks to check if the task should actually execute or if the transaction it was created in failed. :return: Name of the entry in viur-transactionmarker .. py:function:: start_data_access_log() Clears our internal access log (which keeps track of which entries have been accessed in the current request). The old set of accessed entries is returned so that it can be restored with :func:`server.db.popAccessData` in case of nested caching. You must call popAccessData afterwards, otherwise we'll continue to log all entries accessed in subsequent request on the same thread! :return: t.Set of old accessed entries .. py:function:: startDataAccessLog() .. py:function:: end_data_access_log(outer_access_log = None) Retrieves the set of entries accessed so far. To clean up and restart the log, call :func:`viur.datastore.startAccessDataLog`. If you called :func:`server.db.startAccessDataLog` before, you can re-apply the old log using the outerAccessLog param. Otherwise, it will disable the access log. :param outerAccessLog: State of your log returned by :func:`server.db.startAccessDataLog` :return: t.Set of entries accessed .. py:function:: endDataAccessLog(outerAccessLog = None)