odd difference in behavior when using WADispatcher>>register:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

odd difference in behavior when using WADispatcher>>register:

LawsonEnglish
I got tired of having to manually either assign every application in
seaside its own password if I wanted to partially test deployment, so I
tried to move a specific set of applications inside an inner directory
and then give the directory a password. This works. However, I thought
I'd put the process in a loop, and it didn't work as I expected.

This works:

"++++++++++++++++++++++++++++++++++++++++++++++"

"NOTE: only do this after you have created the Dispatcher named
'innerdispatcher' and have made 'browse' the default application"

defaultH := WADispatcher default.
innerDispatcher := defaultH handlerAt: 'innerdispatcher'.

tests := defaultH handlerAt: 'comet'.
defaultH unregister: 'comet'.
innerDispatcher register: tests at: 'comet'.

tests := defaultH handlerAt: 'config'.
defaultH unregister: 'config'.
innerDispatcher register: tests at: 'config'.

tests := defaultH handlerAt: 'examples'.
defaultH unregister: 'examples'.
innerDispatcher register: tests at: 'examples'.

tests := defaultH handlerAt: 'javascript'.
defaultH unregister: 'javascript'.
innerDispatcher register: tests at: 'javascript'.

tests := defaultH handlerAt: 'seaside'.
defaultH unregister: 'seaside'.
innerDispatcher register: tests at: 'seaside'.

tests := defaultH handlerAt: 'status'.
defaultH unregister: 'status'.
innerDispatcher register: tests at: 'status'.


tests := defaultH handlerAt: 'tests'.
defaultH unregister: 'tests'.
innerDispatcher register: tests at: 'tests'.

tests := defaultH handlerAt: 'tools'.
defaultH unregister: 'tools'.
innerDispatcher register: tests at: 'tools'.

tests := defaultH handlerAt: 'files'.
defaultH unregister: 'files'.
innerDispatcher register: tests at: 'files'.
"++++++++++++++++++++++++++++++++++++++++++++++"

This only partially works (some of the Dispatchers are left unmoved):



"++++++++++++++++++++++++++++++++++++++++++++++"
defaultH := WADispatcher default.
innerDispatcher := defaultH handlerAt: 'innerdispatcher'.

defaultH handlers keysAndValuesDo:
     [:key :value|
         ((key = 'innerdispatcher' or: [key = 'browse']) or: [key =
'welcome']) ifFalse:
         [
             defaultH unregister: (defaultH handlerAt: key).
             innerDispatcher register: value at: key.
         ]
     ]
"++++++++++++++++++++++++++++++++++++++++++++++"


Any ideas?

--
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: odd difference in behavior when using WADispatcher>>register:

Bob Arning-2
It's always dicey to iterate over a collection that you are modifying. Iterate over a copy and update the original.

Cheers,
Bob


On 6/29/12 1:39 PM, Lawson English wrote:
This only partially works (some of the Dispatchers are left unmoved):



"++++++++++++++++++++++++++++++++++++++++++++++"
defaultH := WADispatcher default.
innerDispatcher := defaultH handlerAt: 'innerdispatcher'.

defaultH handlers keysAndValuesDo:
    [:key :value|
        ((key = 'innerdispatcher' or: [key = 'browse']) or: [key = 'welcome']) ifFalse:
        [
            defaultH unregister: (defaultH handlerAt: key).
            innerDispatcher register: value at: key.
        ]
    ]
"++++++++++++++++++++++++++++++++++++++++++++++"


Any ideas?




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: odd difference in behavior when using WADispatcher>>register:

Gastón Dall' Oglio
In reply to this post by LawsonEnglish
For test, normally I deploy an standart untrusted image, and then I run the image with an script like below to initialize some apps:

_________________________

"+++ Password Protection (choose the password) +++"

#('browse' 'comet' 'config' 'examples' 'status' 'tests' 'tools' 'welcome' 'piersetup' .........) do: [ :e | | h |
   h := (WADispatcher default handlerAt: e).
   h configuration addParent: WAAuthConfiguration instance.
   h preferenceAt: #login put: 'admin'.
   h preferenceAt: #passwordHash put: (GRPlatform current secureHashFor: 'share-password').
   h addFilter: WAAuthenticationFilter new ].
!

"+++ Start the adaptor (choose the port prefix). Note: only one adaptor of same type can exists +++"

ZnZincServerAdaptor startOn: 8509.
!
____________________


Regards.


2012/6/29 Lawson English <[hidden email]>
I got tired of having to manually either assign every application in seaside its own password if I wanted to partially test deployment, so I tried to move a specific set of applications inside an inner directory and then give the directory a password. This works. However, I thought I'd put the process in a loop, and it didn't work as I expected.

This works:

"++++++++++++++++++++++++++++++++++++++++++++++"

"NOTE: only do this after you have created the Dispatcher named 'innerdispatcher' and have made 'browse' the default application"

defaultH := WADispatcher default.
innerDispatcher := defaultH handlerAt: 'innerdispatcher'.

tests := defaultH handlerAt: 'comet'.
defaultH unregister: 'comet'.
innerDispatcher register: tests at: 'comet'.

tests := defaultH handlerAt: 'config'.
defaultH unregister: 'config'.
innerDispatcher register: tests at: 'config'.

tests := defaultH handlerAt: 'examples'.
defaultH unregister: 'examples'.
innerDispatcher register: tests at: 'examples'.

tests := defaultH handlerAt: 'javascript'.
defaultH unregister: 'javascript'.
innerDispatcher register: tests at: 'javascript'.

tests := defaultH handlerAt: 'seaside'.
defaultH unregister: 'seaside'.
innerDispatcher register: tests at: 'seaside'.

tests := defaultH handlerAt: 'status'.
defaultH unregister: 'status'.
innerDispatcher register: tests at: 'status'.


tests := defaultH handlerAt: 'tests'.
defaultH unregister: 'tests'.
innerDispatcher register: tests at: 'tests'.

tests := defaultH handlerAt: 'tools'.
defaultH unregister: 'tools'.
innerDispatcher register: tests at: 'tools'.

tests := defaultH handlerAt: 'files'.
defaultH unregister: 'files'.
innerDispatcher register: tests at: 'files'.
"++++++++++++++++++++++++++++++++++++++++++++++"

This only partially works (some of the Dispatchers are left unmoved):



"++++++++++++++++++++++++++++++++++++++++++++++"
defaultH := WADispatcher default.
innerDispatcher := defaultH handlerAt: 'innerdispatcher'.

defaultH handlers keysAndValuesDo:
   [:key :value|
       ((key = 'innerdispatcher' or: [key = 'browse']) or: [key = 'welcome']) ifFalse:
       [
           defaultH unregister: (defaultH handlerAt: key).
           innerDispatcher register: value at: key.
       ]
   ]
"++++++++++++++++++++++++++++++++++++++++++++++"


Any ideas?

--
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside