Fix crash with Python Algs & WS replacement.

The weak pointers dished out by the ADS weren't being handled properly
and a new shared_ptr was created from them when extracting the value
from the Python object. This effectively lead to two separate shared_ptr
objects, with different use counts, managing the same object. The fix was
to ensure the shared pointer is created from the weak pointer using the
lock method.
Refs #7101