Adding entry to Firefox cache from an XPCOM component - firefox

The nsICacheSession has a method openCacheEntry() which returns an existing cache entry. Is there a method such as createCacheEntry() that will create a cache entry. I want to create an XPCOM object that will read files from disk and write them to Firefox cache.
Thanks

As stated in MDC nsICache interface reference opening an entry with ACCESS_WRITE will create the entry if it doesn't already exist (if it already exists, the entry will be doomed so you can replace it with a new one).
Perhaps a little too late for the original poster, but this can be useful for other people out there.

Related

Public Read and Write ACL despite all permissions being disabled

I have a class with all the permissions disabled, so it's available only to my cloud code while using the master key. But I looked at it today and I'm seeing that suddenly each of my objects has a Public Read and Write ACL.
What does it mean? I do not want anyone writing to, or reading from this class. Do I have to now set this in two different places?
I should add that this class contains information that I've added myself through the data browser. No app is writing to it.
I also found this a bit confusing and here's what I think is happening:
There appears to be the same notion of undefined for ACL's as for other cells. I think that is the default security ACL (non) value. However, when the ACL is undefined, it gets reported in the Data table viewer, under the ACL column, as "Public Read and Write". I suspect that someone at Parse decided that showing (undefined) for the ACL wouldn't do justice to informing the developers of the security risk of having no ACL for the row.
As evidence of what I'm thinking, I have noticed that when you click on an ACL cell (as if to edit), and it brings up the security dialog box for the ACL of the row, then, in the original cell itself (where you clicked, now in the background), it shows the text (in JSON) of the old ACL, if there is one actually defined, and shows (undefined) if there isn't one defined yet.
My observation is that class-specified security overrides what I'm calling the undefined ACL security setting.
IMHO, it would be better in this case if the Data view page showed something more illustrative: instead of "Public Read and Write", for example, "(undefined: see class security...).
Also, it is not yet clear to me how class security combines with row-defined ACLs (i.e. when present). If I find out one way or the other, I'll update...
(Also, fyi, sometimes it seems to me that you may have to give a few minutes before seeing security setting changes take effect.)

distinguish use cases in NSAutosaveElsewhereOperation

I try to add AutoSave support to the Core Data File Wrapper example
Now if i have a new/untitled document writeSafelyToURL is called with the NSAutosaveElsewhereOperation type.
The bad thing is, I get this type in both typical use cases
- new file: which store a complete new document by creating the file wrapper and the persistent store file
- save diff: where the file wrapper already exists and only an update is required.
Does somebody else already handled this topic or did somebody already migrated this?
The original sample use the originalStoreURL to distinguish those two use cases, which solution worked best for you?
Thanks

How to cache a collection in Magento?

I have a collection that takes significant time to load. What I would like is to cache it (APC, Memcache). It is not possible to cache the entire object (as it cannot be unserialized and it is over 1 MB). I'm thinking that caching the collection data ($col->getData() ) is the way to go, but I found no way to rebuild the object based on this array. Any clues?
Collections already have some caching built in but they need a little prompting so put this in the constructor of a collection:
$cache = Mage::app()->getCacheInstance();
$prefix = "SomeUniqueValue";
$this->initCache($cache, $prefix, array(Mage_Catalog_Model_Product::CACHE_TAG));
Choose tags appropriate to the content of the collection so that it will be flushed automatically. This way builds an ID based on the query being executed, it is most useful when the collection is filtered, ordered or paged - it avoids a version conflict.
Generally this hardly gets used because when you retrieve data you almost always end up displaying it, probably as HTML, so it makes sense to cache the output instead. Block caching is widely used and better documented.
I really don't know, but I searched for all the files that have the word "cache" in them with file names of "Collection.php" and got a few results. The most promising example to look at might be Mage_Sales_Model_Entity_Quote_Item_Collection (_getProductCollection() method). Looks like Varien_Data_Collection (which is a parent class of any magento collection) has a few cache-related methods: initCache() and _getCacheInstance().
Can't say I have used them before but might be useful someday.
Good luck.
You can get more information here: Can I use Magento's Caching layer as a Key/Value Store?
I'll be posting more info there as I find it.

Change mapping in the session

I have a Informatica session which is linked to a wrong mapping.
How do i change the mapping from M1 to M2 in the same session S1 and Workflow W1 WITHOUT importing/exporting as XML and making the changes ???
Invalidate the current mapping temporarily and refresh the session. This would allow you to choose a different mapping for your session. Pick the new one.
Don't forget to validate your old mapping.
Source: ITTOOLBOX
XML import/export is the only "official" way to do this. If you don't want to do that, you will have to create a new session S2 and attach the mapping M2 to that session.
One possible extra option, with disclaimer: If you have access to Informatica's Oracle database (that holds the metadata), you could perhaps make this change directly there. But you would really have to know what you're doing, or else you are likely to mess things up pretty badly. This is certainly not the recommended way of making changes!
The informatica metadata tables confuses you , dont change at that level. All the way is invalidate the mapping by removing port or by syntax errors. Workflw asks you new mapping. This is the best way apart all. Informatica should add new feature to allow us to do this.
XML export is one of the best way.
Export the session object and then edit the xml file where you need to change the mapping name. Now when you'd import it, it'll ask for the mapping to associate with.
This way you can do it.

Having one "brain" in a Firefox Addon?

I have an addon that every 5 minuets or so checks an rss feed for a new post, and if there is one, it displays an alert(). Problem is, I'm afraid that if the user opens multiple windows, that when there's a new post a millions of alerts will popup saying the same thing. Is there anyway to have just one "brain" running at a time?
Thanks in advance!
Look up something called "Javascript shared code modules" or JSMs.
Primary docs are here:
https://developer.mozilla.org/En/Using_JavaScript_code_modules
Each .js file in your addon that needs shared memory will open with the following line:
Components.utils.import("resource://xxxxxxxx/modules/[yourFilenameHere].jsm", com.myFirefoxAddon.shared);
The above line opens [yourFilenameHere].jsm and loads its exported (see below) functions and variables into the com.myFirefoxAddon.shared object. Each instance of that object loaded will point to the same instance in memory.
Note that if you want to have any hope of you addon making it past moderation, you will need to write all your code in a com.myFirefoxAddon.* type object as the goons at AMO are preventing approval of addons that do not Respect the Global Namespace
The biggest caveat for JSM is that you need to manually export each function that you want to be available to the rest of your code... since JS doesn't support public/private type stuff this strikes me as a sort of poor-man's "public" support... in any case, you will need to create an EXPORTED_SYMBOLS array somewhere in your JSM file and name out each function or object that you want to export, like this:
var EXPORTED_SYMBOLS = [
/* CONSTANTS */
"SERVER_DEBUG",
"SERVER_RELEASE",
"LIST_COUNTRIES",
"LIST_TERRITORIES_NOEX",
/* GLOBAL VARIABLES */
/* note: primitive type variables need to be stored in the globals object */
"urlTable",
"globals",
/* INTERFACES */
"iStrSet",
/* FUNCTIONS */
"globalStartup",
/* OBJECTS */
"thinger",
"myObject"
]
[edited] Modules are not the right solution to this problem, since the code will still be imported into every window and the whatever listeners/timers you set up will run in every window. You should be careful with using modules for this -- all the timers/callbacks must be set up in the module code (not just using the observer object defined in the module) and you shouldn't use any references to the window in the module.
The right way to do this is I would prefer to write an XPCOM component (in JS). It's somewhat complicated, yes and I don't have a handy link explaining how to do it. One thing: implementing it using XPCOMUtils is easier, older documentation will throw lots of boilerplate code on you.

Resources