On Wed, Mar 04, 2009 at 06:45:48PM -0800, Benjamin Collins wrote:
>
>
> On Mar 4, 8:01 pm, Robin Lee Powell <[email protected]>
> wrote:
> > Can you post a tarball of the whole thing somewhere?
>
> Sure: http://github.com/aggieben/simple-blog/tarball/broken-maybe-login
Sorry, got busy.
It definitely wasn't working, and as far as I can tell, you hadn't
failed to use it in any way.
In fact, I have no idea *how* it was working. My best guess is that
the login widget it inherits from would re-render no matter what
happened in :on-login.
I had a version in my tree that I hadn't put in the tutorial that
would expect the child widget to always be a zero-arg lambda, and
run that exactly once; it makes stuff nicer down the road.
Moving the logic for that into check-login gives this patch against
your tarball, which seems to work, and is The Right Thing anyway.
Thanks for giving me chance to clean this up outside of my own work;
I'll go put this new stuff in the tutorial too.
An earlier version simply set dirty in check-login; watching
weblocks freakout was funny, and also very happy-making: style and
error checking *GOOD*:
[2009-03-11 01:30:10 [WARNING]] During the rendering phase, 1 widgets were
marked dirty, which should typically be done only during action handling
[2009-03-11 01:30:10 [WARNING]] Warning while processing connection: During the
rendering phase, 1 widgets were marked dirty, which should typically be done
only during action handling
-Robin
--
They say: "The first AIs will be built by the military as weapons."
And I'm thinking: "Does it even occur to you to try for something
other than the default outcome?" -- http://shorl.com/tydruhedufogre
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en
-~----------~----~----~----~------~----~------~--~---
Only in aggieben-mine: data
Only in aggieben-mine: runblog.lisp
Only in aggieben-mine: .runblog.lisp.swp
diff -u -wr
aggieben-simple-blog-55181a9788c4fdb2ed83e68ccf92e774e43b8adf/src/layout.lisp
aggieben-mine/src/layout.lisp
---
aggieben-simple-blog-55181a9788c4fdb2ed83e68ccf92e774e43b8adf/src/layout.lisp
2009-03-04 18:47:53.000000000 -0800
+++ aggieben-mine/src/layout.lisp 2009-03-11 01:25:55.000000000 -0700
@@ -8,8 +8,8 @@
(list 'main blog)
(list 'admin (make-instance 'login-maybe
:on-login #'check-login
- :on-success #'login-success
- :child-widget
(make-admin-page))))))
+ ;:on-success #'login-success
+ :child-widget (lambda ()
(make-admin-page)))))))
(defun make-users-gridedit ()
(make-instance 'gridedit
Only in aggieben-mine/src: .layout.lisp.swp
diff -u -wr
aggieben-simple-blog-55181a9788c4fdb2ed83e68ccf92e774e43b8adf/src/widgets/login-maybe.lisp
aggieben-mine/src/widgets/login-maybe.lisp
---
aggieben-simple-blog-55181a9788c4fdb2ed83e68ccf92e774e43b8adf/src/widgets/login-maybe.lisp
2009-03-04 18:47:53.000000000 -0800
+++ aggieben-mine/src/widgets/login-maybe.lisp 2009-03-11 01:42:13.000000000
-0700
@@ -4,22 +4,23 @@
(defwidget login-maybe (login)
((child-widget :accessor login-maybe-child-widget
:initarg :child-widget
- :documentation "The widget to render if we are already logged
in.")
- (dom-id :initform "login"))
+ :documentation "The widget to render if we are
already logged in. Must be wrapped in (lambda () ...) so that the bits inside
can use auth information. The lambda will be run exactly once.")
+ (real-child-widget
+ :documentation "Where the result of the child-widget lambda gets
put."))
(:documentation "Render login form only if not logged in."))
(defmethod initialize-instance ((self login-maybe) &key &allow-other-keys)
(call-next-method)
(setf (widget-continuation self)
(lambda (&optional auth)
- (declare (ignore auth))
+ (declare (ignore auth)) ;unless you care...
(mark-dirty self))))
(defmethod render-widget-body((self login-maybe) &key &allow-other-keys)
(cond
((authenticatedp)
(hunchentoot:log-message :debug "=== authenticated! ===")
- (render-widget (login-maybe-child-widget self) :inlinep t))
+ (render-widget (slot-value self 'real-child-widget) :inlinep t))
(t
(hunchentoot:log-message :debug "=== not authenticated! ==")
(call-next-method))))
@@ -27,7 +28,14 @@
(defun check-login (login-widget credentials-obj)
"Check the user's login credentials"
(declare (ignore login-widget))
- credentials-obj)
+ (cond
+ ; For now, we accept anything
+ (t
+ (when
+ (login-maybe-child-widget login-widget)
+ (setf (slot-value login-widget 'real-child-widget) (funcall
(login-maybe-child-widget login-widget)))
+ (setf (login-maybe-child-widget login-widget) nil))
+ t)))
(defun login-success (lw cred-obj)
(declare (ignore cred-obj))
Only in aggieben-mine/src/widgets: .login-maybe.lisp.swp