Package orm2 :: Package ui :: Package ORMMode
[hide private]
[frames] | no frames]

Source Code for Package orm2.ui.ORMMode

  1  #!/usr/bin/env python 
  2  # -*- coding: iso-8859-1 -*- 
  3   
  4  ##  This file is part of orm, The Object Relational Membrane Version 2. 
  5  ## 
  6  ##  Copyright 2002-2006 by Diedrich Vorberg <diedrich@tux4web.de> 
  7  ## 
  8  ##  All Rights Reserved 
  9  ## 
 10  ##  For more Information on orm see the README file. 
 11  ## 
 12  ##  This program is free software; you can redistribute it and/or modify 
 13  ##  it under the terms of the GNU General Public License as published by 
 14  ##  the Free Software Foundation; either version 2 of the License, or 
 15  ##  (at your option) any later version. 
 16  ## 
 17  ##  This program is distributed in the hope that it will be useful, 
 18  ##  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 19  ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 20  ##  GNU General Public License for more details. 
 21  ## 
 22  ##  You should have received a copy of the GNU General Public License 
 23  ##  along with this program; if not, write to the Free Software 
 24  ##  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 25  ## 
 26  ##  I have added a copy of the GPL in the file gpl.txt. 
 27   
 28  # Changelog (orm2) 
 29  # --------------- 
 30  # $Log: __init__.py,v $ 
 31  # Revision 1.1  2006/04/28 09:56:41  diedrich 
 32  # Initial commit 
 33  # 
 34  # 
 35   
 36  # Changelog (orm) 
 37  # --------------- 
 38  # 
 39  # $Log: __init__.py,v $ 
 40  # Revision 1.1  2006/04/28 09:56:41  diedrich 
 41  # Initial commit 
 42  # 
 43  # Revision 1.2  2004/08/02 23:05:35  t4w00-diedrich 
 44  # Added OEMFSPageTemplate. 
 45  # 
 46  # Revision 1.1  2004/08/01 15:44:02  t4w00-diedrich 
 47  # Initial commit. 
 48  # 
 49  # 
 50  # 
 51   
 52  """ 
 53  Python product that fullfills a simmilar function as ExternalMethod 
 54  except that will call any callable, mostly classes that inherit from 
 55  the mode class below, instead of just Python functions. (Remember, 
 56  calling a class will return an instance). The callable MUST have a 
 57  **kw parameter for arbitrary key word arguments for this to 
 58  work. Anyway, think of modes as External Methods which have 
 59  overloadable parts. 
 60  """ 
 61   
 62  import ORMMode 
 63  import ORMFSPageTemplate 
 64   
65 -def initialize(context):
66 context.registerClass( 67 ORMMode.ORMMode, 68 permission='Add ORM Mode Object', 69 constructors=(ORMMode.manage_addORMModeForm, 70 ORMMode.manage_addORMMode), 71 #icon='www/PageXML.gif', 72 ) 73 74 75 context.registerBaseClass(ORMMode.ORMMode) 76 77 context.registerClass( 78 ORMFSPageTemplate.ORMFSPageTemplate, 79 permission='Add ORM Mode Object', 80 constructors=(ORMFSPageTemplate.manage_addORMFSPageTemplateForm, 81 ORMFSPageTemplate.manage_addORMFSPageTemplate), 82 #icon='www/PageXML.gif', 83 ) 84 85 86 context.registerBaseClass(ORMFSPageTemplate.ORMFSPageTemplate)
87 88 89 90
91 -class mode(object):
92 """ 93 Baseclass for orm modes. A class that inherits from mode behaves just 94 like a function whoes parts may be overwritten. When instantiated a mode 95 class will not return an instance of itselt, but the result of an 96 instance's __call__ method. Example 97 98 >>> from orm.ui.modes import mode 99 >>> class test(mode): 100 ... def __call__(self, para): 101 ... return para * 2 102 ... 103 >>> x = test(5) 104 >>> x 105 10 106 """
107 - def __new__(cls, *args, **kw):
108 instance = object.__new__(cls) 109 return instance(*args, **kw)
110