Package: visaplan.plone.tools
visaplan.plone.toolsGeneral tools modules forPlone.We don’t claim ultimate Plone wisdom (yet);
this package is one of the parts a big monolithic classic Zope product
was split into.It is part of the footing of the “Unitracc family” of Plone sites
which are maintained byvisaplan GmbH, Bochum, Germany.Some modules of this package might still contain some resources
(e.g. type names)
which are specific to our “Unitracc family” of sites;
this is likely to change in future releases.FeaturesThis add-on can be seen in action at the following sites:https://www.unitracc.dehttps://www.unitracc.comModules in version 1.1.4+:attoolsmoduleseveral tools for Archetypes-based contentbrainsmodulecurrently onemake_collectorfunction, e.g. for address fieldscfgmoduleRead “product” configuration, and detect development modecontextmoduleSeveral tools for processing the request.
Some need some modernization …formsmoduleSeveral tools for formsfunctionsmoduleSome functions, e.g.is_uid_shapedindexesmodule (new in v1.1.4)FunctiongetSortableTitlefor title conversion.This converts umlauts etc. to sort them
as equal to their corresponding base vocals,
according to German lexical usage.logmoduleAutomatically named loggersmockmodulea few small classes for use in docteststhe same module asvisaplan.tools.mockmock_cfgmoduleA rudimentary mock module forcfgsearchmoduleA few functions to support creation of ZODB catalog search queries
(quite proprietary, I’m afraid; might go away in future versions)setupmodule (since v1.1)Functions for use in migration scriptszcmlgenmodule (since v1.1.1)Generatesconfigure.zcmlfiles, ifchanges are detected, anddevelopment mode is active, andthe source is in an development package.decoratorsmodule (since v1.1.6)@returns_json:Wraps the function call and returns theJSON-encoded result,
including HTTP headers.Usessimplejsonif available.NOTto be used for functions which simply provideJSONdata for
insertion in page templates!Otherwise, the browser might try to parse your HTML page as JSON
and fail.DocumentationSorry, we don’t have real user documentation yet.Most functions are documented by doctests, anyway;
it helps to understand some German.InstallationSincevisaplan.plone.toolsis a package for Plone instances,
it is not normally installed usingpip;
instead, install it by adding it to your buildout:[buildout]
...

eggs =
    visaplan.plone.toolsand then runningbin/buildoutContributeIssue Tracker:https://github.com/visaplan/plone.tools/issuesSource Code:https://github.com/visaplan/plone.toolsSupportIf you are having issues, please let us know;
please use theissue trackermentioned above.LicenseThe project is licensed under the GPLv2.To DoBreaking changes:forms.tryagain_url:all options (which are all arguments except the request)
willneed tobe given by name
(which is possible andrecommended already).ContributorsTobias Herp,tobias.herp@visaplan.comChangelog1.4.18.1 (2023-05-03)Bugfixes:When checking the version of the visaplan.plone.search package,
compare correctly, followingPEP 440.Requirements:packaging[tobiasherp]1.4.18 (2023-05-02)Improvements:As we use the traditional indexgetExcludeFromNav, we import the
name of that index from visaplan.plone.search now, if available;The default is stillgetExcludeFromNav.Requirements:importlib_metadataIf we have visaplan.plone.search, we need 1.7+Hints:The default value for thegetExcludeFromNavindex name
will change in a future release.[tobiasherp]1.4.17 (2023-04-05)New features:function .attools.can_be_html(field)[tobiasherp]1.4.16 (2023-03-24)New features:New functionshort_hostnamein .functions[tobiasherp]1.4.15 (2023-03-08)Bugfixes:Py3K support fixes for.functions.is_uid_shaped.log.getLogSupportNew features:New (still tiny) module .seo for SEO support;
for now, focused on structured data.
Functions:parse_title, returning a dict[tobiasherp]1.4.14 (2022-04-22)Bugfixes:Missing imports fixed for.groups.is_member_of__factory.setup.get_default_idxs[tobiasherp]1.4.13 (2022-03-04)Bugfixes:Fixed a bug in .groups.groupinfo_factory(pretty);
for this to work, we need visaplan.plone.groups.Improvements:The label of the default logger of the@@stepdecorator
now includes the name of the worker, e.g.instanceorclientNew features:New.envmodule, providing theworker_name()[tobiasherp]1.4.12 (2022-02-15)Bugfixes:Fixed a bug in .groups.groupinfo_factory(pretty);
for this to work, we need visaplan.plone.groups.[tobiasherp]1.4.11 (2022-02-05)Bugfixes:Fixed a regression for .groups.groupinfo_factory[tobiasherp]1.4.10 (2022-02-03)Improvements:Converted the .groups module in a subpackageNew features:New optionmissing=Falsefor.groups.groupinfo_factoryIfTrue, the resulting function creates anexistingkey,
and for missing groups, thegroup_titleisNone;
otherwise, an empty dict is returned in such cases.[tobiasherp]1.4.9 (2021-12-13)Improvements:Ifcollective.metadataversionis installed, use the configured default set of
indexes (if noidxsexplicitly given but metadata recreation is requested)[tobiasherp]1.4.8 (2021-11-29)New features:New.setupfunctionload_and_cook, for use in GenericSetup upgrade steps[tobiasherp]1.4.7 (2021-11-17)Bugfixes:When detecting the currently active language (.context.getActiveLanguage[_unchecked]),
we now check for theI18N_LANGUAGEcookie first.[tobiasherp]1.4.6 (2021-10-28)Bugfixes:Fixed an error for the new functions in the.attoolsand.dxtoolsmodules
when giving the schema as positional argument
(which to use isn’t implemented yet for.dxtoolsanyway).[tobiasherp]1.4.5 (2021-10-27)(If using the new functions in the .axtools  module, please use release
1.4.6+ instead).Breaking changes:Removed the .metadata module which had been added in release 1.4.2;
we havecollective.metadataversionnow to replace it,
storing themetadata_versionvalue persistently in the registry.New features:New .attools functions:get_first_text_as_htmlget_all_textsgenerate_all_textsNew .dxtools module, containing the functions:get_first_text_as_htmlget_all_textsgenerate_all_textsProfile changes:Removed thedefaultprofile;
there is currently no point in installing this package as a Plone plugin.
Just add it to your required eggs, and import from the modules.We keep the theuninstallprofilefor now;it will be removed in an near-future version.So,don’t “install”this package (Quick-Installer, Plone add-ons);
just use it inPythoncode!We keep theconfigure.zcmlfile and the autoinclude entry point
for now, though;
we can imagine to use e.g. the Plone registry for some settings.[tobiasherp]1.4.4 (2021-08-31)Bugfixes:.setup.make_object_getter() didn’t update the Language index when the language was changedImprovements:.setup.make_object_getter() now additionally updates the following indexes
when the .title attribute is changed:sortable_titleSearchableTextgetEffectiveIndex[tobiasherp]1.4.3 (2021-08-27)New features:.searchmodule:New conversion utilities …make_querystring_mangle, a factory, to createmangleQueryString, usingmangle_umlautsMiscellaneous:normalizeQueryString(as well as the newmangleQueryString)now auto-inserts asterisks at word endsonly[tobiasherp]1.4.2 (2021-08-25)New utilities:.context.getActiveLanguage_unchecked: likegetActiveLanguage,
but not checking against the supported languages, and thus faster
(e.g. for cache key functions)Temporary changes:New.metadatamodule to support conditional metadata updates.Note:this is removed in release 1.4.5.
If you need themetadata_versionmetadata column, please usecollective.metadataversioninstead.[tobiasherp]1.4.1 (2021-06-30)Bugfixes:Bugfix for.setup.handle_subportalHints:visaplan.plone.search contains amake_input_textfunction
in it’s.utilsmodule
which re-implementsmake_inputwithout using BeautifulSoup.
This will probably replace our presentmake_inputfunction and then
disregard any keyword options which are currently passed on to theBeautifulSoupconstructor, i.e. thefactoryoption.Perhaps we’ll create a new visaplan.zope.tools package and move this
functionality there, though.[tobiasherp]1.4.0 (2021-03-26)Breaking changes:.setup.switch_menu_item…won’t change anything if theonargument isNonewon’t accept (other) non-boolean arguments foron,
unlessstrict=Falseis specified (new keyword-only argument)Improvements:Working doctests forsearchmodulezcmlgenconstructors supportskipoptionRequirements:visaplan.toolsv1.3.1+[tobiasherp]1.3.0 (2020-12-16)New Features:New modulegroupsNew.contextfunctionsgetMessenger(factory):creates amessagefunction which doesn’t require
(nor accept) acontextargumentgetPathget_parentparentsparent_brainsmake_brainGettermake_pathByUIDGettermake_translatorget_published_templateidgetSupportedLanguageTuplesNew functionsetup.safe_context_idNew functionsearch.normalizeQueryString(unicode, asterisks)POSKeyErrorrescue facility,for nowprovided here:Inspired by thefive.grok-based@@fix-blobsview by Mikko Ohtamaa,
we have two views:@@check-blobsscans the site object tree for
(Archetypes or Dexterity) objects with broken BLOB attachments
(images or files) and shows them in an HTML list with checkboxes;@@check-blobs-delete-selectedallows to delete the objects
found be be affected.Note:this functionality will likely be moved to a dedicated add-on package;
don’t rely on it to exist inanyother release of this package!Optional functionality, depending onvisaplan.plone.search v1.2.1+visaplan.plone.subportals(both currently not yet on PyPI)Improvements:setupmodule:If thereindexfunction, which was created by themake_reindexerfactory,
was given an object both bybrainand by itself, it compared those two by identity,
which wouldn’t ever match.  Now checking for equality.New functionclone_tree(from release 1.2.0) now works recursivelyWhenclone_treemoves objects from one folder to another, it tries to preserve a useful order;
both functions_clone_tree_innerand_move_objectsuse the new helperapply_move_order_optionsto inject asort_onkey into the query.contextmodule:messagefunction (non-generated; withcontextargument):The defaultmappingisNonenow.make_permissionCheckerdoesn’t require thecheckpermadapter any more to be usefulmake_userdetectordoesn’t require theauthadapter any more to be usefulWorking doctests forsearchmodulezcmlgenmodule:“Constructors” of the generator classes support an optionalskipargument
(keyword-only)Hard dependencies removed:Products.Archetypesif it is not installed, parts of the.attoolsmodule simply won’t workvisaplan.kitchenvisaplan.plone.infohubsIf not installed,.forms.form_changesrequiresaformargument
(but it is a stub anyway).[tobiasherp]1.2.0 (2020-05-13)New utilities:setupmodule:New functionclone_tree, usingfunction factorymake_object_getterandfunction factorymake_subfolder_creatorBoth factories have overlapping functionality and might become unified in a future version;
their initial purposes were:make_object_gettercreates a function (usually calledget_object)
which tries tofinda (possibly moved and/or renamed) object,
and then is able to apply a few changes;make_subfolder_creatorcreates a function (usually callednew_folder)
which creates a newfolder(unless already present),
and then is able to apply a few changes.[tobiasherp]1.1.6 (2019-11-27)New modules:decoratorsmodule:@returns_json(usessimplejsonif available)New utilities:contextmodule:function factorymake_timeformatterBugfixes:Typo in README corrected.[tobiasherp]1.1.5 (2019-07-18)Bugfixes:getConfigurationmight fail; in such cases, log a warning and use the defaultMissing requirements:visaplan.kitchen[tobiasherp]1.1.4 (2019-05-09)indexesmodule added:FunctiongetSortableTitlefor title conversion.This converts umlauts etc. to sort them
as equal to their corresponding base vocals,
according to German lexical usage.attoolsmodule:New functionnotifyedit(context)formsmodule:tryagain_urlfunction supportsvar_itemsargumentbugfix formake_inputfunction (suppression oftypeattribute)zcmlgenmodule:changes detection improved to explicitly ignore added/removed blank linescontextmodule:new functionsmessageandgetbrain,
as replacement for some adapters named alike[tobiasherp]1.1.3 (2019-01-29)setup.make_renamer(): generatedrenamefunction improved:
existing positional options default toNone; instead ofuid,o(object) orbraincan be specified (by name).setup.make_query_extractor(), generatedextract_queryfunction improved:
don’t convert aLanguagestring to a list if it’s value isallzcmlgenmodule:Bugfix for changes detectionIf changes are found but disallowed (non-development setup),
and ifsys.stdoutis connected to a terminal,
start the debugger[tobiasherp]1.1.2 (2018-11-21)Corrections for the documentation(currently) unused dependencies removed
[tobiasherp]1.1.1 (2018-09-27)zcmlgenmodule added:Generatesconfigure.zcmlfiles, ifchanges are detected (buggy; see v1.1.3), anddevelopment mode is active, andthe source is in a development package.1.1 (2018-09-17)attoolsmodule added:a brown bag of tools for Archetypesbrainsmodule added:make_collector, e.g. for address fieldsformsmodule added:a brown bag of modules to support forms in a Zope/Plone systemmockmodule added:a few small classes for use in docteststhe same module asvisaplan.tools.mockmock_cfgmodule added:accompaniescfg, for testing onlysearchmodule added:tools for creation of catalog queriessetupmodule added: functions for use in migration scriptsModule changes:contextmodule:new functiondecorated_toolfunctionsmodule:new functionlooksLikeAUID(for historical reasons)1.0 (2018-07-11)Initial release.
[tobiasherp]