Another question...(about WebUser)

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

Another question...(about WebUser)

Nicolas Petton
Hi,

First, I'm sorry for all this questions...

I want to add a new variable to WebUser. I added this :

WebUser>>website
        ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
put: '']

WebUser>>website: aString
        self otherValuesAt: 'website' put: aString

in a custom category, so no problem.

But what about views ? I would like to display the new feild in views
(WebAdminApp>>viewRegistration and
WebSecurityManagerApp>>userElementForm:).

My first idea was to subclass this apps, and override MyWebSite>>admin
and MyWebSite>>securityManager.

But if I do it, I need to create empty subclasses of WebAdmin and
WebSecurityManager too, and I really don't like it. Is there another way
to do it without creating those empty subclasses ?

Thanks,

Nicolas
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071026/1b971b07/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

Another question...(about WebUser)

Janko Mivšek
nicolas petton a ?crit :
> First, I'm sorry for all this questions...
>  
Don't worry, you are asking right and useful ones!

> I want to add a new variable to WebUser. I added this :
>
> WebUser>>website
> ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
> put: '']
>
> WebUser>>website: aString
> self otherValuesAt: 'website' put: aString
>
> in a custom category, so no problem.
>
> But what about views ? I would like to display the new feild in views
> (WebAdminApp>>viewRegistration and
> WebSecurityManagerApp>>userElementForm:).
>
> My first idea was to subclass this apps, and override MyWebSite>>admin
> and MyWebSite>>securityManager.
>
> But if I do it, I need to create empty subclasses of WebAdmin and
> WebSecurityManager too, and I really don't like it. Is there another way
> to do it without creating those empty subclasses ?
>  
You are right, better avoid subclassing and rather use extensions. So on
Squeak, if you have a package MyPackage, add method category *MyPackage
in class WebUser and that's it! You don't need change any other classes
in that case, specially not WebSecurityManager etc.

Janko

Reply | Threaded
Open this post in threaded view
|

Another question...(about WebUser)

Nicolas Petton

Le vendredi 26 octobre 2007 ? 11:08 +0200, Janko Miv?ek a ?crit :

> nicolas petton a ?crit :
> > First, I'm sorry for all this questions...
> >  
> Don't worry, you are asking right and useful ones!
> > I want to add a new variable to WebUser. I added this :
> >
> > WebUser>>website
> > ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
> > put: '']
> >
> > WebUser>>website: aString
> > self otherValuesAt: 'website' put: aString
> >
> > in a custom category, so no problem.
> >
> > But what about views ? I would like to display the new feild in views
> > (WebAdminApp>>viewRegistration and
> > WebSecurityManagerApp>>userElementForm:).
> >
> > My first idea was to subclass this apps, and override MyWebSite>>admin
> > and MyWebSite>>securityManager.
> >
> > But if I do it, I need to create empty subclasses of WebAdmin and
> > WebSecurityManager too, and I really don't like it. Is there another way
> > to do it without creating those empty subclasses ?
> >  
> You are right, better avoid subclassing and rather use extensions. So on
> Squeak, if you have a package MyPackage, add method category *MyPackage
> in class WebUser and that's it! You don't need change any other classes
> in that case, specially not WebSecurityManager etc.

But if I don't suclass, there will be no field for website (in the
registration form, and update form), right ? I didn't see the code for
this in WebSecurityManagerApp>>userElementForm: or
WebAdminApp>>viewRegistration

Nicolas
>
> Janko
> _______________________________________________
> Aida mailing list
> Aida at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071026/792e1888/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

Another question...(about WebUser)

Janko Mivšek
Hi Nicolas,

nicolas petton a ?crit :

>>> I want to add a new variable to WebUser. I added this :
>>>
>>> WebUser>>website
>>> ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
>>> put: '']
>>>
>>> WebUser>>website: aString
>>> self otherValuesAt: 'website' put: aString
>>>
>>> in a custom category, so no problem.
>>>
>>> But what about views ? I would like to display the new feild in views
>>> (WebAdminApp>>viewRegistration and
>>> WebSecurityManagerApp>>userElementForm:).
>>>
>>> My first idea was to subclass this apps, and override MyWebSite>>admin
>>> and MyWebSite>>securityManager.
>>>
>>> But if I do it, I need to create empty subclasses of WebAdmin and
>>> WebSecurityManager too, and I really don't like it. Is there another way
>>> to do it without creating those empty subclasses ?
>>>  
>>>      
>> You are right, better avoid subclassing and rather use extensions. So on
>> Squeak, if you have a package MyPackage, add method category *MyPackage
>> in class WebUser and that's it! You don't need change any other classes
>> in that case, specially not WebSecurityManager etc.
>>    
>
> But if I don't suclass, there will be no field for website (in the
> registration form, and update form), right ? I didn't see the code for
> this in WebSecurityManagerApp>>userElementForm: or
> WebAdminApp>>viewRegistration
>  
Then override those methods too with your own ones in your package and
you'll have the same result but without subclasing.

Janko

Reply | Threaded
Open this post in threaded view
|

Another question...(about WebUser)

Nicolas Petton

Le vendredi 26 octobre 2007 ? 13:44 +0200, Janko Miv?ek a ?crit :

> Hi Nicolas,
>
> nicolas petton a ?crit :
> >>> I want to add a new variable to WebUser. I added this :
> >>>
> >>> WebUser>>website
> >>> ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
> >>> put: '']
> >>>
> >>> WebUser>>website: aString
> >>> self otherValuesAt: 'website' put: aString
> >>>
> >>> in a custom category, so no problem.
> >>>
> >>> But what about views ? I would like to display the new feild in views
> >>> (WebAdminApp>>viewRegistration and
> >>> WebSecurityManagerApp>>userElementForm:).
> >>>
> >>> My first idea was to subclass this apps, and override MyWebSite>>admin
> >>> and MyWebSite>>securityManager.
> >>>
> >>> But if I do it, I need to create empty subclasses of WebAdmin and
> >>> WebSecurityManager too, and I really don't like it. Is there another way
> >>> to do it without creating those empty subclasses ?
> >>>  
> >>>      
> >> You are right, better avoid subclassing and rather use extensions. So on
> >> Squeak, if you have a package MyPackage, add method category *MyPackage
> >> in class WebUser and that's it! You don't need change any other classes
> >> in that case, specially not WebSecurityManager etc.
> >>    
> >
> > But if I don't suclass, there will be no field for website (in the
> > registration form, and update form), right ? I didn't see the code for
> > this in WebSecurityManagerApp>>userElementForm: or
> > WebAdminApp>>viewRegistration
> >  
> Then override those methods too with your own ones in your package and
> you'll have the same result but without subclasing.

Thank you Janko for your answers.
But if I do it, there will be another problem: this will be applied to
all AIDASites.

I have another idea, but I don't know how to do. I would like to
subclass WebSecurityManagerApp but without subclassing
WebSecurityManager. But is there a way to set a custom app to an object
(an app with a different name)? Something like:
UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp

Thank you,

Nicolas
>
> Janko
> _______________________________________________
> Aida mailing list
> Aida at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071026/f3ed0ff6/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

domain to App mapping (was Another question...(about WebUser)

Janko Mivšek
nicolas petton a ?crit :

> Le vendredi 26 octobre 2007 ? 13:44 +0200, Janko Miv?ek a ?crit :
>  
>> Hi Nicolas,
>>
>> nicolas petton a ?crit :
>>    
>>>>> I want to add a new variable to WebUser. I added this :
>>>>>
>>>>> WebUser>>website
>>>>> ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
>>>>> put: '']
>>>>>
>>>>> WebUser>>website: aString
>>>>> self otherValuesAt: 'website' put: aString
>>>>>
>>>>> in a custom category, so no problem.
>>>>>
>>>>> But what about views ? I would like to display the new feild in views
>>>>> (WebAdminApp>>viewRegistration and
>>>>> WebSecurityManagerApp>>userElementForm:).
>>>>>
>>>>> My first idea was to subclass this apps, and override MyWebSite>>admin
>>>>> and MyWebSite>>securityManager.
>>>>>
>>>>> But if I do it, I need to create empty subclasses of WebAdmin and
>>>>> WebSecurityManager too, and I really don't like it. Is there another way
>>>>> to do it without creating those empty subclasses ?
>>>>>  
>>>>>      
>>>>>          
>>>> You are right, better avoid subclassing and rather use extensions. So on
>>>> Squeak, if you have a package MyPackage, add method category *MyPackage
>>>> in class WebUser and that's it! You don't need change any other classes
>>>> in that case, specially not WebSecurityManager etc.
>>>>    
>>>>        
>>> But if I don't suclass, there will be no field for website (in the
>>> registration form, and update form), right ? I didn't see the code for
>>> this in WebSecurityManagerApp>>userElementForm: or
>>> WebAdminApp>>viewRegistration
>>>  
>>>      
>> Then override those methods too with your own ones in your package and
>> you'll have the same result but without subclasing.
>>    
>
> Thank you Janko for your answers.
> But if I do it, there will be another problem: this will be applied to
> all AIDASites.
>
> I have another idea, but I don't know how to do. I would like to
> subclass WebSecurityManagerApp but without subclassing
> WebSecurityManager. But is there a way to set a custom app to an object
> (an app with a different name)? Something like:
> UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp
>
>  
That's interesting idea and also a problem which needs to be solved
somehow. To solve most generally I would start with some object to App
map and add it to AIDASite, maybe in settings. Then I'd just extend
method Object>>webApp to look in this map too. What do you think?

Janko

Reply | Threaded
Open this post in threaded view
|

domain to App mapping (was Another question...(about WebUser)

Nicolas Petton

Le vendredi 26 octobre 2007 ? 14:18 +0200, Janko Miv?ek a ?crit :

> nicolas petton a ?crit :
> > Le vendredi 26 octobre 2007 ? 13:44 +0200, Janko Miv?ek a ?crit :
> >  
> >> Hi Nicolas,
> >>
> >> nicolas petton a ?crit :
> >>    
> >>>>> I want to add a new variable to WebUser. I added this :
> >>>>>
> >>>>> WebUser>>website
> >>>>> ^self otherValuesAt: 'website' ifAbsent: [self otherValuesAt: 'website'
> >>>>> put: '']
> >>>>>
> >>>>> WebUser>>website: aString
> >>>>> self otherValuesAt: 'website' put: aString
> >>>>>
> >>>>> in a custom category, so no problem.
> >>>>>
> >>>>> But what about views ? I would like to display the new feild in views
> >>>>> (WebAdminApp>>viewRegistration and
> >>>>> WebSecurityManagerApp>>userElementForm:).
> >>>>>
> >>>>> My first idea was to subclass this apps, and override MyWebSite>>admin
> >>>>> and MyWebSite>>securityManager.
> >>>>>
> >>>>> But if I do it, I need to create empty subclasses of WebAdmin and
> >>>>> WebSecurityManager too, and I really don't like it. Is there another way
> >>>>> to do it without creating those empty subclasses ?
> >>>>>  
> >>>>>      
> >>>>>          
> >>>> You are right, better avoid subclassing and rather use extensions. So on
> >>>> Squeak, if you have a package MyPackage, add method category *MyPackage
> >>>> in class WebUser and that's it! You don't need change any other classes
> >>>> in that case, specially not WebSecurityManager etc.
> >>>>    
> >>>>        
> >>> But if I don't suclass, there will be no field for website (in the
> >>> registration form, and update form), right ? I didn't see the code for
> >>> this in WebSecurityManagerApp>>userElementForm: or
> >>> WebAdminApp>>viewRegistration
> >>>  
> >>>      
> >> Then override those methods too with your own ones in your package and
> >> you'll have the same result but without subclasing.
> >>    
> >
> > Thank you Janko for your answers.
> > But if I do it, there will be another problem: this will be applied to
> > all AIDASites.
> >
> > I have another idea, but I don't know how to do. I would like to
> > subclass WebSecurityManagerApp but without subclassing
> > WebSecurityManager. But is there a way to set a custom app to an object
> > (an app with a different name)? Something like:
> > UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp
> >
> >  
> That's interesting idea and also a problem which needs to be solved
> somehow. To solve most generally I would start with some object to App
> map and add it to AIDASite, maybe in settings. Then I'd just extend
> method Object>>webApp to look in this map too. What do you think?

I think it's a very good idea :) This way it would easier to extend
existing models and apps, without overriding existing methods. If you
want I can do it (at least I can try).

Cheers,

Nicolas
>
> Janko
> _______________________________________________
> Aida mailing list
> Aida at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071026/2132bfb4/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

domain to App mapping

Janko Mivšek
nicolas petton a ?crit :

>>> I have another idea, but I don't know how to do. I would like to
>>> subclass WebSecurityManagerApp but without subclassing
>>> WebSecurityManager. But is there a way to set a custom app to an object
>>> (an app with a different name)? Something like:
>>> UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp
>>>      
>> That's interesting idea and also a problem which needs to be solved
>> somehow. To solve most generally I would start with some object to App
>> map and add it to AIDASite, maybe in settings. Then I'd just extend
>> method Object>>webApp to look in this map too. What do you think?
>>    
>
> I think it's a very good idea :) This way it would easier to extend
> existing models and apps, without overriding existing methods. If you
> want I can do it (at least I can try).
Yes, just try it, then we'll finish together. Another place for map can
beWebStyle, but that class is already overloaded ...

Janko

Reply | Threaded
Open this post in threaded view
|

domain to App mapping

Nicolas Petton

Le vendredi 26 octobre 2007 ? 16:28 +0200, Janko Miv?ek a ?crit :

> nicolas petton a ?crit :
> >>> I have another idea, but I don't know how to do. I would like to
> >>> subclass WebSecurityManagerApp but without subclassing
> >>> WebSecurityManager. But is there a way to set a custom app to an object
> >>> (an app with a different name)? Something like:
> >>> UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp
> >>>      
> >> That's interesting idea and also a problem which needs to be solved
> >> somehow. To solve most generally I would start with some object to App
> >> map and add it to AIDASite, maybe in settings. Then I'd just extend
> >> method Object>>webApp to look in this map too. What do you think?
> >>    
> >
> > I think it's a very good idea :) This way it would easier to extend
> > existing models and apps, without overriding existing methods. If you
> > want I can do it (at least I can try).
> Yes, just try it, then we'll finish together. Another place for map can
> beWebStyle, but that class is already overloaded ...

I tried it, and it seems to work fine.

Object>>webAppFor: aSession
        | webApp |
        aSession isNil ifTrue: [^nil].
        webApp := aSession webAppFor: self.
        webApp notNil ifTrue: [^webApp].
        webApp := self firstSessionFromStack site mappings at: self ifAbsent:
[].
        webApp ifNil: [webApp := WebApplication newFor: self on: aSession]
                ifNotNil: [webApp observee: self; session: aSession; postInitialize].
"I know, it's uggly, but it works !"
        webApp notNil ifTrue: [aSession addWebApp: webApp for: self].
        ^webApp


AIDASite>>mappings
        ^self settings at: #mappings ifAbsentPut: [Dictionary new].


AIDASite>>mapApp: aWebApplication for: anObject
        self mappings at: anObject put: aWebApplication


Then in my AIDASite subclass:

admin
        ^self systemServices
                at: #Admin
                ifAbsent: [ |admin|
                        admin := WebAdmin new.
                        self mapApp: MyWebAdminApp new for: admin.
                        self addSystemService: admin named: #Admin.
                        self urlResolver defaultURL: '/admin.html' forObject: self admin.
                        ^self admin].



Cheers,

Nicolas
>
> Janko
> _______________________________________________
> Aida mailing list
> Aida at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
--
Nicolas Petton
http://nico.bioskop.fr
             ___
           ooooooo
          OOOOOOOOO
         |Smalltalk|
          OOOOOOOOO
           ooooooo
            \   /
             [|]
--------------------------------
Ma cl? GPG est disponible ici :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE788C34D

-------------- section suivante --------------
Une pi?ce jointe non texte a ?t? nettoy?e...
Nom: non disponible
Type: application/pgp-signature
Taille: 189 octets
Desc: Ceci est une partie de message
        =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url: http://lists.aidaweb.si/pipermail/aida/attachments/20071026/0bc96cdc/attachment.sig 

Reply | Threaded
Open this post in threaded view
|

domain to App mapping

Janko Mivšek
Nicolas perfect! I'll look at your patch and integrate it in mainstream
Aida when I'll return home.

Thanks
Janko

nicolas petton a ?crit :

> Le vendredi 26 octobre 2007 ? 16:28 +0200, Janko Miv?ek a ?crit :
>  
>> nicolas petton a ?crit :
>>    
>>>>> I have another idea, but I don't know how to do. I would like to
>>>>> subclass WebSecurityManagerApp but without subclassing
>>>>> WebSecurityManager. But is there a way to set a custom app to an object
>>>>> (an app with a different name)? Something like:
>>>>> UrlResolver defaultUrl: '/admin.html' forObject: admin app: MyAdminApp
>>>>>      
>>>>>          
>>>> That's interesting idea and also a problem which needs to be solved
>>>> somehow. To solve most generally I would start with some object to App
>>>> map and add it to AIDASite, maybe in settings. Then I'd just extend
>>>> method Object>>webApp to look in this map too. What do you think?
>>>>    
>>>>        
>>> I think it's a very good idea :) This way it would easier to extend
>>> existing models and apps, without overriding existing methods. If you
>>> want I can do it (at least I can try).
>>>      
>> Yes, just try it, then we'll finish together. Another place for map can
>> beWebStyle, but that class is already overloaded ...
>>    
>
> I tried it, and it seems to work fine.
>
> Object>>webAppFor: aSession
> | webApp |
> aSession isNil ifTrue: [^nil].
> webApp := aSession webAppFor: self.
> webApp notNil ifTrue: [^webApp].
> webApp := self firstSessionFromStack site mappings at: self ifAbsent:
> [].
> webApp ifNil: [webApp := WebApplication newFor: self on: aSession]
> ifNotNil: [webApp observee: self; session: aSession; postInitialize].
> "I know, it's uggly, but it works !"
> webApp notNil ifTrue: [aSession addWebApp: webApp for: self].
> ^webApp
>
>
> AIDASite>>mappings
> ^self settings at: #mappings ifAbsentPut: [Dictionary new].
>
>
> AIDASite>>mapApp: aWebApplication for: anObject
> self mappings at: anObject put: aWebApplication
>
>
> Then in my AIDASite subclass:
>
> admin
> ^self systemServices
> at: #Admin
> ifAbsent: [ |admin|
> admin := WebAdmin new.
> self mapApp: MyWebAdminApp new for: admin.
> self addSystemService: admin named: #Admin.
> self urlResolver defaultURL: '/admin.html' forObject: self admin.
> ^self admin].
>
>