OK... its possible that zope.configuration doesn't work for some reason under 
Jython; I don't know that anyone has tried it recently.  I may give it a shot 
myself over the next week or so out of curiosity.

In the meantime, however, you can disuse "declarative" (ZCML) style 
configuration, which will subvert zope.configuration entirely.  To do so, 
change the body of the "app" function in run.py of the generated sample app 
from this:

     def app(global_config, **settings):
         """ This function returns a ``repoze.bfg`` application object.  It
         is usually called by the PasteDeploy framework during ``paster
         serve``"""
         zcml_file = settings.get('configure_zcml', 'configure.zcml')
         config = Configurator(root_factory=get_root, settings=settings)
         config.begin()
         config.load_zcml(zcml_file)
         config.end()
         return config.make_wsgi_app()

to:

     def app(global_config, **settings):
         """ This function returns a ``repoze.bfg`` application object.  It
         is usually called by the PasteDeploy framework during ``paster
         serve``"""
         zcml_file = settings.get('configure_zcml', 'configure.zcml')
         config = Configurator(root_factory=get_root, settings=settings)
         config.begin()
         config.add_view(context=MyModel, view=my_view,
                              renderer='templates/mytemplate.pt')
         config.add_static_view(name='static', path='templates/static')
         config.end()
         return config.make_wsgi_app()

Diaz, Eduardo wrote:
> Yes, it does
> 
> :P
> 
> On Mon, Jan 4, 2010 at 10:42 AM, Chris McDonough <chr...@plope.com 
> <mailto:chr...@plope.com>> wrote:
> 
>     Diaz, Eduardo wrote:
> 
>         Ok, I think I know why this is happening,
> 
>         the exception raises in the _validate method of the Orderable
>         class, this is where it happends:
> 
>         if self.max is not None and value > self.max:
>            raise TooBig(value, self.max)
> 
>         Here, max is a ValidatedProperty it has a __set___ method which
>         gives it a value, the problem with jython seems to be that it
>         isn't getting the value from the instance dictionary, so I came
>         up a workaround,
> 
>         I define the __get__ method in the ValidatedPropertyClass like this:
> 
> 
>         def __get__(self, inst, owner):
>            name, check = self._info
>            return inst.__dict__[name]
> 
>         And now the tests run ok:
> 
>         jython setup.py test -q
> 
>         running test
>         running egg_info
>         writing MyProject.egg-info/PKG-INFO
>         writing entry points to MyProject.egg-info/entry_points.txt
>         writing requirements to MyProject.egg-info/requires.txt
>         writing top-level names to MyProject.egg-info/top_level.txt
>         writing dependency_links to MyProject.egg-info/dependency_links.txt
>         reading manifest file 'MyProject.egg-info/SOURCES.txt'
>         writing manifest file 'MyProject.egg-info/SOURCES.txt'
>         running build_ext
>         .
>         ----------------------------------------------------------------------
>         Ran 1 test in 0.005s
> 
>         OK
> 
>         I know it is not elegant, and I'll submit a bug to the jython
>         developers... but for now, I want to go on and there's another
>         problem with running the project, and here it is:
> 
>         paster serve MyProject.ini
>         Traceback (most recent call last):
>          File "/home/iamedu/Tests/jython/sys/bin/paster", line 7, in
>         <module>
>            sys.exit(
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/command.py",
>         line 84, in run
>            invoke(command, command_name, options, args[1:])
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/command.py",
>         line 123, in invoke
>            exit_code = runner.run(args)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/command.py",
>         line 123, in invoke
>            exit_code = runner.run(args)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/command.py",
>         line 218, in run
>            result = self.command()
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/serve.py",
>         line 275, in command
>            app = self.loadapp(app_spec, name=app_name,
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteScript-1.7.3-py2.5.egg/paste/script/serve.py",
>         line 311, in loadapp
>            return loadapp(
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/loadwsgi.py",
>         line 204, in loadapp
>            return loadobj(APP, uri, name=name, **kw)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/loadwsgi.py",
>         line 225, in loadobj
>            return context.create()
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/loadwsgi.py",
>         line 625, in create
>            return self.object_type.invoke(self)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/loadwsgi.py",
>         line 110, in invoke
>            return fix_call(context.object, context.global_conf,
>         **context.local_conf)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/util/fixtypeerror.py",
>         line 57, in fix_call
>            val = callable(*args, **kw)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/PasteDeploy-1.3.3-py2.5.egg/paste/deploy/util/fixtypeerror.py",
>         line 57, in fix_call
>            val = callable(*args, **kw)
>          File "/home/iamedu/Tests/jython/MyProject/myproject/run.py",
>         line 11, in app
>            config.load_zcml(zcml_file)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/repoze.bfg-1.2a10-py2.5.egg/repoze/bfg/configuration.py",
>         line 424, in load_zcml
>            xmlconfig.file(filename, package, execute=True)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/xmlconfig.py",
>         line 647, in file
>            include(context, name, package)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/xmlconfig.py",
>         line 546, in include
>            processxmlfile(f, context)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/xmlconfig.py",
>         line 378, in processxmlfile
>            parser.parse(src)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/xmlconfig.py",
>         line 378, in processxmlfile
>            parser.parse(src)
>          File
>         "/home/iamedu/Tools/jython2.5.1/Lib/xml/sax/drivers2/drv_javasax.py",
>         line 141, in parse
>            self._parser.parse(JyInputSourceWrapper(source))
>          File
>         "/home/iamedu/Tools/jython2.5.1/Lib/xml/sax/drivers2/drv_javasax.py",
>         line 178, in startElement
>            self._cont_handler.startElementNS((uri or None, lname), qname,
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/xmlconfig.py",
>         line 230, in startElementNS
>            self.context.begin(name, data, info)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/config.py",
>         line 534, in begin
>            self.stack.append(self.stack[-1].contained(__name, __data,
>         __info))
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/config.py",
>         line 835, in contained
>            return RootStackItem.contained(self, name, data, info)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/config.py",
>         line 703, in contained
>            factory = self.context.factory(self.context, name)
>          File
>         
> "/home/iamedu/Tests/jython/sys/Lib/site-packages/zope.configuration-3.6.0-py2.5.egg/zope/configuration/config.py",
>         line 480, in factory
>            raise ConfigurationError("Unknown directive", ns, n)
>         zope.configuration.xmlconfig.ZopeXMLConfigurationError: File
>         "file:///home/iamedu/Tests/jython/MyProject/myproject/configure.zcml",
>         line 10.8
>            ConfigurationError: ('Unknown directive',
>         u'http://namespaces.repoze.org/bfg', u'view')
> 
> 
>     An obvious thing to check first.. does:
> 
>     <include package="repoze.bfg.includes"/>
> 
>     Come after the first <configure> tag but before any other directive
>     in myproject/configure.zcml?  Is this the bare configure.zcml file
>     generated by the paster template or have you made changes?
> 
>     - C
> 
> 

_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to