7:46 AM
Paradisee
yap
7:46 AM
stevepiercy
a hello world or something
7:46 AM
ok
7:46 AM
Paradisee
i put return Response('OK')
7:46 AM
just to make sure everything works.
7:46 AM
MrTango joined the channel
7:46 AM
but i need to return the whole .pt page instead.
7:47 AM
in flask would be something like: return render_template('home.html')
7:47 AM
bmcorser joined the channel
7:49 AM
stevepiercy
what templating language are you using, and did you install its pyramid bindings?
7:50 AM
Paradisee
i think so.
7:50 AM
stevepiercy
Flask includes Jinja, I think. Pyramid includes none out of the box
7:50 AM
Paradisee
actually im not using any
7:50 AM
ya, flask uses jinja
7:52 AM
Ergo
return render_template('home.html')
7:52 AM
in pyramid you can do the same
7:53 AM
stevepiercy
you might want to install Jinja2, or mako, or chameleon, or none, or write your own, down the road
7:53 AM
Zart
quick pyramid explanation: you start by creating Configurator object, then either configure it explicitly via include, add_view, add_route, etc methods, or use scan method to scan source files for @add_route and such decorators. then you call make_wsgi_app to grab real app and serve it via your server/adapter of choice.
7:54 AM
Paradisee
i'd prefer to use jinja.
7:54 AM
stevepiercy
7:54 AM
Zart
your views can generate responses by themselves (via Response class) or return some data which will be wrapped by preconfigure template (with any templating engine of your choice. or few.)
7:55 AM
for jinja install pyramid_jinja2
7:55 AM
stevepiercy
if you are using .pt as a template extension, you might have been using chameleon
7:55 AM
Paradisee
well...
7:55 AM
i wanna use .html
7:55 AM
.pt make me cry.
7:55 AM
stevepiercy
you can configure the extension
7:55 AM
Zart
config.include('pyramid_jinja2'); config.add_jinja_renderer('.html')
7:55 AM
stevepiercy
.mybadassextension
7:56 AM
Paradisee
sounds better.
7:58 AM
python-jinja2 - small but fast and easy to use stand-alone template engine
7:58 AM
Zart
?
7:58 AM
Paradisee
that's the package.
7:58 AM
Zart
is that some apt?
7:59 AM
Paradisee
ya
7:59 AM
Zart
then it's Jinja2 package
7:59 AM
7:59 AM
Paradisee
ill use pip
7:59 AM
Zart
pyramid_jinja2 adds glue between pyramid and jinja2 and also pulls jinja2 as dependency
8:00 AM
Paradisee
done.
8:00 AM
Zart
8:01 AM
Paradisee
config.add_jinja_renderer('.html')
8:01 AM
doesnt exist.
8:01 AM
Zart
config.include('pyramid_jinja2') first
8:01 AM
this will add jinja2 methods to configurator
8:01 AM
Paradisee
config.include('pyramid_jinja2')
8:01 AM
config.add_jinja_renderer('.html')
8:01 AM
Zart
also add_jinja2_renderer
8:01 AM
Paradisee
AttributeError: add_jinja_renderer
8:02 AM
Zart was quoting name from memory
8:02 AM
lal.
8:02 AM
lemme check then
8:02 AM
Zart
sorry ;D
8:02 AM
8:02 AM
Paradisee
8:03 AM
digitalsatori joined the channel
8:05 AM
ok seems to work.
8:06 AM
let's see if i can change some path to make it more like the original one
8:07 AM
Loetkolben joined the channel
8:10 AM
\o/
8:10 AM
everything is great now.
8:14 AM
Charlie_X joined the channel
8:19 AM
zmijunkie joined the channel
8:22 AM
Thank you guys for the moment! i'll work on this part and ill be back once i've done ;)
8:22 AM
mr_jolly has quit
8:27 AM
digitalsatori joined the channel
8:35 AM
areski joined the channel
8:38 AM
mr_jolly joined the channel
8:56 AM
tjt263 joined the channel
9:03 AM
Kane` has quit
9:13 AM
teix joined the channel
9:19 AM
digitalsatori joined the channel
9:21 AM
tbenita joined the channel
9:25 AM
im back.
9:26 AM
i've been doing all the layout with jinja, now seems reasonable.
9:26 AM
how can i put a route to a link now?
9:28 AM
9:28 AM
but it seems that only accept / in the a href
9:30 AM
Kane` joined the channel
9:32 AM
otter768 joined the channel
9:34 AM
teix
Paradisee, you need to register a view that relates '/home' path to that method that renders this jinja
9:35 AM
Paradisee
ok, done.
9:47 AM
teix
Paradisee, well I wasn't very precise on my answer. using view registers (like view_config decorators) you relate routes with methods and that's route that defines path for routes.
9:47 AM
Paradisee, but I'm glad you find your way ;)
9:47 AM
Paradisee
\o/ :D
9:51 AM
Pumukel joined the channel
9:51 AM
Loetkolben has quit
9:55 AM
Loetkolben joined the channel
10:01 AM
snewpy joined the channel
10:04 AM
mr_jolly_ joined the channel
10:07 AM
utek_ joined the channel
10:07 AM
jgelens_ joined the channel
10:07 AM
mr_jolly has quit
10:08 AM
mr_jolly_ is now known as mr_jolly
10:08 AM
jgelens has quit
10:08 AM
DingoSaar has quit
10:08 AM
pjenvey has quit
10:08 AM
utek has quit
10:09 AM
DingoSaar joined the channel
10:11 AM
pjenvey joined the channel
10:20 AM
hynek
10:27 AM
c0le has quit
10:28 AM
Charlie_X
hynek: does attr support typing?
10:29 AM
hynek
Charlie_X: what do you mean by typing? whether comparison is type-sensitive (and not bullshit like namedtuple)?
10:29 AM
Charlie_X
Of attributes
10:30 AM
hynek
Charlie_X: it does validators and comes with validators for types and zope.interface
10:31 AM
it does it only on __init__ though. monkey patching setattr was a bridge to far for my taste
10:31 AM
10:31 AM
Charlie_X
Wise. It would also make things dog slow.
10:31 AM
Just got to that.
10:33 AM
So you're not using the descriptor protocol?
10:33 AM
hynek
10:33 AM
yeah I don’t b/c something didn’t work with it but I forgot what
10:34 AM
also pretty sure this approach is faster
10:34 AM
Charlie_X
That may depend upon memory use. Are you using __slots__?
10:35 AM
hynek
no, that’s the only downside
10:35 AM
slots has to be defined on the body; can’t do it later :(
10:36 AM
Charlie_X
oh, you mean the retrospective stuff based on the __init__ signature?
10:37 AM
hynek
what I mean is that doing cl.__slots__ in the decorator won’t work (I think, been a while)
10:37 AM
if there’s some trick I’m all ears
10:38 AM
Charlie_X
I think it's possible. I spent some time at PyCon discussing it with Raymond
10:38 AM
hynek
__init__ doesn’t do a lot FWIW, it’s precompiled according to the attr settings. so it does vroom vroom real good
10:38 AM
Charlie_X
Yes, because you can inspect when the class is built
10:38 AM
wiggy
isn't this a textbook example where you would want to use a metaclass?
10:38 AM
Charlie_X
It's where I use a metaclass
10:38 AM
hynek
I think one of the problems was that I’m transforming class attributes into instance attributes and class attributes are immutable in slots
10:39 AM
I don’t touch metaclasses. but I also don’t sub-class FWIW.
10:39 AM
(usually)
10:39 AM
Charlie_X
wiggy: I think they want something more dynamic
10:39 AM
areski joined the channel
10:42 AM
The library seems clearly aimed towards convenience and wrapping rather than domain-specific, where Metaclasses make more sense. I think.
10:48 AM
hynek
Charlie_X: kind of. mainly it’s to help ppl to use proper classes without adding rubbish to their inheritance tree/add magic pixie dust. :)
10:48 AM
c0le joined the channel
10:49 AM
Charlie_X
I'm not sure if I'm convinced by that argument but I can see it being relevant in certain contexts.
10:50 AM
The toy syntax would infuriate me.
10:50 AM
But horses for courses
10:50 AM
I think Python could provide better support for this kind of need.
10:51 AM
wiggy
is there a real need is what I'm wondering
10:52 AM
Charlie_X
For attr in particular?
10:52 AM
hynek
Charlie_X: it has non-toy synonyms: @attributes and attr()
10:52 AM
Charlie_X
hynek: I know.
10:53 AM
Personal preference not a real criticism
10:54 AM
wiggy: I suspect the use case is where people are creating lots of classes to represent objects.
10:54 AM
hynek
…as they should. tuples are pdb hell and namedtuples are the devil
10:54 AM
wiggy
why the hate for namedtuples ?
10:55 AM
Charlie_X
The syntax for creating namedtuples is far from ideal. They work fine.
10:56 AM
hynek
they behave like tuples (namedtuple("A", "a")(1) == namedtuple("B", "b")(1) == (1,)
10:56 AM
Charlie_X
I don't see that as a problem.
10:56 AM
hynek
and if you want to add methods you have to fumble with __new__. it’s a hack. I just wanna regular classes. :)
10:56 AM
wiggy
how does the overhead compare ?