[Mpuls-commits] r1661 - in wasko/branches/2.0: . mpulsweb/model waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 18 18:09:12 CET 2010
Author: bh
Date: 2010-02-18 18:09:10 +0100 (Thu, 18 Feb 2010)
New Revision: 1661
Added:
wasko/branches/2.0/mpulsweb/model/case.py
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/model/case.py
Log:
* mpulsweb/model/case.py: Start the base version of the case model
module.
(get_field_identifier): Added. Moved here from waskaweb
* waskaweb/model/case.py (get_field_identifier): Removed. Moved
to mpulsweb.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-18 12:04:15 UTC (rev 1660)
+++ wasko/branches/2.0/ChangeLog 2010-02-18 17:09:10 UTC (rev 1661)
@@ -1,5 +1,14 @@
2010-02-18 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/model/case.py: Start the base version of the case model
+ module.
+ (get_field_identifier): Added. Moved here from waskaweb
+
+ * waskaweb/model/case.py (get_field_identifier): Removed. Moved
+ to mpulsweb.
+
+2010-02-18 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/model/case.py (get_field_identifier): log.debug instead
of printing to stderr
Added: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py 2010-02-18 12:04:15 UTC (rev 1660)
+++ wasko/branches/2.0/mpulsweb/model/case.py 2010-02-18 17:09:10 UTC (rev 1661)
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
+# Web-Anwendungs-Server fuer Kompetenzagenturen).
+#
+# mpuls WASKA is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
+#
+# mpuls WASKA has been developed on behalf of the
+# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
+# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
+# European Social Fund resources.
+# Authors:
+# Torsten Irländer <torsten.irlaender at intevation.de>
+#
+
+import logging
+
+from formed.meta.data import RepeatNode
+
+from mpulsweb.lib.base import g
+
+
+log = logging.getLogger(__name__)
+
+
+def get_field_identifier(id, name, it=None, idx=0):
+ """Will return the identifier of a field. If the field in in a rg the
+ identifier of the first occourance will be returned on default."""
+ # Map generic fieldnames to specific fieldnames
+ # get name of the field
+ nc = g.formedTree.findByName(name)
+ if not nc:
+ return None
+
+ # is the field within a rg. if so get name
+ parent = nc.getParent()
+ rg = None
+ while parent:
+ if isinstance(parent, RepeatNode):
+ rg = parent
+ break
+ parent = parent.getParent()
+
+ if not rg:
+ return "%s:%d" % (name, id)
+
+ # get instance of the rg
+ rgc = it.getItem("%s:%d" % (rg.getName(), id))
+ if not rgc:
+ return None
+ rgs = rgc.getChildren()
+ if not rgs:
+ log.debug("No repeat group found for %r: create new", name)
+ rg = rgc.createInstance()
+ else:
+ rg = rgs[idx]
+ return '%s:%s:%s' % (name, rg.getInternalIdentifier(), id)
Property changes on: wasko/branches/2.0/mpulsweb/model/case.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py 2010-02-18 12:04:15 UTC (rev 1660)
+++ wasko/branches/2.0/waskaweb/model/case.py 2010-02-18 17:09:10 UTC (rev 1661)
@@ -51,6 +51,7 @@
from mpulsweb.model.user import UserObject
from mpulsweb.model.agencysettings import Agency
from mpulsweb.model.document import listDocuments
+from mpulsweb.model.case import get_field_identifier
from mpulsweb.controllers.formularpage import convert2dic
@@ -68,40 +69,6 @@
log = logging.getLogger(__name__)
-def get_field_identifier(id, name, it=None, idx=0):
- """Will return the identifier of a field. If the field in in a rg the
- identifier of the first occourance will be returned on default."""
- # Map generic fieldnames to specific fieldnames
- # get name of the field
- nc = g.formedTree.findByName(name)
- if not nc:
- return None
-
- # is the field within a rg. if so get name
- parent = nc.getParent()
- rg = None
- while parent:
- if isinstance(parent, RepeatNode):
- rg = parent
- break
- parent = parent.getParent()
-
- if not rg:
- return "%s:%d" % (name, id)
-
- # get instance of the rg
- rgc = it.getItem("%s:%d" % (rg.getName(), id))
- if not rgc:
- return None
- rgs = rgc.getChildren()
- if not rgs:
- log.debug("No repeat group found for %r: create new", name)
- rg = rgc.createInstance()
- else:
- rg = rgs[idx]
- return '%s:%s:%s' % (name, rg.getInternalIdentifier(), id)
-
-
def save_getone(params, k, v):
try:
return params.getone(k)
More information about the Mpuls-commits
mailing list