Aloe Express; MimeTypes;

  1. 4 weeks ago

    Hans-Norbert G

    is not verified Jun 26 Pre-Release Testers, Xojo Pro

    Hello,

    can You put another MimeType into Aloe Express?

    MimeTypes.Value("mjs") = "application/javascript"  // needed for ES6 modules

    in method MIMETypeGet

    By the way, dictionary is rebuild for every call to MIMETypeGet (even UseETags sends "not changed" to further calls to same file).
    Would a property as dictionary not be easier? (Don't know all the dependencies in Aloe Express either;-)

    Thanks a lot!

  2. Karen A

    Jun 26 Pre-Release Testers

    @Hans-NorbertGratzal Hello,
    By the way, dictionary is rebuild for every call to MIMETypeGet (even UseETags sends "not changed" to further calls to same file).
    Would a property as dictionary not be easier? (Don't know all the dependencies in Aloe Express either;-)

    Thanks a lot!

    I went through the code in detail. In my copy of the code I changed the start of the method from:

    Dim MimeTypes As New Dictionary
     ' Add all the MimeTypes

    To:

    STATIC MimeTypes As Dictionary
    
    If MIMETypes Is NIL Then
      MimeTypes = New Dictionary
      ' Add all the MimeTypes
    End if

    And it does not cause any issued... For something like this I like using Static as you only need to have one instance of the dictionary AND it does not clutter up the properties list (For almost 2 decades I wished I could put properties in classes and modules into folders to group/organize them when there is a lot in Xojo/RS/RB!)

    I also found a repository of MIMETypes on the web and added the ones not already there so for you use can add whatever MIMETypes you want.

    - karen

  3. Hans-Norbert G

    is not verified Jun 27 Pre-Release Testers, Xojo Pro
    Edited 4 weeks ago

    Hello Karen!

    Thanks a lot for Your info and the tipps!

    I also found a repository of MIMETypes on the web and added the ones not already there so for you use can add whatever MIMETypes you want.

    Of course, and I did so; but everything must be redone when getting a new version of the tool; but, no problem. Will keep it documented.

    STATIC MimeTypes As Dictionary
    
    If MIMETypes Is NIL Then
      MimeTypes = New Dictionary
      ' Add all the MimeTypes
    End if

    Very good idea to have a direct solution!
    I don't like Xojo's static because it's global to the class not to the method only; I even would consider it a "false static".

    Ok, everything works fine!
    Thanks a lot again!
    Regards!

  4. Greg O

    Jun 27 Xojo Inc

    @Hans-NorbertGratzal don't like Xojo's static because it's global to the class not to the method only; I even would consider it a "false static".

    In which case you should be using a private property on the class.

  5. Karen A

    Jun 27 Pre-Release Testers

    @Greg OLone In which case you should be using a private property on the class.

    In this case the list of MIMETypes should be same for all class instances. It makes no sense to recreate the dictionary for every instance...

    As this is for a server, one wants to keep system resource use (processor and ram) to a minimum, so it should either be DIMed as Static, or as a private shared property on the class, and only initialized once.

  6. Karen A

    Jun 27 Pre-Release Testers
    Edited 4 weeks ago

    @Hans-NorbertGratzal I don't like Xojo's static because it's global to the class not to the method only; I even would consider it a "false static".

    I think you are getting STATIC variables and SHARED properties mixed up.

    Static variables are private to the method but shared across all instances .When static variables are defined in instance methods, although shared across all instances they can only be accessed within that method within instances, and never outside that method either from inside or outside the class.

    Shared properties are global to the class and independent of any instance. You can set their scope to control if they can be accessed outside the class or not and from subclasses or not.

    - Karen

or Sign Up to reply!