Coder Social home page Coder Social logo

plone.supermodel's Introduction

Introduction

https://secure.travis-ci.org/pyrenees/plone.supermodel.png

plone.supermodel provides XML import and export for schema interfaces based on zope.schema fields. The principal use cases are:

1. Define a schema interface in code based on an XML file. This can be done with syntax like:

>>> from plone.supermodel import xmlSchema
>>> IMySchema = xmlSchema("myschema.xml")

2. Save and load interface definitions via an XML format. To turn a schema interface into XML, you can do:

>>> from plone.supermodel import serializeSchema
>>> xml_string = serializeSchema(IMySchema)

To get a schema from an XML file, you can use the xmlSchema() function above, or you can use the more powerful spec() function, which turns a dict of all schemata and widget hints in a given XML file.

See schema.txt and interfaces.py in the source code for more information, including details on how to give widget hints for forms and how to keep multiple schemata in the same XML file.

Supermodel vs. Userschema

This package is quite similar to Tres Seaver's "userschema" library, which can be found at http://agendaless.com/Members/tseaver/software/userschema.

In fact, plone.supermodel was originally based on userschema. However, as the package was refined and refactored, less and less of userschema remained, to the point where we'd have needed to significantly refactor the latter to keep using it.

The XML import/export code is currently based on algorithms that were written for plone.app.portlets and plone.app.contentrules' GenericSetup handlers.

Some of the key differences between the two packages are:

  • userschema can create schema interfaces from HTML forms and CSV spreadsheets. plone.supermodel does not support such configuration.

  • Schemata created with userschema are typically loaded at startup, with a ZCML directive. plone.supermodel supports a "pseudo-base class" syntax, as seen above, to define interfaces in Python code. Beyond that, its API is more geared towards runtime configuration.

  • plone.supermodel supports serialisation of schemata to XML.

  • The plone.supermodel XML syntax is more directly tied to zope.schema fields, and infers most parameters from the schema interface declared by each zope.schema field. This has two advantages:

    • API documentation for zope.schema can be easily applied to <schema /> blocks
    • New fields and obscure attributes are easier to support
  • plone.supermodel's XML schema is intended to support more schema metadata, including widget hints.

In the future, it may be possible to make userschema re-use part of plone.supermodel or vice-a-versa, with more refactoring.

plone.supermodel's People

Contributors

optilude avatar davisagli avatar esteele avatar lrowe avatar smcmahon avatar datakurre avatar mauritsvanrees avatar seanupton avatar garbas avatar jensens avatar gweis avatar gforcada avatar tisto avatar thet avatar matthewwilkes avatar do3cc avatar pbauer avatar bloodbare avatar

Watchers

 avatar James Cloos avatar

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.