allow specification of message factory for states definition in order to provide package-specific translation domains
This commit is contained in:
		
							parent
							
								
									f898a2b49e
								
							
						
					
					
						commit
						e2a19d5ffc
					
				
					 2 changed files with 6 additions and 3 deletions
				
			
		|  | @ -1,5 +1,5 @@ | |||
| # | ||||
| #  Copyright (c) 2009 Helmut Merz helmutm@cy55.de | ||||
| #  Copyright (c) 2013 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
|  | @ -18,8 +18,6 @@ | |||
| 
 | ||||
| """ | ||||
| Basic implementations for stateful objects and adapters. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from persistent.interfaces import IPersistent | ||||
|  | @ -99,6 +97,7 @@ class StatefulAdapter(Stateful): | |||
| 
 | ||||
|     def __init__(self, context): | ||||
|         self.context = context | ||||
|         self.msgFactory = self.getStatesDefinition().msgFactory | ||||
| 
 | ||||
|     def getState(self): | ||||
|         statesAttr = getattr(self.context, self.statesAttributeName, {}) | ||||
|  |  | |||
|  | @ -76,11 +76,13 @@ class StatesDefinition(object): | |||
|     implements(IStatesDefinition) | ||||
| 
 | ||||
|     initialState = 'started' | ||||
|     msgFactory = None | ||||
| 
 | ||||
|     def __init__(self, name, *details, **kw): | ||||
|         self.name = self.__name__ = name | ||||
|         self.states = Jeep() | ||||
|         self.transitions = Jeep() | ||||
|         msgFactory = kw.get('msgFactory') | ||||
|         for d in details: | ||||
|             if ITransition.providedBy(d): | ||||
|                 self.transitions.append(d) | ||||
|  | @ -89,6 +91,8 @@ class StatesDefinition(object): | |||
|             else: | ||||
|                 raise TypeError('Only states or transitions are allowed here, ' | ||||
|                                 'got %s instead.' % repr(d)) | ||||
|             if msgFactory: | ||||
|                 d.title = msgFactory(d.title) | ||||
|         for k, v in kw.items(): | ||||
|             setattr(self, k, v) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue