Giter Site home page Giter Site logo

Comments (7)

dlqqq avatar dlqqq commented on June 9, 2024

@dleen I think the simplest way would be to allow users to configure what events a FIM listens to. That way, you can disable the FIM from listening to delete events from the CM, call get_id(<path>) and delete the associated commenting data, and then call FIM.delete() yourself (since all event listeners are public methods anyways).

This would be a pretty simple change to implement, do you want to give it a try? We use traitlets.config to implement configurability of our classes. You would want to define a new trait that accepts a list that defines the CM event actions the class will listen to, say self.cm_actions. This trait should default to listening to all the actions, e.g. default to the value ["get", "save", "rename", "copy", "delete"]. Then, you would want to change the logic of the below method to bind the action to None if the action isn't listed in self.cm_actions.

def get_handlers_by_action(self) -> Dict[str, Optional[Callable[[Dict[str, Any]], Any]]]:
    return {
        "get": None,
        "save": lambda data: self.save(data["path"]),
        "rename": lambda data: self.move(data["source_path"], data["path"]),
        "copy": lambda data: self.copy(data["source_path"], data["path"]),
        "delete": lambda data: self.delete(data["path"]),
    }

from jupyter_server_fileid.

kevin-bates avatar kevin-bates commented on June 9, 2024

Specifically tuning FIM's event listener works fine if your application is the only server extension in town. However, if other server extensions expect, in this case, "delete" events, they'll be screwed.

Seems like @dleen's suggestion of FIM emitting events (index, move, delete, copy?) and letting each server extension determine which events are pertinent is a good way to go. This eliminates the ambiguity of which listener acts first on the same event and doesn't interfere with multiple server extension configurations.

from jupyter_server_fileid.

dlqqq avatar dlqqq commented on June 9, 2024

@kevin-bates I'm not quite sure I follow. Dependent extensions need to be able to query for the file ID before the FIM deletes the record, not before. Emitting an event in the FIM methods to allow extensions to respond after deletion doesn't seem to solve @dleen 's issue.

from jupyter_server_fileid.

dleen avatar dleen commented on June 9, 2024

The deletion event would include the ID of the file deleted which would probably work

from jupyter_server_fileid.

kevin-bates avatar kevin-bates commented on June 9, 2024

Correct. All you (@dleen) need is the ID. This way the ambiguity is resolved. All events emitted by the FIM would include the corresponding ID(s).

from jupyter_server_fileid.

dlqqq avatar dlqqq commented on June 9, 2024

Ah, thank you both for clarifying. Then yes, we could implement support for this.

(btw I'm insanely busy with Jupyter AI, so I'd love to accept open source contributions for any of the issues opened recently, just reach out to me so I can assign you 🤗)

from jupyter_server_fileid.

dleen avatar dleen commented on June 9, 2024

Yes I'm willing to work on these issues - just wanted to discuss before jumping into the code

from jupyter_server_fileid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.