Giter Club home page Giter Club logo

plone.registry's Introduction

Introduction

This package provides debconf-like (or about:config-like) settings registries for Zope applications. A registry, with a dict-like API, is used to get and set values stored in records. Each record contains the actual value, as well as a field that describes the record in more detail. At a minimum, the field contains information about the type of value allowed, as well as a short title describing the record's purpose.

plone.registry's People

Contributors

gforcada avatar mauritsvanrees avatar optilude avatar esteele avatar jensens avatar pre-commit-ci[bot] avatar lrowe avatar bloodbare avatar sneridagh avatar thet avatar tisto avatar pbauer avatar tomgross avatar matthewwilkes avatar davisagli avatar jean avatar mrtango avatar vangheem avatar garbas avatar seanupton avatar agitator avatar

Stargazers

 avatar

Watchers

David Bain avatar Dylan Jay avatar  avatar Mikko Ohtamaa avatar TsungWei Hu avatar Jesse Snyder avatar John S. De Stefano Jr avatar Rob Porter avatar Vincent Fretin avatar Rodrigo Ferreira de Souza avatar Christian Klinger avatar Mauro Amico avatar Leonardo J. Caballero G. avatar Silviu Bogan avatar Daniel Manchon avatar Robert Niederreiter avatar  avatar Ramiro Batista da Luz avatar Thiago Curvelo avatar Cleber J Santos avatar Takeshi Yamamoto avatar Brayton Osgood avatar Thomas Desvenain avatar Rudd-O avatar Gildardo Bautista avatar  avatar Felipi Macedo avatar Rudá Porto Filgueiras avatar ringobouya avatar Armin Stross-Radschinski avatar Cris Ewing avatar Davi Medeiros avatar Anatoly Bubenkov avatar trabby avatar Fulvio Casali avatar Eric BREHAULT avatar Zoltan Szabo avatar Takashi NAGAI avatar Manabu TERADA avatar Low Kian Seong avatar Joao S. O. Bueno avatar Bert Vanderbauwhede avatar Daniel Murray avatar Rizwan avatar Jean Ferri avatar andreasma avatar  avatar Georg Gogo. BERNHARD avatar Ken Wasetis avatar Wyn Williams avatar Rob Gietema avatar Ryan Foster avatar Roché Compaan avatar T. Kim Nguyen avatar Thomas Clement Mogensen avatar awello avatar James Cloos avatar  avatar Hans-Peter Locher avatar Ralph Jacobs avatar Charles Beebe avatar Chris Calloway avatar Mohammad Tareq Alam avatar Franklin Kingma avatar Carol Ganz avatar Juan Carlos Coruña avatar André Nogueira avatar Maik Röder avatar Corina Riba avatar Espen Moe-Nilssen avatar  avatar Laurent Lasudry avatar Tânia Andrea avatar tiazma avatar Harald Friessnegger avatar nilo avatar  avatar Derrick Stone avatar André NUYENS avatar DHietpas avatar Fazal Sulaiman avatar Jonathan Lewis avatar Max Jakob avatar  avatar Gauthier Bastien avatar Stefaner Benjamin avatar Luca avatar Lucas Aquino avatar  avatar Alice Tseng avatar Luca Pisani avatar Zoltan Benedek avatar Ian Anderson avatar Adam avatar Jason Craig avatar Julien Stegle avatar Lur Ibargutxi avatar Alex Button avatar Jess Henderson avatar  avatar

plone.registry's Issues

Make documentation (more) visible

The documentation is distributed in four .rst files and concatenated to the variable long_description
in setup.py (see below).

To make it easier to find the documentation put at least a link to those files. Better; generate docs.

long_description = (
    read('README.rst') +
    '\n' +
    read('plone', 'registry', 'registry.rst') +
    '\n' +
    read('plone', 'registry', 'events.rst') +
    '\n' +
    read('plone', 'registry', 'field.rst') +
    '\n' +
    read('CHANGES.rst') +
    '\n'
)

Endless recursion error in recordsproxy

@tomgross has already fixed this on master a few months ago, but I see the same on 1.0.x. I will make a pull request cherry picking his changes.

But maybe there is room for discussion: why/how does this happen? Strangely, I have seen it twice, both times in a site that uses collective.solr. And Tom has made a fix, and he is using collective.solr as well.

Here is the traceback:

Traceback (innermost last):

* Module ZPublisher.Publish, line 249, in publish_module_standard
* Module ZPublisher.Publish, line 191, in publish
* Module zope.event, line 31, in notify
* Module zope.component.event, line 24, in dispatch
* Module zope.component._api, line 136, in subscribers
* Module zope.component.registry, line 321, in subscribers
* Module zope.interface.adapter, line 585, in subscribers
* Module plone.transformchain.zpublisher, line 113, in applyTransformOnFailure
* Module plone.transformchain.zpublisher, line 85, in applyTransformOnSuccess
* Module plone.transformchain.zpublisher, line 60, in applyTransform
* Module zope.component._api, line 172, in queryUtility
* Module zope.component.registry, line 163, in queryUtility
* Module ZODB.Connection, line 860, in setstate
* Module ZODB.Connection, line 914, in _setstate
* Module ZODB.serialize, line 612, in setGhostState
* Module ZODB.serialize, line 605, in getState
* Module plone.registry.recordsproxy, line 35, in __getattr__
* Module plone.registry.recordsproxy, line 35, in __getattr__
* Module plone.registry.recordsproxy, line 35, in __getattr__
* Module plone.registry.recordsproxy, line 35, in __getattr__
           -------
* Module plone.registry.recordsproxy, line 35, in __getattr__
RuntimeError: maximum recursion depth exceeded while calling a Python object

During the Solr training in Boston we saw it, using Plone 5.0. See this collective.loremipsum issue.
I now see it in a client website on Plone 4.3. This also uses collective.solr (6.0a1).

@tomgross: Were your fixes (#11 and #12) made to fix that problem we found during the Solr training?
Did you ever find out the root cause?

Locally (well, on the laptop of colleague @fredvd) I see that it goes wrong while loading the local component registry of the Plone site, which tries to load the registry, and fails when loading an instance of RecordsProxy. I couldn't figure out which record it exactly is. But its __dict__ is an empty dictionary, just like it apparently is in old-style classes.

Empty string prefix is added as "."

when registering or using registry records from an interface with prefix='' plone.registry.registry.forInterface and plone.registry.registry.forInterface add a dot . as prefix (see below).

The conditional not prefix.endswith(".") should be extended with and prefix != ""

i.e. if not prefix.endswith(".") and prefix != "":

    def forInterface(self, interface, check=True, omit=(), prefix=None,
                     factory=None):
        if prefix is None:
            prefix = interface.__identifier__

        if not prefix.endswith("."):    # <- if not prefix.endswith(".") and prefix != "":
            prefix += '.'

    ...

    def registerInterface(self, interface, omit=(), prefix=None):
        if prefix is None:
            prefix = interface.__identifier__

        if not prefix.endswith("."):    # <- if not prefix.endswith(".") and prefix != "":
            prefix += '.'
    ...

Custom validator will prevent records from being reimported

Steps to reproduce:

  1. Create a control panel following instructions from https://pypi.org/project/plone.app.registry/#creating-a-custom-control-panel
  2. Add a validator for a field as explained in https://docs.plone.org/develop/addons/schema-driven-forms/customising-form-behaviour/validation.html#field-widget-validators
  3. Add initial values for that same field in registry.xml
  4. Install the product

You will see a traceback like this:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFPlone.controlpanel.browser.quickinstaller, line 213, in __call__
  Module <string>, line 3, in installProducts
  Module AccessControl.requestmethod, line 70, in _curried
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 686, in installProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 602, in installProduct
  Module Products.GenericSetup.tool, line 388, in runAllImportStepsFromProfile
  Module Products.GenericSetup.tool, line 1433, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1245, in _doRunImportStep
  Module plone.app.registry.exportimport.handler, line 70, in importRegistry
  Module plone.app.registry.exportimport.handler, line 116, in importDocument
  Module plone.app.registry.exportimport.handler, line 324, in importRecord
  Module plone.registry.record, line 34, in __init__
ValueError: Field is not persistent

If the product was installed and the validator is added afterwards, when you try to reimport the registry.xml the traceback looks like this:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.GenericSetup.tool, line 559, in manage_importSelectedSteps
  Module Products.GenericSetup.tool, line 358, in runImportStepFromProfile
  Module Products.GenericSetup.tool, line 1245, in _doRunImportStep
  Module plone.app.registry.exportimport.handler, line 70, in importRegistry
  Module plone.app.registry.exportimport.handler, line 116, in importDocument
  Module plone.app.registry.exportimport.handler, line 282, in importRecord
  Module plone.registry.record, line 60, in _set_field
  Module plone.registry.registry, line 283, in _setField
ValueError: The record's field must be an IPersistentField.

This is what happens in collective/collective.z3cform.datagridfield#14

As I explain in my comment (collective/collective.z3cform.datagridfield#14 (comment)), I found that when the persistent field is created, the __provides__ attribute would be overridden. This only happens when the field has a custom validator defined.

In order to fix it, I have added the __provides__ to the list of ignored attributes by adding to my __init.py__:

from plone.registry.field import DisallowedProperty
DisallowedProperty('__provides__')

I found that the vocabulary attribute is already ignored in

DisallowedProperty.uses.append('vocabulary')

should I add the __provides__ here as well as a solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.