IRC Logs for #circuits Tuesday, 2013-07-16

jgiorgiprologic, not really, i still cant seem to reproduce it outside the original00:31
jgiorgii had an index handler on "/login" accepting optional kwargs user, passwd and redirect00:32
jgiorgithe handler itself was usually called as a result of a redirect from a failed or null auth elsewhere00:32
jgiorgioccasionally the user argument was a Request object but i cant seem to find anywhere that would set that00:32
jgiorgii corrected it by a bit of juggling and i might be on to a possible cause00:33
prologickeep me posted on your progress00:35
prologicremember that the methods of a Controller are decorated with @expose automatically00:35
prologicwhich are then in turn decorated with @handler00:35
prologicimplicitly the underlying handler receives the request, response tuple as it's first two arguments00:36
prologicso if for example you are trying to call the method directly inside code00:36
prologicyou should pass request, response as the first two arguments00:36
prologicthen everything else00:36
jgiorgii wasnt calling it within code00:41
jgiorgialso there seems to be a bug with the call primitive inside a Controller00:41
jgiorgithree tests in one00:51
jgiorgitesting just the Component and no Controller + Server the call primitive works perfectly00:51
jgiorgiwithin a Controller it fails, i tried two ways: 1 is directly using within an exposed handler and yielding the value, this times out00:53
prologichow does .call() not work inside a Controller?00:53
jgiorgi2 is using a method to wrap the use of call so the exposed handler can return the value, same except this time there's nonetype exceptions in the debugger output00:54
prologicthe wrapped version won't work00:54
prologicyou -have- to yield no matter what00:54
prologicif you use call/wait00:55
prologicthis is using generators as coroutines00:55
jgiorgieffectively i wrap in a generator, iterate over it and return the last output which should be x.value x being the result of yield
jgiorgiit was just a thought to see if circuits.web wasn't handling the yield statement properly00:56
prologicit should00:56
prologicbut the semantics should be the same00:56
prologicthe handler must yield at all times00:56
prologicdef index(self):00:56
prologic   x = yield
prologic   yield x00:57
prologicthere is no other way to do this00:57
prologicnot in Python < 3.400:57
jgiorgisure there is00:58
jgiorgidef _foo(self):00:58
jgiorgi  x = yield
jgiorgi  yield x00:58
jgiorgidef index(self):00:58
jgiorgi  x = self._foo()00:59
jgiorgi  return x00:59
jgiorgi(actually i should have iterated over the generator once in index)00:59
jgiorgii did that for a while to workaround a different bug00:59
prologicthis is the only code that will work01:00
prologicalso NB: if the event never occurs01:00
prologicthen yes it will timeout01:00
prologicyou can specify a timeout value for call/wait IIRC01:00
prologicyeah no01:02
prologicyour example above will not work01:02
prologicfor two reasons01:02
prologica) you are not returning the generator back to the core of ircuits01:02
prologicso it will not interactively inspect the task and keep it running01:02
prologicb) if you try to do so manually you will block other handlers01:02
jgiorgireally, the channel was what was doing it? i feel dumb now01:03
jgiorgiadding , "*" makes the code work01:03
prologicotherwise it would have been fired to whatever the channel of the controller was01:04
jgiorgibut my handler is on "*" so it should have still been executed01:04
jgiorgiand in fact was being executed (tested by adding in print statements in the handler)01:04
prologicbut bare in mind the pattern I showed you01:04
prologicit will not work any other way01:05
prologicsorry :)01:05
prologicPython < 3.4 limitation01:05
prologicwhen circuits no longer supports Python < 3.401:05
prologicwe can start to use yield from internally01:05
prologicand things will be much nicer from your point of view01:05
prologicuntil then we're stuck with generator-style coroutines01:05
prologicwhere you have to yield control back to the manager01:05
prologicany call/wait must yield01:05
prologicyield self.wait(...)01:06
prologicyield x01:06
jgiorgigot it, those were among my first attempts01:07
jgiorgibut i deviate from the example when something doesnt work01:07
jgiorgiwell this makes things a lot easier on my now, i have to add in a few StopIteration's but i'll live01:08
prologicyou should not need to catch StopIteration01:15
prologicit's caught by the manager and terminates the task01:15
jgiorgiStopIteration when i want yield to be equivilent of return01:19
jgiorgiie heres some data, stop here01:19
jgiorgidef index(self, q=None):01:19
jgiorgix = yield
jgiorgiprint x.value01:19
jgiorgiyield x01:19
jgiorgihow can i make that work? that hangs, effectively i need to use the value before yielding it back for writing to the client01:20
jgiorginvm im an idiot01:25
prologicat the point where the manager returns control after the call/wait01:29
prologicthe value is then ready01:29
prologicso you can do whatever you want with it01:29
prologicbut you must still yield it01:29
prologicor yield a final result01:29
jgiorgithe channel argument is required even if channels is specified within the Event?01:44
prologicL384 of circuits/core/managers.py01:47
prologicIt will use *channels from the parameters passed in otherwise event.channels or getattr(self, "channel", "*") or "*"01:47
prologicevent.channels must be a tuple01:48
jgiorgievent.channels is a tuple, works, i have to specify then it works, but thats easy enough to handle01:50
jgiorgii hit something a bit more blocking, attempting to access self.request fails when i'm using call01:51
prologicthat I'm aware of01:57
prologicnot a lot I can do about it too01:57
jgiorgiis there a workaround?01:57
prologicthe semantics of generators means the call to the handler is lost01:57
prologicbut the stack is reinvokved01:57
prologicI haven't come up with one yet01:57
prologicthe self.request / self.response was convenient01:57
prologicbut doesn't work for a generator01:58
prologicwhich is what a handler that uses call/wait is01:58
prologicself.request / self.response is available up to the first point of the first yield01:58
prologicafter that it's no longer available01:58
jgiorgidamn, i need that data01:58
prologicyou can get it from the event object01:59
prologicdef index(self, event, *args, **kwargs):01:59
prologic   request, response = event.args[:2]01:59
jgiorgithat's a good enough workaround for me01:59
jgiorgiwhat about methods like self.forbidden02:05
jgiorgiwill they function?02:05
jgiorgiand where can i grab session?02:08
prologicthere is no session handling in circuits.web02:14
prologicyou have to do it yourself02:14
prologicyou can grab the session cookie02:14
prologicor any cookies via the Request object02:14
prologicself.forbidden() should work02:14
prologicbut if you're using call/wait02:15
prologicbest to probably raise Forbidden() from circuits.web.exceptions02:15
prologicI imagine02:15
prologicor just, response))02:15
prologicand yield02:15
jgiorgii can do that, i use circuits.web.Session so self.session is present (i assume it wont be now that im using call) so request.session?02:16
jgiorgiusing your example produces index() takes at least 2 arguments (1 given)02:16
jgiorgiso the event argument is not being passed02:16
prologicit should02:42
prologiclemme check02:42
jgiorgiprologic, this does not appear to be related to the use of call/wait, this example fails03:27
prologicyou are right03:58
prologiccould you file a bug please?03:58
prologicthat _should_ work03:58
prologicthe code is there for it03:58
prologicbut somehow it's broken03:58
jgiorgiok i'll file a bug report04:59
jgiorgifor now i guess i have to revert04:59
prologicfile a bug report on that05:07
jgiorgino worries, there's always a workaround05:07
prologicI'll see if I can fix it in dev sooner rather than later05:07
jgiorgii'll save the code in it's current state and just revert for basic functionality05:07
jgiorgibug report filed05:20
*** qwebirc73686 has joined #circuits07:49
*** tpelka has joined #circuits07:52
*** qwebirc73686 has quit IRC07:55
tpelkaHi all, I have a question regarding IRC bot, is there any method handling user transition to AWAY mode, like join() for user join or part() for user leave ?08:29
*** amee2k_ has quit IRC09:40
*** amee2k has joined #circuits09:41
*** amee2k has quit IRC10:21
*** amee2k has joined #circuits10:22
*** sweeper has joined #circuits11:54
*** koobs has quit IRC12:23
*** koobs has joined #circuits12:23
*** koobs has quit IRC12:30
*** koobs has joined #circuits12:30
*** koobs has quit IRC12:34
*** koobs has joined #circuits12:34
*** koobs has quit IRC12:41
*** koobs has joined #circuits12:42
*** tpelka has quit IRC15:25
*** LeuX has quit IRC17:07
*** LeuX has joined #circuits17:10
*** qwebirc60933 has joined #circuits18:20
*** qwebirc60933 has quit IRC18:22
*** Osso has joined #circuits20:17
*** Osso has quit IRC20:18
*** Osso has joined #circuits20:54
*** Osso has quit IRC21:10
*** Osso has joined #circuits21:15
*** Osso has quit IRC21:31
*** ChanServ has quit IRC22:43
*** spaceone has quit IRC22:43
*** jgiorgi has quit IRC22:43
*** koobs has quit IRC22:43
*** amee2k has quit IRC22:43
*** prologic has quit IRC22:43
*** koobs has joined #circuits22:46
*** amee2k has joined #circuits22:46
*** jgiorgi has joined #circuits22:46
*** ChanServ has joined #circuits22:46
*** spaceone has joined #circuits22:46
*** prologic has joined #circuits22:46

Generated by 2.11.0 by Marius Gedminas - find it at!