On Sat, Feb 12, 2011 at 11:36 AM, Anthony <[email protected]> wrote:
> I am checking out Weblocks again for a project and I need to implement
> a feature like permalinks, where I give a unique URL to a user, via
> email and they would click the link to go to the web site.  The link
> url would like something like this:
>
> http://mycoolwebsite.com/auth/<some long random string or guid>/
>
> This URL would live forever and I could in theory have thousands of
> them.  Is selector or static-selector what I want to use for this or
> do I need to go directly to Hunchentoot for this functionality?

Basically, what you want for this is ON-DEMAND-SELECTOR.  Here's some
sample code from the app I'm writing:

(defwidget proposal-selector (on-demand-selector)
    ()
  (:default-initargs :lookup-function 'proposal-selector-lookup))

(defun proposal-selector-lookup (selector tokens)
  (declare (ignore selector))
  #.(locally-enable-sql-reader-syntax)
  (multiple-value-prog1
      (and (= (length tokens) 1)
           (let ((id (handler-case
                         (parse-integer (car tokens))
                       (parse-error () nil))))
             (and id
                  (let ((proposals (select 'proposal :where [= [id] id] :flatp 
t)))
                    (and proposals
                         (values (make-view-proposal-widget (car proposals))
                                 tokens nil nil))))))
    #.(restore-sql-reader-syntax-state)))

(defun make-view-proposal-widget (proposal)
  (make-widget
    (list (lambda (&rest args)
            (declare (ignore args))
            (render-object-view proposal (find-view 'proposal-public-view))))))

This is using integer id's; it does the conversion and calls
CLSQL:SELECT to pull the proposal out of the DB.  (Ignore the
weird-looking SQL syntax stuff if you don't recognize it; it's
CLSQL-specific.)

-- Scott

-- 
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.

Reply via email to