On 4/1/07, Toby Sargeant <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm very new to pylons, so this might be a lack of understanding > issue, but I've looked around the docs and haven't really found > anything. > > I'm trying to write a test suite for my model. tests/test_models.py > looks like the place to do it, but there's no stub code. Not knowing > if it was meant to be run as a script, or through paste, I decided to > try as a script, and borrowed the preamble from websetup.py to get the > config/sqlalchemy metadata initialized. > > This is all well and good, but the model relies on lib/app_globals.py > to setup some config information for it via 'g'. Tracing it through, I > see that g gets set up in the WSGI middleware, which clearly isn't > being run in the script case. > > I'm stumped as to how to set this up properly, and any suggestions/ > pointers would be much appreciated.
A related problem happened to me Friday. I have a glossary that's being parsed from a third-party HTML document, and logically it belongs in the model. I want to parse it on application startup and put the data structure in 'g'. But I can't import "myapp.models.glossary" from "myapp.lib.app_globals" because CONFIG hasn't been registered yet. So I had to put it in "myapp.lib.glossary" instead. (The source file is myapp/lib/glossary_data.html.) What you need to mimic is whatever "paster shell" is doing to initialize 'g' and 'model'. If "paster test" isn't doing this... oh, there is no "paster test". Maybe there should be. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
