[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/module - moduleservice.pt:1.1.2.1 registration.pt:1.1.2.1 __init__.py:1.6.6.1 configure.zcml:1.5.6.1

Fred L. Drake, Jr. fred at zope.com
Thu Jan 15 15:50:50 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/browser/services/module
In directory cvs.zope.org:/tmp/cvs-serv1563/src/zope/app/browser/services/module

Modified Files:
      Tag: zope3-fdrake-globalized-modules-branch
	__init__.py configure.zcml 
Added Files:
      Tag: zope3-fdrake-globalized-modules-branch
	moduleservice.pt registration.pt 
Log Message:
Checkpointing the current state of the module globalization work on a branch
so it does not get lost.  See http://dev.zope.org/Zope3/ModulesAreGlobal.


=== Added File Zope3/src/zope/app/browser/services/module/moduleservice.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">

  <div metal:define-macro="body">
    <div tal:define="registries view/update">

      <h2 metal:define-slot="heading">Registered global modules</h2>

      <div tal:condition="not:registries">
        <p metal:define-slot="empty_text">No modules have been registered.</p>
      </div>

      <div tal:condition="registries">

        <div metal:define-slot="extra_top" tal:condition="nothing">
          <p>For each fruit, the fruit name is given and all of the components
             registered to provide the fruit are shown.  You may select the
             component to provide the fruit or disable the fruit.</p>

          <p>Select a fruit name or a component name to visit the fruit or
            component.</p>
        </div>

        <form action="." method="post" tal:attributes="action request/URL">
          <div tal:repeat="registry registries">
            <a href="#"
               tal:content="registry/name"
               tal:attributes="href string:${registry/url}/registration.html"
               tal:condition="registry/active">Orange</a>
            <span tal:replace="registry/name"
                  tal:condition="registry/inactive" />
            <br />
            <span tal:replace="structure registry/view" />
          </div>
          <input type="submit" name="submit_update" value="Update"
                 i18n:attributes="value update-button"/><br />
        </form>

        <div metal:define-slot="extra_bottom" tal:condition="nothing" />

      </div>
    </div>
  </div>

</div>
</body>
</html>


=== Added File Zope3/src/zope/app/browser/services/module/registration.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">

<form tal:attributes="action request/URL" method="POST"
      tal:define="ignored view/update">

  <div tal:condition="view/registered">
    <div tal:define="registration view/registration">
      <p i18n:translate="">This module is registered as:</p>

      <div class="registrationSummary">
        <div tal:content="registration/usageSummary"
             class="usageSummary" />
        <div tal:content="registration/implementationSummary"
             class="implementationSummary" />
        <div class="modificationLink">
          <a tal:attributes="href registration/@@absolute_url"
             i18n:translate="">(modify)</a>
        </div>
      </div>

      <tal:block condition="view/active">
        <p i18n:translate="">
            This registration causes this module to be available to
            all modules loaded in the server's database.  Deactivating
            it will cause it to only be available to other modules in
            this folder.</p>
        <input type="submit" value="Deactivate" name="deactivate" />
      </tal:block>
      <tal:block condition="not:view/active">
        <p i18n:translate="">
            This module is currently available only to other modules
            within this folder.  Activating it will make it available
            to all modules loaded in the server's database.</p>

        <input type="submit" value="Activate" name="activate" />
      </tal:block>
    </div>

    <hr />
    <a href="registrations.html" i18n:translate="">
      Advanced Options
    </a>

  </div>

  <div tal:condition="not:view/registered">
    <p i18n:translate="">
        This module is currently available only to other modules
        within this folder.  Activating it will make it available to
        all modules loaded in the server's database.</p>

    <p i18n:translate="">
        Before this module can be activated, some additional
        information needs to be collected in order to register it with
        the <a tal:attributes="href view/moduleService" >Module
        Service</a>.</p>

    <input type="submit" value="Register" name="activate" />
  </div>

</form>

</div>
</body>
</html>


=== Zope3/src/zope/app/browser/services/module/__init__.py 1.6 => 1.6.6.1 ===
--- Zope3/src/zope/app/browser/services/module/__init__.py:1.6	Mon Dec 29 11:45:04 2003
+++ Zope3/src/zope/app/browser/services/module/__init__.py	Thu Jan 15 15:50:19 2004
@@ -16,22 +16,23 @@
 $Id$
 """
 
-from zope.app.services.module import Manager
+from zope.app import zapi
+from zope.app.browser.services.registration import RegistrationView
 from zope.app.event import publish
 from zope.app.event.objectevent import ObjectCreatedEvent
+from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.services.module import Manager
+from zope.app.services.servicenames import Modules
 from zope.publisher.browser import BrowserView
 from zope.proxy import removeAllProxies
 
-from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.browser.services.registration import AddComponentRegistration
 
 
 class AddModule(BrowserView):
 
     def action(self, source):
-        name = self.context.contentName
-        if not name:
-            raise UserError(_(u"module name must be provided"))
-        mgr = Manager(name, source)
+        mgr = Manager(source)
         mgr = self.context.add(mgr)  # local registration
         mgr.execute()
         self.request.response.redirect(self.context.nextURL())
@@ -46,6 +47,50 @@
             return _(u"The source was updated.")
         else:
             return u""
+
+
+class ModuleRegistrationView(RegistrationView):
+
+    def moduleService(self):
+        service = zapi.getService(self.context, Modules)
+        return zapi.getPath(service)
+
+
+class AddRegistration(AddComponentRegistration):
+
+    def add(self, registration):
+        registration = super(AddRegistration, self).add(registration)
+        registration.componentPath = zapi.getPath(registration.getComponent())
+        return registration
+
+
+class ModuleServiceView(BrowserView):
+
+    def update(self):
+        names = list(self.context.listRegistrationNames())
+        names.sort()
+        items = []
+        for name in names:
+            registry = self.context.queryRegistrations(name)
+            view = zapi.getView(registry, "ChangeRegistrations", self.request)
+            view.setPrefix(name)
+            view.update()
+            items.append(self._getItem(name, view, registry.active()))
+        return items
+
+    def _getItem(self, name, view, cfg):
+        # hook for subclasses. returns a dict to append to an item
+        if cfg is not None:
+            url = zapi.getPath(zapi.traverse(cfg, cfg.componentPath))
+        else:
+            url = None
+        return {"name": name,
+                "active": cfg is not None,
+                "inactive": cfg is None,
+                "view": view,
+                "url": url,
+                }
+
 
 class ViewModule(BrowserView):
 


=== Zope3/src/zope/app/browser/services/module/configure.zcml 1.5 => 1.5.6.1 ===
--- Zope3/src/zope/app/browser/services/module/configure.zcml:1.5	Wed Dec 17 04:15:41 2003
+++ Zope3/src/zope/app/browser/services/module/configure.zcml	Thu Jan 15 15:50:19 2004
@@ -6,12 +6,12 @@
 
 <!-- Persistent Modules -->
 
-  <page 
-      name="edit.html" 
+  <page
+      name="edit.html"
       for="zope.app.interfaces.services.module.IModuleManager"
       menu="zmi_views" title="Edit"
       class="zope.app.browser.services.module.EditModule"
-      template="edit_module.pt" 
+      template="edit_module.pt"
       permission="zope.ManageServices"
       />
 
@@ -33,11 +33,50 @@
         template="browse_module.pt"
         /> 
 
-  <menuItem 
-      menu="add_component" 
+  <menuItem
+      menu="add_component"
       for="zope.app.interfaces.container.IAdding"
-      action="Module"  
-      title="Module" 
+      action="Module"
+      title="Module"
+      />
+
+  <page
+      for="zope.app.interfaces.services.module.IModuleManager"
+      name="registration.html"
+      template="registration.pt"
+      class=".ModuleRegistrationView"
+      permission="zope.ManageServices"
+      menu="zmi_views" title="Registration"
+      />
+
+  <addform
+      label="New Module Registration"
+      for="zope.app.interfaces.services.module.IModuleManager"
+      name="addRegistration.html"
+      schema="zope.app.interfaces.services.module.IModuleRegistration"
+      class=".AddRegistration"
+      permission="zope.ManageServices"
+      content_factory="zope.app.services.globalmodule.GlobalModuleRegistration"
+      arguments="name componentPath"
+      set_after_add="status"
+      fields="name componentPath permission status"
+      />
+
+  <editform
+      name="index.html"
+      schema=
+        "zope.app.interfaces.services.module.IModuleRegistration"
+      menu="zmi_views"
+      label="Edit Registration"
+      permission="zope.ManageServices"
+      fields="name componentPath permission status" />
+
+  <page
+      name="index.html"
+      for="zope.app.interfaces.services.module.IModuleService"
+      class=".ModuleServiceView"
+      permission="zope.ManageServices"
+      template="moduleservice.pt"
       />
 
 </zope:configure>




More information about the Zope3-Checkins mailing list