core
¶
iii
iii
iii
vvv iii uu uu rrrrrrrr
vvvv iii uu uu rr rr
v vvvv iii uu uu rr rr vv vvvv iii uu uu rr rrrrr
- vvvv vvvv iii uu uu rr rrr
- vvv vvvv iii uu uu rr rrr
- vvvvvv iii uu uu rr rrr
vvvv iii uuuuuu rr rrr
I N F O R M A T I O N S Y S T E M
viur-core Copyright © 2012-2024 by Mausbrand Informationssysteme GmbH
ViUR is a free software development framework for the Google App Engine™. More about ViUR can be found at https://www.viur.dev.
Licensed under the GNU Lesser General Public License, version 3. See file LICENSE for more information.
Subpackages¶
core.bones
core.bones.base
core.bones.boolean
core.bones.captcha
core.bones.color
core.bones.credential
core.bones.date
core.bones.email
core.bones.file
core.bones.json
core.bones.key
core.bones.numeric
core.bones.password
core.bones.randomslice
core.bones.raw
core.bones.record
core.bones.relational
core.bones.select
core.bones.selectcountry
core.bones.sortindex
core.bones.spatial
core.bones.string
core.bones.text
core.bones.treeleaf
core.bones.treenode
core.bones.user
core.languages
core.modules
core.prototypes
core.render
core.utils
Submodules¶
Package Contents¶
Classes¶
Translate class which chooses the correct translation according to the request language |
|
Simple Query-Iter to delete all entities encountered. |
|
BaseClass to run a database Query and process each entry matched. |
Functions¶
|
Decorator to call a function periodic during maintenance. |
|
Functions decorated with this are called shortly at instance startup. |
|
Deprecated version of CallDeferred |
|
Wrapper for deferred tasks to limit the amount of retries |
|
Sets the default language used by ViUR to lang. |
|
If conf.i18n.language_method is set to "domain", this function allows setting the map of which domain |
|
Define whats going to be served by this instance. |
- class core.translate(key, defaultText=None, hint=None, force_lang=None)¶
Translate class which chooses the correct translation according to the request language
This class is the replacement for the old translate() function provided by ViUR2. This classes __init__ takes the unique translation key (a string usually something like “user.auth_user_password.loginfailed” which uniquely defines this text fragment), a default text that will be used if no translation for this key has been added yet (in the projects default language) and a hint (an optional text that can convey context information for the persons translating these texts - they are not shown to the end-user). This class will resolve its translations upfront, so the actual resolving (by casting this class to string) is fast. This resolves most translation issues with bones, which can now take an instance of this class as it’s description/hints.
- Parameters:
key (str) – The unique key defining this text fragment. Usually it’s a path/filename and a unique descriptor in that file
defaultText (str) –
The text to use if no translation has been added yet. While optional, it’s recommended to set this, as the key is used
instead if neither are available.
hint (str) – A text only shown to the person translating this text, as the key/defaultText may have different meanings in the target language.
force_lang (str) – Use this language instead the one of the request.
- __slots__ = ['key', 'defaultText', 'hint', 'translationCache', 'force_lang']¶
- __repr__()¶
Return repr(self).
- Return type:
str
- __str__()¶
Return str(self).
- Return type:
str
- translate(**kwargs)¶
Substitute the given kwargs in the translated or default text.
- Return type:
str
- __call__(**kwargs)¶
Just an alias for translate
- static substitute_vars(value, **kwargs)¶
Substitute vars in a translation
Variables has to start with two braces ({{), followed by the variable name and end with two braces (}}). Values can be anything, they are cast to string anyway. “Hello {{name}}!” becomes with name=”Bob”: “Hello Bob!”
- Parameters:
value (str) –
- static merge_alias(translations)¶
Make sure each aliased language has a value
If an aliased language does not have a value in the translation dict, the value of the main language is copied.
- Parameters:
translations (dict[str, str]) –
- class core.DeleteEntitiesIter¶
Bases:
QueryIter
Simple Query-Iter to delete all entities encountered.
- ..Warning: When iterating over skeletons, make sure that the
query was created using Skeleton().all(). This way the Skeleton.delete() method can be used and the appropriate post-processing can be done.
- classmethod handleEntry(entry, customData)¶
Overridable hook to process one entry. “entry” will be either an db.Entity or an SkeletonInstance (if that query has been created by skel.all())
Warning: If your query has an sortOrder other than __key__ and you modify that property here it is possible to encounter that object later one again (as it may jump behind the current cursor).
- core.PeriodicTask(interval=0, cronName='default')¶
Decorator to call a function periodic during maintenance. Interval defines a lower bound for the call-frequency for this task; it will not be called faster than each interval minutes. (Note that the actual delay between two sequent might be much larger)
- Parameters:
interval (int) – Call at most every interval minutes. 0 means call as often as possible.
cronName (str) –
- Return type:
Callable
- class core.QueryIter¶
Bases:
object
BaseClass to run a database Query and process each entry matched. This will run each step deferred, so it is possible to process an arbitrary number of entries without being limited by time or memory.
To use this class create a subclass, override the classmethods handleEntry and handleFinish and then call startIterOnQuery with an instance of a database Query (and possible some custom data to pass along)
- queueName = 'default'¶
- classmethod startIterOnQuery(query, customData=None)¶
Starts iterating the given query on this class. Will return immediately, the first batch will already run deferred.
Warning: Any custom data must be json-serializable and must be passed in customData. You cannot store any data on this class as each chunk may run on a different instance!
- Parameters:
query (viur.core.db.Query) –
customData (Any) –
- Return type:
None
- classmethod _requeueStep(qryDict)¶
Internal use only. Pushes a new step defined in qryDict to either the taskqueue or append it to the current request if we are on the local development server.
- Parameters:
qryDict (dict[str, Any]) –
- Return type:
None
- classmethod _qryStep(qryDict)¶
Internal use only. Processes one block of five entries from the query defined in qryDict and reschedules the next block.
- Parameters:
qryDict (dict[str, Any]) –
- Return type:
None
- classmethod handleEntry(entry, customData)¶
Overridable hook to process one entry. “entry” will be either an db.Entity or an SkeletonInstance (if that query has been created by skel.all())
Warning: If your query has an sortOrder other than __key__ and you modify that property here it is possible to encounter that object later one again (as it may jump behind the current cursor).
- classmethod handleFinish(totalCount, customData)¶
Overridable hook that indicates the current run has been finished.
- Parameters:
totalCount (int) –
- classmethod handleError(entry, customData, exception)¶
Handle a error occurred in handleEntry. If this function returns True, the queryIter continues, otherwise it breaks and prints the current cursor.
- Return type:
bool
- core.StartupTask(fn)¶
Functions decorated with this are called shortly at instance startup. It’s not guaranteed that they actually run on the instance that just started up! Wrapped functions must not take any arguments.
- Parameters:
fn (Callable) –
- Return type:
Callable
- core.callDeferred(func)¶
Deprecated version of CallDeferred
- core.retry_n_times(retries, email_recipients=None, tpl=None)¶
Wrapper for deferred tasks to limit the amount of retries
- Parameters:
retries (int) – Number of maximum allowed retries
email_recipients (None | str | list[str]) – Email addresses to which a info should be sent when the retry limit is reached.
tpl (None | str) – Instead of the standard text, a custom template can be used. The name of an email template must be specified.
- Return type:
Callable
- core.setDefaultLanguage(lang)¶
Sets the default language used by ViUR to lang.
- Parameters:
lang (str) – Name of the language module to use by default.
- core.setDefaultDomainLanguage(domain, lang)¶
If conf.i18n.language_method is set to “domain”, this function allows setting the map of which domain should use which language. :param domain: The domain for which the language should be set :param lang: The language to use (in ISO2 format, e.g. “DE”)
- Parameters:
domain (str) –
lang (str) –
- core.setup(modules, render=None, default='html')¶
Define whats going to be served by this instance.
- Parameters:
modules (types.ModuleType | object) – Usually the module provided as modules directory within the application.
render (types.ModuleType | object) – Usually the module viur.core.renders, or a dictionary renderName => renderClass.
default (str) – Name of the renderer, which will form the root of the application. This will be the renderer, which wont get a prefix, usually html. (=> /user instead of /html/user)