On Mon, Jan 31, 2011 at 10:27, Leslie P. Polzer <[email protected]>
wrote:
> What do you think is the best way to proceed with this?
I understand that I'm probably pain in the ass, but I'd really like to
understand what is going on, so that I can later on lookup in the
source and the net and not bother you or someone else.
I'd really like to understand what is happening in your example and
why. :-) For starters, I still don't understand why I can't use
default login and navigation widgets that come with weblocks?
> Are there some specific parts in the example that you don't
> understand?
If you don't mind, I'd like to dissect your example, so that I can try
to understand it better...
(defwidget protected-navigation (lazy-navigation)
((user-fn :type (or symbol function)
:accessor user-fn
:initarg :user-fn
:initform #'authenticatedp)
(login-widget :type (or widget null)
:accessor login-widget
:initform nil)
(login-widget-generator :type (or symbol function)
:accessor login-widget-generator
:initarg :login-widget-generator
:initform (f0 (make-instance 'login))))
(:documentation "Lazy navigation that checks whether
the user (as per USER-FN) is logged in. If they are then
this widget acts as a normal lazy navigation. If not then
the widget in the `login-widget' slot is shown or created
by calling LOGIN-WIDGET-GENERATOR."))
Ok, so :user-fn by default receives an result from authenticatedp. In
that case, I don't understand why in your example have you used (f0
(webapp-session-value 'user)), why would you have to set up additional
key in webapp-session-value?
:login-widget defines what widget will be used for login? Do I put in
there something like
:initform 'login
or my login widget that has my parameters (username instead of e-mail
as the login slot)?
If I do that, then I guess I could put
login-widget-generator :initform nil ?
I don't get exact specifics, but I do get that "get-widget-for-tokens"
parses uri. I don't know why you need it, but ok.
(defmethod render-navigation-menu ((navigation protected-navigation) &rest args)
(declare (ignorable args))
(when (funcall (user-fn navigation))
(call-next-method)))
Ok, let's say that I do understand that this method will be called if
the widget passed to render-navigation-menu is protected-navigation
widget. Like I said before, I still don't understand the need for
redefining navigation widget.
(defun init-user-session (root)
(setf (widget-children root)
(list
(make-widget (f_% (with-html (:p (esc (format nil "Current
user: ~S" (webapp-session-value 'user)))))))
(make-navigation "Main nav"
(list "hello" (make-widget "Hello, world"))
:navigation-class 'protected-navigation
:extra-args `(:user-fn
,(f0
(webapp-session-value 'user))
:login-widget-generator
,(f0
(make-widget
(f_%
(render-link
(f_% (setf
(webapp-session-value 'user) t)
(redirect
"/" :defer nil))
"Login")))))))))
Now, this one... I really don't understand what is going on here.
Well, I do kind of, but I don't understand how can I modify it for my
purposes. Why redefining :user-fn if in the widget you already have
authenticatedp? login-widget-generator - create function that creates
an widget that receives function that renders link, and when that link
is clicked, the user is set to t, so that the something,
protected-navigation knows that it is authenticated. I have tried
putting there my login widget, but there is an lack of understanding
on my side, so it doesn't work...
> Does something keep you from debugging the problems you're seeing?
I have managed to redirect backtrace into slime, which makes things
easier when there is an backtrace. I'm about to implement logging into
an file, because when I get an empty white web page, or an message
that there is too much redirection, there is not much to be debugged
from. I don't know yet how to debug or at least do a step trace into
sbcl threads.
--
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.