[Checkins] SVN: z3c.zalchemy/trunk/src/z3c/zalchemy/ - Provide an edit form for the AlchemyEngineUtility.

Stefan H. Holek stefan at epy.co.at
Wed Feb 28 12:06:16 EST 2007


Log message for revision 72910:
  - Provide an edit form for the AlchemyEngineUtility.
  - Rename 'url' param of the AlchemyEngineUtility constructor to 'dsn'
    so it matches the field name.
  

Changed:
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/browser/configure.zcml
  A   z3c.zalchemy/trunk/src/z3c/zalchemy/browser/views.py
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/configure.zcml
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/interfaces.py

-=-
Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/browser/configure.zcml
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/browser/configure.zcml	2007-02-28 16:39:56 UTC (rev 72909)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/browser/configure.zcml	2007-02-28 17:06:16 UTC (rev 72910)
@@ -27,5 +27,13 @@
       add="zope.ManageContent"
       />
 
+  <browser:page
+      name="edit.html"
+      menu="zmi_views" title="Edit"
+      for="..interfaces.IAlchemyEngineUtility"
+      permission="zope.ManageServices"
+      class=".views.EditView"
+      />
+
 </configure>
 

Added: z3c.zalchemy/trunk/src/z3c/zalchemy/browser/views.py
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/browser/views.py	2007-02-28 16:39:56 UTC (rev 72909)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/browser/views.py	2007-02-28 17:06:16 UTC (rev 72910)
@@ -0,0 +1,8 @@
+
+from zope.formlib import form
+from z3c.zalchemy.interfaces import IAlchemyEngineUtility
+
+
+class EditView(form.EditForm):
+    form_fields = form.Fields(IAlchemyEngineUtility)
+


Property changes on: z3c.zalchemy/trunk/src/z3c/zalchemy/browser/views.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/configure.zcml
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/configure.zcml	2007-02-28 16:39:56 UTC (rev 72909)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/configure.zcml	2007-02-28 17:06:16 UTC (rev 72910)
@@ -31,6 +31,20 @@
       trusted="true"
       />
 
+  <class class=".datamanager.AlchemyEngineUtility">
+
+    <require
+        permission="zope.View"
+        interface=".interfaces.IAlchemyEngineUtility"
+        />
+
+    <require
+        permission="zope.ManageServices"
+        set_schema=".interfaces.IAlchemyEngineUtility"
+        />
+
+  </class>
+
   <include package=".browser" />
 
 </configure>

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2007-02-28 16:39:56 UTC (rev 72909)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2007-02-28 17:06:16 UTC (rev 72910)
@@ -18,6 +18,7 @@
 import transaction
 from zope.interface import implements
 from zope.component import queryUtility, getUtility, getUtilitiesFor
+from zope.schema.fieldproperty import FieldProperty
 
 from transaction.interfaces import IDataManager, ISynchronizer
 
@@ -31,9 +32,9 @@
     """
     implements(IAlchemyEngineUtility)
 
-    def __init__(self, name, url, echo=False, **kwargs):
+    def __init__(self, name, dsn, echo=False, **kwargs):
         self.name = name
-        self.url = url
+        self.dsn = dsn
         self.echo = echo
         self.kw={}
         self.kw.update(kwargs)
@@ -46,7 +47,7 @@
         kw = {}
         kw.update(self.kw)
         # create a new engine and store it thread local
-        self.storage.engine = sqlalchemy.create_engine(self.url,
+        self.storage.engine = sqlalchemy.create_engine(self.dsn,
                                             echo=self.echo,
                                             **kw)
         return self.storage.engine
@@ -60,6 +61,10 @@
             self._v_storage = local()
         return self._v_storage
 
+for name in IAlchemyEngineUtility:
+    setattr(AlchemyEngineUtility, name, FieldProperty(IAlchemyEngineUtility[name]))
+
+
 _tableToEngine = {}
 _classToEngine = {}
 _tablesToCreate = []

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/interfaces.py
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/interfaces.py	2007-02-28 16:39:56 UTC (rev 72909)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/interfaces.py	2007-02-28 17:06:16 UTC (rev 72910)
@@ -39,9 +39,10 @@
 
 
 class IAlchemyEngineUtility(interface.Interface):
-    dns = schema.Text(
-            title = u'DNS',
-            required = True,
+    dsn = schema.TextLine(
+            title=u'DSN',
+            required=True,
+            default=u'sqlite://',
             )
     echo = schema.Bool(
             title=u'echo sql',



More information about the Checkins mailing list