99
1010Usage:
1111 from django_forms_workflows.data_sources import get_data_source
12-
12+
1313 source = get_data_source('ldap')
1414 value = source.get_value(user, 'department')
1515"""
1616
1717from .base import DataSource , DataSourceRegistry
18- from .user_source import UserDataSource
19- from .ldap_source import LDAPDataSource
2018from .database_source import DatabaseDataSource
19+ from .ldap_source import LDAPDataSource
20+ from .user_source import UserDataSource
2121
2222# Global registry
2323registry = DataSourceRegistry ()
2424
2525# Register built-in sources
26- registry .register (' user' , UserDataSource )
27- registry .register (' ldap' , LDAPDataSource )
28- registry .register (' database' , DatabaseDataSource )
29- registry .register ('db' , DatabaseDataSource ) # Alias
26+ registry .register (" user" , UserDataSource )
27+ registry .register (" ldap" , LDAPDataSource )
28+ registry .register (" database" , DatabaseDataSource )
29+ registry .register ("db" , DatabaseDataSource ) # Alias
3030
3131
3232def get_data_source (source_type ):
3333 """
3434 Get a data source instance by type.
35-
35+
3636 Args:
3737 source_type: Type of data source ('user', 'ldap', 'database', etc.)
38-
38+
3939 Returns:
4040 DataSource instance
41-
41+
4242 Raises:
4343 ValueError: If source type is not registered
4444 """
@@ -48,32 +48,31 @@ def get_data_source(source_type):
4848def register_data_source (source_type , source_class ):
4949 """
5050 Register a custom data source.
51-
51+
5252 Args:
5353 source_type: Unique identifier for the source
5454 source_class: DataSource subclass
55-
55+
5656 Example:
5757 from django_forms_workflows.data_sources import register_data_source, DataSource
58-
58+
5959 class SalesforceSource(DataSource):
6060 def get_value(self, user, field_name, **kwargs):
6161 # Query Salesforce API
6262 pass
63-
63+
6464 register_data_source('salesforce', SalesforceSource)
6565 """
6666 registry .register (source_type , source_class )
6767
6868
6969__all__ = [
70- ' DataSource' ,
71- ' DataSourceRegistry' ,
72- ' UserDataSource' ,
73- ' LDAPDataSource' ,
74- ' DatabaseDataSource' ,
75- ' get_data_source' ,
76- ' register_data_source' ,
77- ' registry' ,
70+ " DataSource" ,
71+ " DataSourceRegistry" ,
72+ " UserDataSource" ,
73+ " LDAPDataSource" ,
74+ " DatabaseDataSource" ,
75+ " get_data_source" ,
76+ " register_data_source" ,
77+ " registry" ,
7878]
79-
0 commit comments