John Dickson wrote:
> Hi Edgar
>
> OK, a minor misunderstanding there...
>
> As far as I know, the helpers module is there for whatever *you* want
> to be easily available in the UI code for *your* app. Pylons doesn't
> (and probably couldn't) provide a standard helpers.py that is right
> for every application. This also seems to fit the pattern of the
> other modules generated in /config and /lib for your application
>
> So, if you want to use a function like routes.url_for() in your UI,
> the easy way to achieve this is to import it in helpers.py (as I
> showed below) - then you can access it as h.url_for() in your
> controllers, templates etc. It's also common to import things like
> "webhelpers.html.tags.*" etc., particularly for form handling.
>
> Hope this helps ............................ JD
>
> 2009/3/17 edgarsmolow <[email protected]
> <mailto:[email protected]>>
>
>
> Thanks, John, but that's not my question.
> My question is not about how to access functions in the module. My
> question is about why the documentation talks about using the url_for
> () function, but it is not present in the module. Are we expected to
> write it ourselves, or was there a problem in the WAY I set up the
> application? For instance, perhaps I missed a step...
>
> Thanks.
> Edgar
>
>
> On Mar 16, 5:14 pm, John Dickson <[email protected]
> <mailto:[email protected]>> wrote:
> > Hi Edgar
> >
> > You normally add the imports you want to helpers.py, which then
> makes them
> > available as "h.some_import". For example, I use the following
> line to get
> > the url_for() function:
> >
> > from routes import url_for
> >
> > Cheers ........................ JD
> >
> > 2009/3/17 edgarsmolow <[email protected]
> <mailto:[email protected]>>
> >
> >
> >
> > > I recently began development with Pylons 0.9.7. The online docs
> > > suggest using a function called url_for that should be in
> > > myproject.lib.helpers.py <http://myproject.lib.helpers.py>.
> But, the file is essentially empty.
> >
> > > Is helpers.py supposed to come with any functions at all, or
> are we
> > > supposed to write url_for (and any others mentioned in the docs)?
> >
> > > Thanks.
> > > Edgar
> >
> > --
> > /Angle-parked in a parallel universe.../
> >
>
>
>
> --
> /Angle-parked in a parallel universe.../
Ok. Now that I've got that straightened out, on to another problem. I'm
using Pylons 0.9.7 with SQLAlchemy 0.5, but running into a problem when
testing model functionality. In particular, there's a Person object
which is supposed to be stored in
the persons table. Here's a test code snippet:
import sqlalchemy as sa
import w2t.model as model
import w2t.model.meta as meta
DB_URL = "mysql://userid:passw...@localhost/dbname"
engine = sa.create_engine(DB_URL)
model.init_model(engine)
session = meta.Session()
wilma = model.Person('Wilma','Flintstone')
wilma.acct_no = 'SOMEACCOUNTNUMBER'
wilma.gender = 'F'
print 'Wilma:',wilma
session.add(wilma)
meta.Session.commit()
Since neither meta.Session or session have an add method, an
AttributeError exception is raised. But, I don't know the correct set
of calls to make to create a session.
Thanks.
Edgar
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---