Hey, do you guys usually declare all instance attributes in the init of a class?
Let's say your init only accepts one parameter, but you have other attributes you plan on using, would you say something like self.otherattribute = None to clarify?
inklesspen
yeah, that's a good thing to do
that's not necessarily the same thing as "declaring instance attributes"
and there's no technical benefit to doing this. but it's handy down the line when you look at the __init__ and wonder what is going on.
c0le joined the channel
mastokley joined the channel
ash__
Hey there folks, quick question to help direct my reading. I'm trying to create a situation where I check some db state before a view is routed, and if the db is not ready I return a HTTPFound (or something) sending it somewhere else. Importantly this needs to be done for most of the views in the app so I kind of want it to happen in a single location.
There are two distinct, non user related states that I've got to do this for (effectively blocking the app until the state is resolved) and the obvious example of this is with user Auth. I've seen this done in a root factory with acls redirecting to a login page but I'm wondering if there is somewhere else thats better suited to non-user stuff-- or if I should keep following the root factory rabbit hole and see where it leads?
Any tips would be greatly appreciated :D
mejymejy joined the channel
user___
inklesspen: Yeah, I agree, just wanted to hear what the kind of consensus was, so thanks for the info
jhauser joined the channel
inklesspen
ash__: the ContextFound event might be appropriate
user___
ash__: Why not put it in the __init__ of your main view class?
mejymejy has quit
ash__
inklesspen: I was looking through the events at one stage. Will go back and re-read this now.
inklesspen
user___: "main view class"?
my pyramd apps have no such thing. :D
tokra100 joined the channel
yvl joined the channel
ash__
user__: Currently not using class based views but could look into this. Was thinking at one stage I could inherit from something that provided this overriding of the view for me, but then went off on the event tangent... :p. Might have a look again but it would require changing of a (small) chunk of code.
Zart
"db isnt ready" = no db connection at all?
user___
I understand not everyone uses this approach, but it is a pattern I use, my fault for assuming that everybody does :D
I come from a java background so my python is tainted by many of the philosophies from java...
Zart: I think he is trying to resolve concurrent access or race conditions
user__: Yah. Have done this before. Just got out of the habit to keep things flat and simple in small apps.
Makes a lot of sense though-- thanks for the link :)
tomeff has quit
tokra100 has left the channel
ddimmich joined the channel
uralbash joined the channel
frispete_ joined the channel
ddimmich has quit
ddimmich_ joined the channel
redir joined the channel
mejymejy joined the channel
mejymejy has quit
ash__ has quit
rickmak_ joined the channel
rodfersou joined the channel
El_Rolando joined the channel
zepolen joined the channel
waigani joined the channel
zepolen has quit
disko has quit
tokra100 joined the channel
tokra100 has left the channel
user___ has quit
bochecha joined the channel
tbenita joined the channel
davisagli has quit
Loetkolben joined the channel
Loetkolben has quit
disko joined the channel
ronnix joined the channel
agitator|hpeter joined the channel
atomekk joined the channel
Aankhen`` has quit
sakal joined the channel
Aankhen`` joined the channel
NotreDev has quit
mejymejy joined the channel
mejymejy has quit
slav0nic joined the channel
areski joined the channel
yleclanche joined the channel
plamut joined the channel
eatkin joined the channel
zepolen joined the channel
RchrdB joined the channel
pldz joined the channel
tbenita has quit
uralbash joined the channel
ronnix joined the channel
tbenita joined the channel
ronnix joined the channel
evilbungle joined the channel
zepolen has quit
Loetkolben joined the channel
zepolen joined the channel
ronnix joined the channel
teix joined the channel
mejymejy joined the channel
ronnix_ joined the channel
ljosberinn joined the channel
mejymejy has quit
RchrdB joined the channel
areski joined the channel
bind
from now on, if someone asks me about pyramid ... I only can say ... "Pyramid? I wish I would have tried it earlier! :D"
Loetkolben has quit
ronnix joined the channel
utek
bind: but what about Pyramid? :>
zepolen has quit
yvl has quit
zepolen joined the channel
thdr joined the channel
ronnix joined the channel
bind
Well, for example that from the get go you are confronted with the "best practices" wrt python packaging
so yesterday I wanted to run my pyramid example app on our hosting thing
zepolen has quit
I just had to do pip install . within the source checkout from within the virtualenv
and created an upstart thing running gunicorn --paste production.ini
hvelarde joined the channel
furthermore there is quite a lot of freedom and a lot of routing/view/renderer goodies which are quite handy ... but then again ... still being a bit new to pyramid :D