from functools import wraps

from .utils import partial_prepare


def partial(func):
    """Wraps func to behave like a partial pipeline step, any output
    that's not None or {} will be considered a response object and
    will be returned to user.

    The pipeline function will receive a current_partial object, it
    contains the partial pipeline data and a token that is used to
    identify it when it's continued, this is useful to build links
    with the token.

    The default value for this parameter is partial_token, but can be
    overridden by SOCIAL_AUTH_PARTIAL_PIPELINE_TOKEN_NAME setting.

    The token is also stored in the session under the
    partial_pipeline_token key.
    """
    @wraps(func)
    def wrapper(strategy, backend, pipeline_index, *args, **kwargs):
        current_partial = partial_prepare(strategy, backend, pipeline_index,
                                          *args, **kwargs)

        out = func(strategy=strategy,
                   backend=backend,
                   pipeline_index=pipeline_index,
                   current_partial=current_partial,
                   *args, **kwargs) or {}

        if not isinstance(out, dict):
            strategy.storage.partial.store(current_partial)
            strategy.session_set('partial_pipeline_token',
                                 current_partial.token)
        return out
    return wrapper

@@ -70,21 +70,37 @@
  partial
-(func
+_step(save_to_session
 ):%0A    %22
@@ -710,18 +710,90 @@
  key
-.%0A    %22%22%22%0A
+ when the save_to_session parameter is True.%0A    %22%22%22%0A    def decorator(func):%0A    
     
@@ -805,16 +805,20 @@
 s(func)%0A
+    
     def 
@@ -878,32 +878,36 @@
 wargs):%0A        
+    
 current_partial 
@@ -993,32 +993,36 @@
                 
+    
 *args, **kwargs)
@@ -1031,16 +1031,20 @@
         
+  
+  
 out = fu
@@ -1065,16 +1065,20 @@
 rategy,%0A
+    
         
@@ -1124,16 +1124,20 @@
         
+    
 pipeline
@@ -1170,32 +1170,36 @@
                 
+ 
+   
 current_partial=
@@ -1226,32 +1226,36 @@
                 
+    
 *args, **kwargs)
@@ -1262,16 +1262,20 @@
  or %7B%7D%0A%0A
+    
         
@@ -1308,32 +1308,36 @@
 t):%0A            
+    
 strategy.storage
@@ -1368,16 +1368,60 @@
 artial)%0A
+                if save_to_session:%0A        
         
@@ -1474,41 +1474,8 @@
 en',
-%0A                                
  cur
@@ -1494,16 +1494,20 @@
 .token)%0A
+    
         
@@ -1517,16 +1517,20 @@
 urn out%0A
+    
     retu
@@ -1540,8 +1540,153 @@
 wrapper%0A
+    return decorator%0A%0A%0A# Backward compatible partial decorator, that stores the token in the session%0Apartial = partial_step(save_to_session=True)

Implement a backward compatible parameterised partial_step decorator (decomaker). From now on saving the token into the session is optinal. See: https://github.com/python-social-auth/social-core/issues/145