Set context_key based on parent context_key

Fixes a bug where resources created from imports always have 'web' as the context_key rather than the actual context they are being created on.