Misc ================= .. py:data:: model.CmsHost :return: The string like "https://bellevue.tpsdb.com" for your church database. :rtype: str This is useful for producing links such as:: linktemplate='{2}' link = linktemplate.format(model.CmsHost, peopleid, name) .. py:data:: model.FromMorningBatch :return: True if this script is being called from the Batch Service. :rtype: bool .. py:data:: model.UserName :return: The username of the logged on user running the script. :rtype: str .. py:data:: model.Data :rtype: Dynamic Dictionary object, with keys as properties. This object is available whenever a Python Script is run. .. py:function:: model.CallScript(name) :return: the output of the script from all the ``print`` statements :rtype: str :param str name: The name of the Python Script Special Content .. py:function:: model.Content(name) :return: The content :rtype: str :param str name: The name of the Content file .. py:function:: model.DataHas(key) :return: True if Data has a property for the specified key :rtype: bool :param str key: The name of the key (case sensitive) Example:: Data.Test = "some words" if DataHas("Test"): print Data.Test .. py:function:: model.DynamicData() :return: a new DynamicData object :rtype: DynamicData This function returns a new DynamicData object that can be used in Python to hold data with name/value pairs. The easiest way to explain is by examples of what it can do. Try the following code:: dd = model.DynamicData() dd.value1 = "Value one" dd.value2 = 123 print '
'
        print dd
        print '
' When executed the following shows on the screen:: { "value1": "Value one", "value2": 123 } So you are able to store arbitrary values into a DynamicData object in a very simple manner. The output of the print statement presents a representation of the data in JSON format. Try this:: dd = model.DynamicData() dd.title = 'This is a demonstration of using multiple levels' dd.lev = model.DynamicData() dd.lev.str = "This is in the second level" dd.lev.num1 = 1 dd.lev.num2 = 2 print '
'
        print dd
        print 'The sum of num1 and num2 is:', dd.lev.num1 + dd.lev.num2
        print '
' When executed the following is printed to the screen:: { "title": "This is a demonstration of using multiple levels", "lev": { "str": "This is in the second level", "num1": 1, "num2": 2 } } The sum of num1 and num2 is: 3 Note that there are two assignments of a DynamicData object. The second assiment is to ``dd.lev``, a member of the first object. This way, nested heirarchys are simple and can hold complex and organized structures. Note how ``dd.lev.num1`` clearly shows the heirarchy from the first level (``dd``) to the second level (``lev``) through the dot notation (``.``). .. py:function:: model.FmtPhone(phone, *prefix) :return: The formatted phone number, e.g. 901-555-1212. :rtype: str :param str phone: The phone number to format. :param str prefix: \*Optional, Goes in front of the formatted number, e.g. `(c)` for cell phone. .. py:function:: model.FmtZip(zipcode) :return: The zip code formatted with "plus four" (e.g. 38018-2243 ) :rtype: str :param str zipcode: The zipcode number to format. .. py:function:: model.HtmlContent(name) :return: The body of the HTML content saved in Special Content > HTML under name. :rtype: str :param str name: The name of the content .. py:function:: model.SqlContent(name) :return: The SQL content saved in Special Content > SQL Scripts :rtype: str :param str name: The name of the script .. py:function:: model.TextContent(name) :return: The text saved in Special Content > Text Content :rtype: str :param str name: The name of the text file .. py:function:: model.TitleContent(name) :return: The title attribute of the content saved in Special Content under name. :rtype: str :param str name: The name of the content This is often used to store the Subject of an email represented by the content. .. py:function:: model.Replace(text, pattern, replacement) :return: The new string with all occurrences of pattern in text replaced with replacement. :rtype: str :param str text: The entire string to be modified. :param str pattern: The special text to be replaced. :param str replacement: The replacement text. .. py:function:: Markdown(text) :return: The rendered HTML text :rtype: str :param str text: The markdown text See https://www.markdownguide.org/ .. py:function:: RegexMatch(s, regex) :return: The matched text :rtype: str :param str s: the target string to be searched for a match :param str regex: the Regular Expression pattern to match on .. py:function:: RestGet(url, headers, *user, *password) :return: The content of the returned result :rtype: str :param str url: The fully qualified URL of the REST endpoint :param Dictionary headers: The data passed as headers (stored as a Python Dictionary object) :param str user: The optional user name :param str password: The optional password The user and password are passed as a Basic Authentication string The HTTP verb is GET. .. py:function:: RestPost(url, headers, obj, *user, *password) :return: The content of the returned result :rtype: str :param str url: The fully qualified URL of the REST endpoint :param Dictionary headers: The data passed as headers (stored as a Python Dictionary object) :param object obj: The body of the POST method :param str user: The optional user name :param str password: The optional password The user and password are passed as a Basic Authentication string The HTTP verb is POST. The obj will be converted to a string and passed to the REST POST endpoint. .. py:function:: RestPostJson(url, headers, obj, *user, *password) :return: The content of the returned result :rtype: str :param str url: The fully qualified URL of the REST endpoint :param Dictionary headers: The data passed as headers (stored as a Python Dictionary object) :param object obj: The body of the POST method :param str user: The optional user name :param str password: The optional password The user and password are passed as a Basic Authentication string The HTTP verb is POST. The body will be Serialized into a JSON string. .. py:function:: RestDelete(url, headers, *user, *password) :return: The content of the returned result :rtype: str :param str url: The fully qualified URL of the REST endpoint :param Dictionary headers: The data passed as headers (stored as a Python Dictionary object) :param str user: The optional user name :param str password: The optional password The user and password are passed as a Basic Authentication string The HTTP verb is DELETE .. py:function:: JsonDeserialize(jsontext) :return: The content of the returned result :rtype: dynamic :param str jsontext: The JSON text. .. py:function:: JsonDeserialize2(jsontext) :return: The content of the returned result :rtype: List of dynamic: A Python List of Python Dictionary objects :param str jsontext: The JSON text. This method is designed to deserialize an array of json objects. .. py:function:: JsonSerialize(obj) :return: The object converted into a JSON string :rtype: str :param object obj: The object to be converted .. py:function:: Setting(name, def) :return: The Setting value :rtype: str :param str name: The name of the Setting :param str def: The optional default value, an empty string if not passed .. py:function:: FormatJson(json) :return: The formatted json :rtype: str :param str json: The compressed json string to be formatted This adds indentation and newlines to a compressed json string making it easier to read. .. py:function:: FormatJson(data) :return: The formatted json :rtype: str :param dictionary data: The Python object that should be formatted as Json Works the same as previous except that you pass in a Python object instead of a json string. .. py:function:: Md5Hash(text) :return: A hashed string :rtype: str :param str text: The string to be hashed .. py:function:: CreateQueryTag(name, code) :return: The count of people in the target :rtype: int :param str name: The name of the QueryTag :param str code: The Search Builder code to be run This creates a special type of tag called QueryTag. It uses the same table that holds all other tags. But this type is only managed (created and deleted) with a Python script. If QueryTags will be used for multiple purposes, it is important to name the tags with a common prefix for a given purpose or project. This way it will be easy to delete a project's query tags to start over without disturbing other projects. .. py:function:: DeleteQueryTags(namelike) :param str namelike: The name of the QueryTag using % as wild card(s) .. py:function:: WriteContentSql(name, sql) :param str name: The name of the file :param str sql: The SQL code to be written This function writes Sql content to a Sql Script file in Special Content. If the file exists it will be overwritten. Otherwise, a new file is created. .. py:function:: WriteContentText(name, text) :param str name: The name of the file :param str text: The text to be written This function writes text to a Text file in Special Content. If the file exists it will be overwritten. Otherwise, a new file is created. .. py:function:: CsvReader(text) :return: an object to use for reading the csv file :rtype: CsvHelper.CsvReader :param str text: The text of the csv content Example:: csv = model.CsvReader(model.Data.file) while csv.Read(): Date = model.ParseDate(csv['Date']) Amount = csv['Amount'] .. py:function:: CsvReaderNoHeader(text) :return: an object to use for reading the csv file :rtype: CsvHelper.CsvReader :param str text: The text of the csv content Example:: csv = model.CsvReader(model.Data.file) while csv.Read(): Date = model.ParseDate(csv[0]) Amount = csv[1] .. py:function:: model.AppendIfBoth(s1, join, s2) :return: the resulting string :rtype: str :param str s1: the first string :param str join: the text to join between the two strings :param str s2: the second string If both s1 and s2 have values, the concatenation of s1 + join + s2 will be returned, otherwise just s1 is returned. .. py:function:: model.DynamicDataFromJson(json) :return: the DynamicData object :rtype: DynamicData :param str json: the string of JSON code Example:: json = ''' { "Member": { "RowType": "Member", "FamilyCnt": 2746, "RecurringCnt": 110, "MonthlyAmt": 76831.975 }, "NonMember": { "RowType": "NonMember", "FamilyCnt": 2887, "RecurringCnt": 20, "MonthlyAmt": 8372.175 }, "Combined": { "RowType": "Combined", "FamilyCnt": 5633, "RecurringCnt": 130, "MonthlyAmt": 85204.15 }, "Created": "3/11/19 3:51 PM" } ''' data = model.DynamicDataFromJson(json) print data.Created print data.NonMember.MonthlyAmt The two print statements will output the appropriate values. .. py:function:: model.CustomStatementsFundIdList(name) :return: the string with all fundids in a comma separated list. :rtype: str :param str name: the name of the FundList .. seealso:: :doc:`/Finance/CustomStatements` and :doc:`/CustomProgramming/TextScripts/CustomFundSets` .. py:function:: model.SpaceCamelCase(s) :return: the string with space separated words at each Capital letter. :rtype: str :param str s: the CamelCasedWords string to be expanded. .. py:function:: model.UserIsInRole(role) :return: True or False :rtype: bool :param str role: the role to check