Giter Club home page Giter Club logo

Comments (6)

deanishe avatar deanishe commented on July 28, 2024

As mentioned in #16, JSON doesn't support common Python objects. That's the reason Workflow doesn't use it except to store the settings (the settings file has to be in one human-readable format or another, and JSON allows a nicer API than, e.g., ConfigParser).

The lack of stored_data() and store_data() methods is mostly due my belief that cache_data(name, data) and cached_data(name, max_age=0) achieve the same results (albeit using a different directory).

They should probably be added as a way to put data in the data directory, but I think they would also have to use pickle, at least by default: the choice to use a different on-disk format needs to be consciously made by the user because it probably won't accept arbitrary data.

Both the store_data and cache_data methods could be modified to accept serializer and extension arguments to use any custom serialiser that supports the dump(obj, fp)/load(fp) interface.

from alfred-workflow.

fractaledmind avatar fractaledmind commented on July 28, 2024

I've added a Pull Request with these features added. I didn't add an extension arg tho; I simply use the serializer name as the extension. pickle is the default serializer for all 4 data storage methods, but user's can set there own serializer on instantiation. That seems a good balance of safe defaults, but extensibility.

from alfred-workflow.

fractaledmind avatar fractaledmind commented on July 28, 2024

PS. This is all coming up because I'm rewriting ZotQuery from the ground up, and I'm really trying to take advantage of Alfred Workflow this time. I'm also trying to have cleaner, smarter data storage and models. The logic of the cached_data method is genius, since you can grab or create data with one call, but I want to store ZotQuery data in permanent storage and in JSON format. Thus, my desire for the changes. However, I reiterate, this is a great tool, so thank you.

from alfred-workflow.

deanishe avatar deanishe commented on July 28, 2024

WRT permanent storage: data in the cache dir only gets deleted when a user explicitly deletes their caches using some tool like OnyX.

It's generally a dumb idea to delete the cache unless something is going wrong: the data is there to speed things up.

The difference is mostly semantic: data in caches is ephemeral or can be easily recreated; data stored in data directories is user-generated and can't be automatically recreated (e.g. settings).

I'm certainly open to using the data directory as the storage for the cache_ functions if the potential deletion of the data is an issue. Workflow does a fair job of managing the data (it isn't going to fill the cache with endless gigabytes of shite unless actively abused).

from alfred-workflow.

deanishe avatar deanishe commented on July 28, 2024

BTW, what did you decide to do regarding search? Are you going to try sqlite?

from alfred-workflow.

deanishe avatar deanishe commented on July 28, 2024

Added store_data() and stored_data() methods, plus SerializerManager

See v1.8.

from alfred-workflow.

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.