Flattened enkel.exml
authorEspen A. Kristiansen <[email protected]>
Thu, 5 Apr 2007 21:28:01 +0000 (5 23:28 +0200)
committerEspen A. Kristiansen <[email protected]>
Thu, 5 Apr 2007 21:28:01 +0000 (5 23:28 +0200)
13 files changed:
enkel/exml/__init__.py [moved from testsuite/exml/markup/__init__.py with 67% similarity]
enkel/exml/form/__init__.py [deleted file]
enkel/exml/form/ns.py [deleted file]
enkel/exml/form/validate.py [deleted file]
enkel/exml/formgen.py [moved from enkel/exml/form/formgen.py with 99% similarity]
enkel/exml/info.py [moved from enkel/exml/markup/ns.py with 53% similarity]
enkel/exml/markup/__init__.py [deleted file]
enkel/exml/validate.py [moved from enkel/exml/markup/validate.py with 77% similarity]
testsuite/exml/__init__.py
testsuite/exml/form/__init__.py [deleted file]
testsuite/exml/formgen.py [moved from testsuite/exml/form/formgen.py with 97% similarity]
testsuite/exml/markup/validate.py [deleted file]
testsuite/exml/validate.py [moved from testsuite/exml/form/validate.py with 78% similarity]

similarity index 67%
rename from testsuite/exml/markup/__init__.py
rename to enkel/exml/__init__.py
index 3c178d2..7347978 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
-from enkel.exml.markup import validate as dt_validate
+""" Validation and utilities for the enkel xml languages.
 
-import validate
 
-
-def suite():
-       return unit_mod_suite(validate, dt_validate)
-
-if __name__ == "__main__":
-       run_suite(suite())
+Markup
+======
+       You often find that you want both site-admins and normal users to
+       submit information in a structured way. This often occur in
+               - forums
+               - blogs
+               - wikis
+       And many other systems. For these situations enkel supplies a
+       markup language in the U{http://enkel.sourceforge.net/xml/markup}
+       namespace. See the URL for documentation.
+"""
diff --git a/enkel/exml/form/__init__.py b/enkel/exml/form/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/enkel/exml/form/ns.py b/enkel/exml/form/ns.py
deleted file mode 100644 (file)
index 5b8c86f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-XMLNS_FORM = "http://enkel.sourceforge.net/xml/form"
diff --git a/enkel/exml/form/validate.py b/enkel/exml/form/validate.py
deleted file mode 100644 (file)
index bb4d825..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen ([email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-
-"""
-EXML form validation.
-@warning: This module depends on the B{lxml} library.
-"""
-
-from os.path import join
-from lxml import etree
-
-from enkel.rngdata import RNGDIR
-
-
-def validate_formsection(xml):
-       """ Validate a document agains formsection.rng.
-       Parameters and excetions are the same as
-       L{enkel.exml.markup.validate.validate_inline}.
-       """
-       rng_file = join(RNGDIR, "formsection.rng")
-       rng_doc = etree.parse(rng_file)
-       rng = etree.RelaxNG(rng_doc)
-       rng.assertValid(xml)
-
-
-def validate_form(xml):
-       """ Validate a document agains form-standalone.rng.
-       Parameters and excetions are the same as
-       L{enkel.exml.markup.validate.validate_inline}.
-       """
-       rng_file = join(RNGDIR, "form-standalone.rng")
-       rng_doc = etree.parse(rng_file)
-       rng = etree.RelaxNG(rng_doc)
-       rng.assertValid(xml)
similarity index 99%
rename from enkel/exml/form/formgen.py
rename to enkel/exml/formgen.py
index ca3c6d0..64353d0 100644 (file)
@@ -20,7 +20,8 @@ from enkel.model.field.base import *
 from enkel.model.formgen import Form
 from enkel.model.ds import One, Many, DatasourceField
 from enkel.xmlutils.writer import XmlWriter
-from ns import XMLNS_FORM
+
+from info import XMLNS_FORM
 
 
 class Form(Form):
similarity index 53%
rename from enkel/exml/markup/ns.py
rename to enkel/exml/info.py
index 93fbd22..2fa21d8 100644 (file)
@@ -1,4 +1,6 @@
 """
 @var XMLNS_MARKUP: The namespace used by the exml markup language.
+@var XMLNS_FORM: The namespace used by the exml form language.
 """
 XMLNS_MARKUP = "http://enkel.sourceforge.net/xml/markup"
+XMLNS_FORM = "http://enkel.sourceforge.net/xml/form"
diff --git a/enkel/exml/markup/__init__.py b/enkel/exml/markup/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
similarity index 77%
rename from enkel/exml/markup/validate.py
rename to enkel/exml/validate.py
index aec4e05..28923f3 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 """
-EXML markup validation.
+Validation of various exml languages.
+
+@note: When the documentation below refers to a "<filename>.rng"
+               it refers to a file in enkel/rngdata/.
 @warning: This module depends on the B{lxml} library.
 """
 
@@ -33,7 +36,7 @@ def validate_inline_field(fieldname, xml, offset):
        of exml inline.
 
        >>> from enkel.model.field.xmlf import XmlField
-       >>> from ns import XMLNS_MARKUP as ns
+       >>> from info import XMLNS_MARKUP as ns
        >>> f = XmlField(validate=validate_inline_field)
        >>> xml = u"<inline xmlns='%s'>hello</inline>" % ns
        >>> f.validate("f", xml)
@@ -45,13 +48,13 @@ def validate_inline_field(fieldname, xml, offset):
 
 
 def validate_inline(xml):
-       """ Validate a xml document against inline.rng.
+       """ Validate a xml document against "inline.rng".
 
        Examples
        ========
                >>> from lxml.etree import parse, XML
                >>> from cStringIO import StringIO
-               >>> from ns import XMLNS_MARKUP as ns
+               >>> from info import XMLNS_MARKUP as ns
 
                >>> doc = "<inline xmlns='%s'><em>hello</em></inline>" % ns
                >>> validate_inline(XML(doc))
@@ -83,7 +86,7 @@ def validate_section_field(fieldname, xml, offset):
        of exml section.
 
        >>> from enkel.model.field.xmlf import XmlField
-       >>> from ns import XMLNS_MARKUP as ns
+       >>> from info import XMLNS_MARKUP as ns
        >>> f = XmlField(validate=validate_section_field)
        >>> xml = u"<section xmlns='%s'><h>hello</h></section>" % ns
        >>> f.validate("f", xml)
@@ -104,6 +107,31 @@ def validate_section(xml):
        rng.assertValid(xml)
 
 
+
+def validate_formsection(xml):
+       """ Validate a document agains "formsection.rng".
+       Parameters and excetions are the same as
+       L{enkel.exml.markup.validate.validate_inline}.
+       """
+       rng_file = join(RNGDIR, "formsection.rng")
+       rng_doc = etree.parse(rng_file)
+       rng = etree.RelaxNG(rng_doc)
+       rng.assertValid(xml)
+
+
+def validate_form(xml):
+       """ Validate a document agains "form-standalone.rng".
+       Parameters and excetions are the same as
+       L{enkel.exml.markup.validate.validate_inline}.
+       """
+       rng_file = join(RNGDIR, "form-standalone.rng")
+       rng_doc = etree.parse(rng_file)
+       rng = etree.RelaxNG(rng_doc)
+       rng.assertValid(xml)
+
+
+
+
 def suite():
        import doctest
        return doctest.DocTestSuite()
index cb41eb4..671402b 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
+from enkel.exml import validate as dt_validate
 
-import markup, form
+import validate, formgen
 
 
 def suite():
-       return unit_mod_suite(markup, form)
+       return unit_mod_suite(validate, dt_validate, formgen)
 
 if __name__ == "__main__":
        run_suite(suite())
diff --git a/testsuite/exml/form/__init__.py b/testsuite/exml/form/__init__.py
deleted file mode 100644 (file)
index d6a6ff6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen ([email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-from enkel.wansgli.testhelpers import unit_mod_suite, run_suite
-
-import formgen, validate
-
-
-def suite():
-       return unit_mod_suite(formgen, validate)
-
-if __name__ == "__main__":
-       run_suite(suite())
similarity index 97%
rename from testsuite/exml/form/formgen.py
rename to testsuite/exml/formgen.py
index f06b7a4..063f334 100644 (file)
@@ -21,8 +21,8 @@ from datetime import date, time, datetime
 from lxml.etree import XML
 
 from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.form.formgen import Form
-from enkel.exml.form.validate import validate_form
+from enkel.exml.formgen import Form
+from enkel.exml.validate import validate_form
 from enkel.model.data import Manip
 from enkel.model.util import ModelData
 from enkel.model.ds import One, Many
diff --git a/testsuite/exml/markup/validate.py b/testsuite/exml/markup/validate.py
deleted file mode 100644 (file)
index 05244f5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# This file is part of the Enkel web programming library.
-#
-# Copyright (C) 2007 Espen Angell Kristiansen ([email protected])
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-from unittest import TestCase
-from cStringIO import StringIO
-from lxml.etree import XML
-
-from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.markup.validate import \
-               validate_section, validate_inline
-from enkel.exml.markup.ns import XMLNS_MARKUP
-
-
-SECTION = \
-u"""<section xmlns="%s">
-       <h>This is a test</h>
-       <p>
-               Really it is;)
-       </p>
-</section>""" % XMLNS_MARKUP
-
-INLINE = u"""<inline xmlns="%s">
-       A <strong>strong</strong> <em>person</em>.
-</inline>""" % XMLNS_MARKUP
-
-
-class TestValidate(TestCase):
-       def test_validate_section(self):
-               validate_section(XML(SECTION))
-       def test_validate_inline(self):
-               validate_inline(XML(INLINE))
-
-
-def suite():
-       return unit_case_suite(TestValidate)
-
-if __name__ == '__main__':
-       run_suite(suite())
similarity index 78%
rename from testsuite/exml/form/validate.py
rename to testsuite/exml/validate.py
index 10411cf..7bccfa8 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 from unittest import TestCase
+from cStringIO import StringIO
 from lxml.etree import XML
 
 from enkel.wansgli.testhelpers import unit_case_suite, run_suite
-from enkel.exml.markup.ns import XMLNS_MARKUP
-from enkel.exml.form.ns import XMLNS_FORM
-from enkel.exml.form.validate import \
+from enkel.exml.validate import \
+               validate_section, validate_inline, \
                validate_formsection, validate_form
+from enkel.exml.info import XMLNS_MARKUP, XMLNS_FORM
 
 
 FORM = \
@@ -57,7 +58,24 @@ u"""<section xmlns="%(XMLNS_MARKUP)s">
 </section>""" % vars()
 
 
+SECTION = \
+u"""<section xmlns="%s">
+       <h>This is a test</h>
+       <p>
+               Really it is;)
+       </p>
+</section>""" % XMLNS_MARKUP
+
+INLINE = u"""<inline xmlns="%s">
+       A <strong>strong</strong> <em>person</em>.
+</inline>""" % XMLNS_MARKUP
+
+
 class TestValidate(TestCase):
+       def test_validate_section(self):
+               validate_section(XML(SECTION))
+       def test_validate_inline(self):
+               validate_inline(XML(INLINE))
        def test_validate_formsection(self):
                validate_formsection(XML(FORMSECTION))
        def test_validate_form(self):