Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe hide field-level tagged values with patched Field methods #200

Open
drmalex07 opened this issue Nov 18, 2015 · 0 comments
Open

Maybe hide field-level tagged values with patched Field methods #200

drmalex07 opened this issue Nov 18, 2015 · 0 comments

Comments

@drmalex07
Copy link
Member

We support several field-level tags (at schema definition), but is both error-prone and difficult to document all these options as tags. Maybe hide them under patched Field methods, so that they are documented as "extended" Field methods.

E.g:

class TagDefinition(object):

    class Tag(object):

        def __init__(self, field):
            self.field = field

        # Provide methods for actual configuration         

        def link_to(self, name):
            self.field.setTaggedValue('links-to', name)

        def format(self, name, opts):
             self.field.setTaggedValue('format:%s' % name, opts) 

    def __init__(self): pass

    def __get__(self, field, fieldtype=None):
        return self.Tag(field)

    def __set__(self, field, value):
        raise AttributeError('Not meant to be set')

# Patch with a config descriptor: Let the monkeys go wild
Field.config = TagDefinition()
class IFoo(Interface):
    # Tag actual fields
    abstract = zope.schema.Text(title=u'Abstract')
    abstract.config.link_to("notes")
    abstract.config.format("markup", {'descend': False})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant