IRC Logs for #circuits Saturday, 2013-03-09

*** christopher has joined #circuits01:33
*** ronny has quit IRC05:25
*** ronny has joined #circuits05:27
*** ronny has quit IRC05:27
*** ronny has joined #circuits05:27
*** ircnotifier has joined #circuits07:02
*** ircnotifier has quit IRC07:03
*** ircnotifier has joined #circuits07:04
*** ircnotifier has quit IRC07:05
spaceoneprologic: why didn't you take the Header class from cherrypy?07:28
prologicNot sure :)07:29
spaceonei don't really like the class because it inherits from dict but stores its values in a list07:29
prologicMaybe we took BaseHTTPServer's one instead?07:29
prologicI'll have a look in a sec07:30
spaceoneokay ;)07:30
*** ircnotifier has joined #circuits07:33
*** ircnotifier has quit IRC07:34
*** ircnotifier has joined #circuits07:38
*** ircnotifier has quit IRC07:40
*** ircnotifier has joined #circuits07:41
prologicworking on a new irc bot07:41
prologicto arbitrarily take sources of input and announce them on irc07:42
ircnotifiertest: prologic cb54f3ab01e1 This is FooBar\! ([u'foobar.txt'])07:43
prologicsweet it worked07:43
prologicnow I just have to improve it a bit07:43
spaceone'take sources' ?07:43
prologicright now it takes input form a restful api07:44
prologicI'm pretty happy with this so far actually07:44
prologicthe format of the msg kinda sucks a bit though07:44
prologicwhat's the normal form?07:44
*** ircnotifier has quit IRC07:45
spaceone? i don't understand07:46
spaceonebut i have found a bug in circuits.web.errors07:46
spaceone 73     def sanitize(self):07:46
spaceone 74         if self.code < 300 or self.code > 399:07:46
spaceone 75             if "Location" in self.response.headers:07:46
prologica lot of open source projects use irc bot to post their commits on a channel07:46
spaceone 76                 del self.response.headers["Location"]07:46
spaceoneLocation header can be send on 201 CREATED also07:46
spaceoneprologic: ah ok07:47
spaceoneprologic: a friend of mine programmed this in php07:47
prologicI bet anything my implementation is shorter )07:47
prologiccause of circuits07:47
prologicfix that bug and submit a pull request? :)07:47
spaceoneoh i am currently thinking about not using circuits.web instead i want to create because there a a lot unREStful things in .web07:48
spaceoneand found another bug07:57
prologicguess no one ever claimed circuits.web was particularly restful :)08:05
spaceone244             if headers.get("Expect", "") == "100-continue":08:05
spaceone245                 return
spaceone246                     Response(08:05
spaceone247                         wrappers.Response(08:05
prologicthat's up to your application08:05
spaceone248                             request, code=100, encoding=self._encoding08:05
spaceone249                         )08:05
spaceone250                     )08:05
spaceone251                 )08:05
spaceoneprologic: yes of course, but the design of circuits web prevents being restful08:05
prologichow so?08:05
spaceoneprologic: like the example code i posted there08:05
prologicwhat about it?08:06
spaceoneif i am requesting with header Expect: 100-continue it answers directly instead of letting me decide08:06
prologicis it up to the app to respond with 100 Continue?08:07
prologicshow me in the rfc? :)08:07
spaceonewait a moment08:07
prologicare you familiar with bitbucket?08:07
prologicare you able to fork and submit pull requests for these bug fixes/changes?08:07
spaceone14.20 Expect08:08
spaceoneprologic: hmm not really, i want to use svn or git and no websites like bitbucket08:08
spaceone(i am sorry i have to go in some minutes)08:10
*** ircnotifier has joined #circuits08:12
prologicspaceone, we can work with git08:13
prologiccircuits is on github too08:13
*** ircnotifier has quit IRC08:13
spaceoneprologic: ok that is nice08:13
*** ircnotifier has joined #circuits08:14
ircnotifier1 commit(s) pushed to test on branch Unknown08:14
ircnotifierc1a745def6d5 by prologic: Removed08:14
prologicI just have to work on how to keep them in sync08:14
spaceoneprologic: :D yep08:14
*** ircnotifier has quit IRC08:15
*** ircnotifier has joined #circuits08:16
ircnotifier2 commit(s) pushed to test08:16
ircnotifierce452262d6c8 by prologic: Added foo08:16
ircnotifier8183c3b1203e by prologic: Added bar08:16
prologicoh oops :)08:20
prologicmust have been a typo somewhere08:20
spaceoneprologic: here another typo:
prologicAhh no I changed the url08:21
spaceoneprologic: bye bye, i am back at afternoon08:22
prologickk nps08:23
ircnotifier2 commit(s) pushed to circuits-dev08:31
ircnotifier7273fc41cd33 by prologic: Fixed typo - Thanks spaceone :)08:31
ircnotifierbce06637348e by prologic: Automated merge with
*** ircnotifier has quit IRC08:32
*** ircnotifier has joined #circuits08:33
*** ircnotifier has quit IRC08:36
*** ircnotifier has joined #circuits08:36
*** ircnotifier has quit IRC08:37
*** ircnotifier has joined #circuits08:43
*** ircnotifier has quit IRC08:48
*** ircnotifier has joined #circuits08:49
*** ronny_ has joined #circuits09:11
*** ronny has quit IRC09:15
*** zolokroft has joined #circuits09:56
prologicmorn'n all15:36
spaceoneprologic: you need to add a link to the commits15:51
spaceoneso that i can see the diff15:51
prologicthey're all there :)15:54
prologicSorry dude, I know you like git/svn15:54
prologicI will get into syncing github/bitbucket soon15:55
prologichaving some problems with hggit extensions for mercurial from my desktop @ home15:55
spaceonebtw what OS do you use?15:55
prologicAlso spaceone could you post any other patches I might have missed?15:55
prologicI run CRUX on my desktop and all servers I own15:55
spaceoneprologic: i will check for patches tomorrow15:56
prologicI think I missed two you posted15:58
prologicif you could repaste them I'll apply them15:58
prologicAlso what are we going to do about the Expect - 100 Continue behavior?15:58
spaceoneprologic: maybe really thinking about a modular REST component for circuits?15:59
prologicspaceone, well ...16:00
prologiccircuits.web has some of the basics that allow for RESTful apis16:01
prologicwe should (I think) just keep improving it16:01
prologiclike fixing the Expect / 100 Continue behavior16:01
prologicand making writing RESTful apis easier16:01
prologic- Upon receiving a request which includes an Expect request-header16:03
prologic        field with the "100-continue" expectation, an origin server MUST16:03
prologic        either respond with 100 (Continue) status and continue to read16:03
prologic        from the input stream, or respond with a final status code. The16:03
prologic        origin server MUST NOT wait for the request body before sending16:03
prologic        the 100 (Continue) response. If it responds with a final status16:03
prologic        code, it MAY close the transport connection or it MAY continue16:03
spaceoneprologic: the Expect thing is difficult.. if the app does not handle it the server must do it16:03
prologic        to read and discard the rest of the request.  It MUST NOT16:03
prologic        perform the requested method if it returns a final status code.16:03
prologicI'm confused :)16:03
prologicAccording to what I'm reading16:03
prologicthe behavior is fine16:03
prologicWhy would you want to handle the response in the application code anyway?16:03
prologicWhat's the use-case for handling it in application code vs. server?16:03
spaceonebecause if the representation the client send can be 10MB but the store only has 5MB it should have the possibility to decline16:04
spaceonealso there are more than 100-continue things (which can be handlet actually)16:04
prologicI don't understand :)16:04
prologicthinking about it16:07
prologicwe could just move some of the behavior out of the HTTP Component into another say DefaultBehaviors16:07
prologicwhich any application code an override by filtering the request at a higher priority16:07
prologickind of like a pre-dispatcher if you will16:08
prologicHTTP -> Default -> Dispatcher16:08
spaceonethere needs to be more abstraction layers16:08
prologiccertainly something that can be easily achieved16:08
prologicwithout breaking existing code16:08
prologicand allowing more flexibility in the application code16:08
prologicnot sure what to call this component though16:09
spaceonehmm, dunno too16:09
spaceonehmm no16:09
prologicand rename the current Dispatcher to something else?16:09
prologicyeah I dunno16:10
prologicneed to have a meaningful name16:10
prologicand then we can split that out16:10
spaceonei dont like the current dispatcher16:10
prologicit would also handle HTTP Errors as well16:10
prologicrather than letting the HTTP Component do it16:10
spaceoneit is the logic from cherrypy16:10
prologicand I think it should also handle default responses as well16:10
prologicso HTTP is just doing parsing and buffering16:10
prologicbefore firing to this 2nd component16:10
prologicwhich does a bit more processing16:10
prologicthen fires to a dispatcher16:11
spaceonei think a important thing is the design of "resources"16:11
prologicthe current dispatcher also dispatches to GET/PUT/POST/DELETE16:11
prologicdid you know?16:11
spaceonei did not see one really example of the powerfullnes16:12
spaceonei only saw small examples with one method (index)16:12
spaceoneit was also not clear to me which methods are 'exposed' and which not16:12
prologicperhaps I'll expand the docs to make that clear16:13
prologichave you read the latest dev docs I wrote last night on circuits.web?16:14
spaceonealso do not write for everything a 10 line example code which is always almost the same16:14
spaceonebecause i can't remember the url16:14
prologicit's all linked at :)16:15
prologicok so the default dispatcher's behavior is:16:15
prologica) to map urls to events (a bit like cherrypy's url -> object tree mapping) but not quite the same16:15
prologicwe simply map to events16:15
prologicControllers by default have a channel of "/"16:15
prologicwhich can be overridden by subclasses16:15
prologicthis affects the lookup of url -> event16:16
prologicthe 2nd thing that the default dispatcher does16:16
prologicis also dispatch to HTTP methods (GET, PUT, POST, DELETE) in the same way16:16
prologiciif they exist16:16
prologicPerhaps a more complete example?16:16
prologicI can write one quickly16:16
spaceoneno, it is more clear now16:18
spaceonedont waist the time16:19
prologicoh really?16:19
prologicwhat I said made it more clear?16:19
prologicor the new circuits.web docs?16:19
prologicI think there's still more content I can put in them16:19
spaceonethe docs16:20
prologicoh cool :)16:21
prologicthat means I did a somewhat good job :)16:21
spaceonebut i still don't like it :D16:21
prologicwrote all that last night16:21
prologicstill a couple of things left todo16:21
prologicstill don't like the default dispatcher?16:21
prologicwhat does it lack for you?16:22
spaceonei will tell you more about it the next days16:22
prologicor what dispatcher are we missing?16:22
prologicbecause there are 5 others16:22
prologickk nps :)16:22
prologicI'm always up for improving things16:22
prologic-but - let's improve circuits.web rather than fork or create a separate thing16:22
prologicie: abstract away as much as possible to make application code easier16:23
spaceonethat is hard for me16:23
spaceonebecause i am a strict HTTP use16:23
spaceonei hate those redefinements of things (like RPC, cookies, etc.)16:24
spaceonei also want every resource to be available in multiple variants16:25
spaceoneyou can see all this in SF16:25
prologicno what I mean is improve the components we have16:25
prologicin your case you would:16:25
prologicfrom circuits.web import BaseServer, ResourceDispatcher16:25
prologic(BaseServer(8000) + ResourceDispatcher() + MyResource()).run()16:26
prologicfor example16:26
prologicthat's where I'd like to see us improve things16:26
prologicso you get pure HTTP16:26
prologicplus a dispatcher that suits the job16:26
prologicand your application code16:26
prologicdoes that make sense?16:26
spaceonein a way yrs16:26
prologicServer(8000, dispatcher=ResourceDispatcher)16:26
prologicie: change the default to something else16:27
spaceonehmm no16:27
spaceonei would prefer the first16:27
spaceoneit is simpler, cleaner, and modular16:28
prologicthat's fine :)16:28
prologiceither or could be done or both16:28
prologicbut yeah the former is cleaner/simpler16:28
prologicbut does that sound more like what you need?16:28
prologica Resource Dispatcher?16:28
prologicand some kind of Resource base component/controller16:28
prologicI must be misunderstanding :)16:29
spaceonewith HTTP you transer various varians (representations) of resources which are identified by an URI16:29
spaceoneso we need an URIDispatcher16:29
spaceoneand a BaseComponent "Resource"16:30
spaceoneand events for HTTP headers16:30
prologicand a URIDispatcher would dispatch how?16:30
prologicjust dispatcher the request itself without mapping anything?16:30
spaceoneoh of course with mapping16:30
prologichow would the mapping work then?16:30
prologicURI -> <what>?16:31
spaceonethe URIdispatcher should map HOST and PATH16:31
spaceonemaybe this are two things (dispatcher) maybe not16:31
prologicsounds like our VirtualHosts dispatcher :)16:32
prologicwhich does channel manipulation based on host16:32
spaceonejah, but that requires an prefix of every path16:32
spaceonethats ugly16:32
spaceonebtw, is it possible to run 2 servers? one for HTTP and one for HTTPS?16:33
prologicjust provide a different channel to run the 2nd server in16:33
spaceonei did not understand what a channel is16:34
prologicSo this is ugly?16:34
prologicahh ok16:34
prologica channel is a way to separate components that listen to the same types of events16:35
prologiceg: running two servers at once, or two irc bots at once, etc16:35
spaceonebtw. i am new to programming, (i am 19 yrs old, doing apprentice at a comp. which creates a linux distibution)... i think i have talent and am a good programmer, but i don't know many names for programming patterns or such things and have to learn how to solve specific things in a senseful way16:36
prologicthat's ok :)16:37
prologicjgiorgi is quite young too iirc16:37
prologicbasically every component in circuits has 2 things16:37
prologica channel that separates it from other components16:37
prologicand a set of event handlers that listen to specific events16:38
prologicthe basic form:16:38
prologicclass Foo(Component):16:38
prologic   channel = "foo"16:38
prologic   def foo(self):16:38
prologic      return "FooBar"16:38
prologicwould return "FooBar" for any:16:38"Foo"), "foo")16:39
prologicSimple example:16:41
prologicnotice the, "*")16:41
prologicfire on all channels16:41
spaceoneok, can you give an example where it makes sense to use multiple channels?16:42
prologiconly when you want to separate things that might have the same event16:44
prologicin general though it's nice to do things like:16:44
prologicclass Logger(Component):16:44
prologic   channel = "log"16:45
prologic   def error(self, *args):16:45
prologic      ...16:45
prologicand in your app16:45"foobar!"), "log")16:45
prologicwith the ircnotifier I wrote last night at
prologicit makes uses of separate channels16:46
spaceoneok, it is clearer now (not everything is clear but i will give it time, unserstanding and learning is a process)16:46
prologicthere's a "bot" channel and "web" channel in use16:46
prologicit is :)16:47
prologicin circuits the way you're meant/encouraged to design things16:47
prologicis by using components, channels and events16:47
prologicto keep all your functionality loosely coupled16:47
prologicthat means basically components should not know about each other per say16:48
prologicand the interfaces between various parts of your system are "events"16:48
prologicso you could for any arbitrary component rip it out16:48
prologicand replace with another similar component that reacts the same way16:48
spaceonehow would a controller work?16:48
prologicthen on top of this is circuits powerful messaging system16:48 .call(...) and .wait(...)16:49
prologicwith handler filtering and prioritization and event feedback capabilities16:49
prologicwell the way we designed BaseController and Controller16:49
prologicis similar to how we designed BaseComponent and Component16:50
spaceoneah btw. please explane: @handler(priority=???)16:50
prologicone is explicit exposing of urls -> event handlers16:50
prologicthe other is implicit16:50
prologicand it's just a container of event handlers that get mapped to requests16:50
prologicby the Dispatcher ofc16:50
prologicBaseController and subclasses only work with the (default) Dispatcher16:50
prologicit listens for registration of them in the system16:51
prologicthe docstrings in @handler are poorly formatted - sorry16:52
prologicBut basically:16:52
prologictwo ways of specifying event handlers16:52
prologicimplicitly (provided by Component)16:52
prologicor explicitly (using BaseComponent) or just using @handler16:53
prologic@handler(*names, **kwargs):16:53
prologicnames is a tuple of event names you want to listen to16:53
prologicand **kwargs some optional parameters that control aspects of the handler16:53
spaceoneso there could be an event for the Expect header with a very high priority, which listens on all http channels?16:55
spaceonehandler for the event*16:55
prologicwhich is why I suggested an in-between component16:58
prologicto handle some of the default behavior16:59
prologicwhich application code would simply override by filtering at a higher priority16:59
spaceone(why not overriding by overwrinting the method when subclassing)?17:00
spaceoneah wait17:02
spaceone@handler: def foo('ExpectEvent', prio=1); @handler: def bar(??, prio=2, filter=ExpectEvent|bar)17:04
prologicahh because that breaks loose coupling :)17:04
prologicyou override the event handler instead17:04
prologicor the event17:04
prologicfilter is a boolean17:05
prologicso it would be17:05
prologic@handler("Expect") in both cases17:05
prologicjust with different priorities17:05
spaceoneand filter defined to filter all other events?17:05
spaceoneso that they are not executed?17:05
prologicno just the one it's defined for17:06
prologic@handler("foo", filter=True)17:06
prologicif you return a True-ish value from the handler, no other handlers will run17:06
spaceoneand priority defined the order in which they are executed?17:06
prologicfor Foo17:06
spaceoneso priority is incompatible to filter?17:06
spaceonefilter removes every other handler for event X17:07
spaceonepriority says in which order the handlers of event X are executed?17:07
prologichang on17:08
prologicthe sort key is17:08
prologic(handler.priority, handler.filter)17:08
prologicso it ordered by priority first, then filter17:08
spaceonefilter filters every event after handler.priortiy?17:09
prologichang on17:09
prologicok so let me explain again17:10
prologicboth priority and filter affect the order of the handlers (execution)17:10
prologicevent handlers are sorted by priority first, then whether or not it's a filter17:10
prologicNow if an event handler is marked as a filter (filter=True) and17:11
prologiciif the event handler returns a value that is True-ish17:11
prologicno other event handler will run for that specific event17:11
prologicthat's it17:11
spaceonethat should be documentated (but not in a docstring, in an own section ("how handlers work"))17:13
spaceonewith some examples17:14
spaceone"""If you want to override a handler defined in a base class of your component, you must specify override=True, else your method becomes an additional handler for the event."""17:16
spaceoneexplain that please17:16
prologicI'll bbl - going up to see my mum17:20
prologicwe'll talk more then :)17:20
spaceone(it is 02:17 AM, i will go to sleep soon)17:20
prologicgood :)17:22
prologicI will write a new document on how handlers work17:22
prologicthanks for the suggestion17:22
prologictalk tomorrow17:23
*** EMOKDOOM has joined #circuits20:15
prologicthere we go :)20:15
prologichi EMOKDOOM20:15
*** ircnotifier has quit IRC20:52
*** ircnotifier has joined #circuits21:03
*** ircnotifier has quit IRC21:10
*** ircnotifier has joined #circuits21:11
*** ircnotifier has quit IRC21:12
*** ircnotifier has joined #circuits21:12
*** naq has joined #circuits21:13
*** ircnotifier has quit IRC21:14
naqhi, is anyvody online?21:14
*** ircnotifier has joined #circuits21:15
EMOKDOOMSLow, but yes, i assume21:19
naqcan you help me with a question I have?21:20
naqwhat does GF(M) stands for on a capacitor21:20
naqnevermind, I think I got an answer21:22
prologicnaq, sorry dude21:22
prologicyou're in the wrong place :)21:22
prologictry #electronics :)21:22
naqI've been there but it's too much traffic and nobody answered21:22
prologicWell a Python Application Framework isn't going to be of much help either I'm afraid :)21:22
prologicI'm a Software Engineer21:23
prologicnot an Electronic Engineer :)21:23
EMOKDOOMMy electronics knowledge only goes as far as my car knowledge goes21:24
EMOKDOOMEven then it was 'if it's broken just replace it'21:24
EMOKDOOMhey pro check this out:!/exercises/121:25
EMOKDOOMCant get the comp to let me pass wanna help me? :]21:26
prologicone sec21:26
EMOKDOOMthis is my code21:26
EMOKDOOMdef grades_sum(x):21:26
EMOKDOOMtotal = 021:26
EMOKDOOMfor i in x:21:26
EMOKDOOMtotal += i21:26
EMOKDOOMreturn total21:26
EMOKDOOMdef grades_average(grades):21:26
EMOKDOOMaverage = grades_sum(grades) / len(grades)21:26
EMOKDOOMreturn average21:26
EMOKDOOMprint grades_average(grades)21:26
prologicand it's wrong?21:27
EMOKDOOMI THINK it's right21:31
EMOKDOOMbut the system shoots back and error message to try again21:32
EMOKDOOMone sec21:37
EMOKDOOMmy damn internet is running like a snail21:37
EMOKDOOMIt seem like i did the same thing like in the first one though21:37
EMOKDOOMexcept the float part21:37
EMOKDOOMaverage= 7.6923076923121:39
EMOKDOOMYeah i'm sure it's a bug21:39
prologicSo lesson #121:44
prologicDon't unnecessarily reinvent the wheel :)21:44
prologicPython has lots of builtin functions21:44
prologice.g: sum(xs)21:44
prologicWhich takes a list or an iterable of numbers (ints, flotas, etc)21:44
prologicand computes the sum21:44
EMOKDOOMYeah haha21:45
EMOKDOOMThe lesson wanted the long way though but thanks :]21:45
prologicHave a read through of Python builtins21:46
prologicThere are many things you can do out of the box without writing too much code21:46
prologicRemember: Less is more21:46
prologicfor example. here's a function that will give you a list of odd numbers21:47
prologicodds = filter(range(10), lambda i: i % 2)21:48
prologic>>> odds = filter(lambda i: i % 2, range(10))21:49
prologic>>> odds21:49
prologic[1, 3, 5, 7, 9]21:49
prologicsorry other way around :)21:49
EMOKDOOMwhats lambd21:49
prologicsyntax for writing anonymous functions in python21:50
prologictakes the form of:21:50
prologiclambda *args: expression21:50
EMOKDOOMit was a damn indentation error!!21:58
EMOKDOOM30 minutes gone :321:59
*** EMOKDOOM has quit IRC22:20
prologicyes well that CA editor seems to suck a bit22:22
prologicoh well :)22:22
*** ircnotifier has quit IRC23:41
*** ircnotifier has joined #circuits23:42
*** ircnotifier has quit IRC23:52
*** ircnotifier has joined #circuits23:52
*** ircnotifier has quit IRC23:58
*** ircnotifier has joined #circuits23:58

Generated by 2.11.0 by Marius Gedminas - find it at!