IRC Logs for #circuits Tuesday, 2013-05-14

*** amee2husky has joined #circuits00:54
*** irclogger_____ has quit IRC05:08
*** irclogger_____ has joined #circuits05:09
*** jgiorgi has joined #circuits05:54
*** jgiorgi has quit IRC05:54
*** jgiorgi has joined #circuits05:54
*** koobs has quit IRC06:23
*** koobs has joined #circuits06:24
prologicamee2husky, hey10:44
prologicif you don't set a channel for a component10:45
prologicthen it defauls to *10:45
amee2huskyyeah, i figured that out yesterday10:47
amee2huskybecause i accidentially had a function post an event to itself10:48
amee2huskyneeded kill -9 to stop the recursive runaway10:48
prologicyes don't do that :)11:00
prologiccalled an infinite event loop11:00
amee2huskyi need to change the name of the Log() event class11:34
amee2huskybecause major bad vibes happen if i have a log() function in my Component superclass and forget to set the channel somewhere11:34
prologicmake one WriteLog11:35
prologicand the other Log11:35
prologicI knew you'd run into that sooner or later :)11:35
amee2huskyanyway, lunch time, then class11:39
prologicso how are you finding circuits so far?13:12
prologicg'night all13:46
Romsterg'night pro13:49
amee2huskyactually, i quite like it13:54
amee2huskywhen you read it later, here is an idea i had13:54
amee2huskyevent handers are rarely meant to be called explicitly... right?13:55
amee2huskyprobably too late, but how about changing the conventions for automatically registered handlers?13:55
amee2huskyto only register automatic handlers for functions with a certain prefix13:55
amee2huskysay, register a handler for EventName for a methon _on_event_name()13:56
Romsteri wish i had more time and motivation and a brain that didn't find programming so hard. to do more python stuff.13:56
amee2huskythat would mimic the method name convention for manually registered handlers13:57
amee2huskythe extra "_on_" isn't too much effort to type, and it subtly namespaces the event handlers13:57
*** ronny has joined #circuits13:57
*** ronny has quit IRC13:57
*** ronny has joined #circuits13:57
prologic<amee2husky> event handers are rarely meant to be called explicitly... right? <-- ideally not.14:06
RomsterEC is on amee2husky14:06
prologicamee2husky, we already have all this14:06
prologicjust not with a prefix14:06
prologicyou can either subclass BaseComponent14:07
prologicin which case no methods are automatically turned into event handlers14:07
amee2huskywell, the prefix would make the implicit handlers *slightly* more explicit14:07
prologicand you have to explicitly use @handler on your methods14:07
prologicor you subclass Component14:07
prologicin which case you are free to use @handler or not14:07
prologicany method not prefixed with a _ is turned into an event handler automatically14:07
prologicbut you can still use @handler to customize it a bit14:08
prologicmaking said method not an event handler - but rather a normal method14:08
amee2huskywould it be a bad idea to subclass BaseComponent, and make my own implicit handler thing with the _on_ prefix?14:08
prologicthis is true it would14:08
prologichowever it would also break absolutely everything :)14:09
prologicand every app ever written in circuits14:09
amee2huskyyup, that too :314:09
prologicyou could14:09
prologicyou'd have to modify the HandlerMetaClass14:09
prologicor create your own HandlerMetaClass14:09
amee2huskyi'll look at how the handler thing works later... at the uni right now14:10
amee2huskyand i've never used decorators like that before14:10
prologicthe question I have to ask though14:11
prologicis why?14:11
prologicyou're not really buying anything by doing this :)14:11
amee2huskywhy the _on_ prefix?14:11
prologicI normally write all my apps in this style14:11
prologiccomponents everywhere14:11
prologicand anything that isn't a component14:11
prologicis simply a function that does one thing14:11
prologicso all my systems that I write are all event-driven and functional in nature14:12
prologicmaking them a) very robusy and b) highly reusable14:12
amee2huskywell, i understand the main reason for the implicit handlers is to avoid an extra line and duplicating the method name, right?14:12
prologicwell no not at all14:12
prologicthe reason it's there has nothing to do with implicit vs. explicit - aka the python zen14:13
prologicit has to do with the component architecture14:13
prologicthink of circuits as more of a programming language14:13
prologican abstraction of interfaces14:13
prologicif you find yourself state in a component - think again14:13
prologicstate should be contained within data structures or objects14:14
prologicall your components implement behaviors14:14
amee2huskyhmm yeah, i get that14:14
prologicI mean if you wanna do it to learn14:14
prologicby all means :)14:14
prologicbut doing it for the aesthetics14:15
prologicjust so you have14:15
prologicdef on_foo(...)14:15
amee2huskybut i don't get why that means i shouldn't have methods that are not event handlers?14:15
prologicisn't buying you anything :)14:15
prologicwell we do support it of course14:15
prologicbut usually I don't do it14:15
prologicoccasionally there are things you don't want as event handler14:16
prologicyou just write in that case:14:16
prologicdef _my_private_method(self, ...):14:16
prologic   ...14:16
amee2huskyit subtly namespaces the event handlers so i can't get accidentially get events handled by functions that shouldn't14:16
prologicwhich won't get picked up14:16
amee2huskymmh i understand the _ convention to mean "don't touch from anywhere else, even from a subclass"14:17
amee2huskyand i like pulling complex code apart into functions, even if they are technically not neccessary14:17
amee2huskyi find 10 single page long functions are easier to read than one 500 lines function14:18
prologicAlso check this out:14:18
prologic>>> from import TCPServer14:18
prologic['read_value_changed', 'registered', 'started', 'stopped', 'unregister', 'close', 'write']14:18
prologicThere also two other class methods14:18
prologic.handlers() and .handles(*names)14:18
prologicuseful for plugin introspection of components you've loaded14:19
prologici.e: check if the component you wanted is the right one14:19
prologicalso as of a few revisinos ago14:19
prologicwe now support event priority as well14:19
prologicturned out to be trivial to add to the core14:20
amee2huskyhehe14:20, priority=X)14:20
prologicI haven't found a use-case for them for myself yet14:20
prologicbut someone else here wanted them :)14:20
amee2huskymmh which randomly reminds me of something14:21
amee2huskyyesterday i pulled all the initialization code into a "core component"14:21
amee2huskybut i'm still getting out of order log entries14:22
prologicahh yeah14:22
prologicbut are you running the core first14:22
prologicthen later on regsitered other components?14:22
amee2huskyi only run the core in the main program now14:22
Romsteri really do have a need to stop using sed and use some python class to explode strings and sort them,
prologicdoes Core also subclass LoggableComponent?14:22
amee2huskyand in the started event, i instantiate everything else14:22
Romsteras that's the mess in regex i have now.14:22
amee2huskyyeah, it does.14:23
prologic"foo bar baz".split(" ")14:23
prologicamee2husky, don't14:23
prologicchicken-egg problem14:23
prologicimpossible to solve :)14:23
prologicmake a clean, tight and simple Core14:23
amee2huskyi don't call the log() method until the Logger component is running14:23
prologicthat subclasses Component14:23
prologicmake it the only thing that runs first14:23
prologicmake it do nothing but:14:24
prologic1) load config file14:24
prologic2) read list of plugins14:24
prologic3) load plugins and register them14:24
prologicbut don't subclass LoggableComponent14:24
prologicyour plugins should14:24
prologicand really you should rename LoggableComponent to something like14:24
prologicBasePlugin :)14:24
Romsteryeah i'll play around with .split14:24
amee2huskyactually, .split() == .split(None) != .split(" ")14:25
Romstersee my regex hell in that pastebin?14:25
amee2husky.split(None) will "intuitively" split on whitespace, folding consecutive whitespace into one separator14:25
prologicbut so will14:25
amee2huskyerr yeah, but don't ask em what it does >_>14:25
prologicxs = [x for x in line.split(" ") if x]14:26
Romsteroh i can do for loops to split on a few different things.14:26
amee2huskyi used to like the ShellWords module in perl14:26
prologicif you're doing any kind of I/O processing14:27
prologicwrite generate expressions14:27
amee2huskybecause it allows splitting into words while respecting quotes14:27
Romsterif i can get my head around python again...14:27
amee2huskyalso, parking disk running out... bbiab14:27
Romsteri had to pick a project that no one else would be sane enough todo.14:31
Romsteranyways you should get to bed prologic, i'm gonna be in bed soon myself.14:34
Romsterbut possibly after EC has drawn a platypus that i just asked for earlier.14:34
prologichi ronny14:40
prologicwhat's up?14:40
ronnyi just finished moving to bonn14:40
prologicah congrats14:40
ronnyand well, tommorow is the first day at work14:42
prologicahh cool14:43
prologicgood luck!14:43
amee2huskyoh murr14:59
amee2huskyfinally home14:59
amee2huskymust be something with the weather.... people are flying low today  -_-15:00
Romsteroh murr platypus
Romsterheck i've been brain dead most of today. seems i don't register on everything that others have said. selective hearing.15:07
Romsteri guess it's a sign i'm over working myself.15:07
*** ronny has quit IRC16:18
*** ronny has joined #circuits18:21
*** ronny has quit IRC18:21
*** ronny has joined #circuits18:21
amee2huskyprologic:   <<  can you explain that one to me?  o.O20:14
amee2huskyit ised to work before i did the weird dev install thing20:14
*** ronny has quit IRC21:19
prologicMorning All22:30

Generated by 2.11.0 by Marius Gedminas - find it at!