Comments (6)
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.
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.
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.
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.
BTW, what did you decide to do regarding search? Are you going to try sqlite
?
from alfred-workflow.
Added store_data()
and stored_data()
methods, plus SerializerManager
from alfred-workflow.
Related Issues (20)
- Cache Image HOT 5
- Basic auth HOT 3
- Pass parameter to subprocess HOT 5
- Tutorial options for keywords need to be updated for Alfred 4 HOT 11
- set_config raises error when the bundle id is null HOT 4
- Setting only arg on Variables adds line break HOT 1
- will it support python3? HOT 1
- python3 has no cpickle HOT 1
- cant get output HOT 11
- chr() arg not in range(256) error when trying to use Beautiful Soup 4 HOT 1
- workflow:magic not working?
- API functionality question
- AlertCautionIcon.icns does not exist on Big Sur
- ERROR: [Script Filter] JSON error
- Google SDK
- Can't get Script Filter to find the pinboard.py file from the tutorial HOT 1
- [Feature request] Possible to open bookmarks from root?
- Not working on the latest MacOS 12.3 HOT 11
- How to fetch chrome cookie?
- Issues with notify.notify in release version HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-workflow.