Hi Thierry,
On 28 Oct 2013, at 11:31, Goubier Thierry <[email protected]> wrote:
> Le 28/10/2013 11:18, Sven Van Caekenberghe a écrit :
>> Thierry,
>>
>> ZnUrl now implements #mcRepositoryAsUser:withPassword: though it is
>> currently a hack.
>> Do you have a suggestion how to make it extendable ?
>> I will think about it as well, I do have some ideas.
>
> Well, I would just move the schemeName on the repository class and add a
> fromUrl:asUser:withPassword: in the repository instance creation, and change
> the mcRepositoryAsUser:withPassword: to search among repository types based
> on the scheme in the url and dispatch with a call to
> fromUrl:asUser:withPassword: on the right repository class.
Sounds like an excellent idea/design.
The dispatching/searching could be done on all subclasses of MCRepository,
maybe using a more general #handlesUrl: method that for now just says ^ url
scheme = #http but is general enough for potential special cases in the future.
Having an instanciation class method on MCRepository subclasses like #fromUrl:
would then do the actual action.
The fact that username/password are passed as arguments while they could be
part of the url is strange, but maybe necessary since you might not want them
in the url proper - but the url can be freely manipulated (like safeUrl := url
copy; username: nil; password: nil; yourself).
Now, your idea solves the problem entirely external to ZnUrl itself, maybe it
will hinder portability of Monticello itself (but the version in Pharo is
probably customised anyway) ?
My idea was to have some kind of global registry for actions to be performed on
ZnUrl, the arguments being the url, an operation name, and an optional
argument, ZnUrl>>#performOperation:withArgs: - To register a handler you
specify a selection block, ZnUrl class>>#registerOperationWhen:do:
For example, there is currently ZnUrl>>#resolve which should work differently
on file urls.
ZnUrl>>#resolve
^ self performOperation: #resolve withArgs: nil
ZnUrl
registerOperationWhen: [ :url :operation :args |
(url scheme = #http | url scheme = #https) & operation = #resolve ]
do: [ :url :args |
ZnClient new
beOneShot;
enforceHttpSuccess: true;
get: self ].
ZnUrl
registerOperationWhen: [ :url :operation :args |
url scheme = #file | operation = #resolve ]
do: [ :url :args |
url asFileReference contents ].
#performOperation:with: would search for a handler whose condition block
matches and then execute it. But I am not 100% sure about this idea myself ;-)
It is extendable but is require registration which can be a bit brittle.
Sven
> Thierry
>
>> Sven
>>
>> On 28 Oct 2013, at 11:18, Goubier Thierry <[email protected]> wrote:
>>
>>> Hi All,
>>>
>>> Url has been deprecated. What is to be done with the Monticello use of the
>>> subclasses of Url?
>>>
>>> At the moment, ZnUrl has a hardcoded case switch to redirect on the right
>>> type of repository [1], but... It's not extendable, and breaks
>>> gitfiletree://.
>>>
>>> [1]
>>> https://github.com/pharo-project/pharo-core/blob/e89b4ac70d5cef761667317d58a4496d443d8a4e/Gofer-Core.package/extension/ZnUrl/instance/mcRepositoryAsUser_withPassword_.st
>>>
>>> Thierry
>>> --
>>> Thierry Goubier
>>> CEA list
>>> Laboratoire des Fondations des Systèmes Temps Réel Embarqués
>>> 91191 Gif sur Yvette Cedex
>>> France
>>> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
>>>
>>
>>
>>
>>
>
> --
> Thierry Goubier
> CEA list
> Laboratoire des Fondations des Systèmes Temps Réel Embarqués
> 91191 Gif sur Yvette Cedex
> France
> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95