List Info

Thread: r23837 - in ATContentTypes/branches/photoimagemerge-branch: adapters interface skins/ATContentTypes




r23837 - in ATContentTypes/branches/photoimagemerge- branch: adapters interface skins/ATContentTypes
user name
2006-05-23 07:41:38
Bear with me here, but I seem to remember that this doesn't
work as you  
may think:

photo = zapi.queryAdapter(obj,IScalable,default=None)

will return None if obj directly provides or its class
implements the  
interface. I believe the better syntax (which also avoids
the import of  
(soon-)deprecated zapi) is:

photo = IScalable(obj, None)

... which is also easier to read. 

Martin

---- Forwarded Usenet-message ----
From: gawel <svn-changesplone.org>
Newsgroups: gmane.comp.web.zope.plone.collective.cvs
Subject: r23837 - in
ATContentTypes/branches/photoimagemerge-branch:  
adapters interface skins/ATContentTypes
Date: Mon, 22 May 2006 22:36:23 +0100
URL: news://<E1FiI4d-0005Lq-GJantiloop.plone.org>

Author: gawel
Date: Mon May 22 21:36:21 2006
New Revision: 23837

Modified:
   
ATContentTypes/branches/photoimagemerge-branch/adapters/imag
e.py
   
ATContentTypes/branches/photoimagemerge-branch/interface/ima
ge.py
   
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atphotoalbum.js
   
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atslideshow.js
Log:
use zapi.queryAdapter instead of calling the interface
herself
fix redirect views in js


Modified:
ATContentTypes/branches/photoimagemerge-branch/adapters/imag
e.py
============================================================
==================
---  
ATContentTypes/branches/photoimagemerge-branch/adapters/imag
e.py	(original)
+++
ATContentTypes/branches/photoimagemerge-branch/adapters/imag
e.py	Mon  
May 22 21:36:21 2006
 -8,6
+8,7 

  from Products.ATContentTypes.content.folder import
ATFolder

+from zope.app import zapi
  from zope.interface import implements
  from Products.Archetypes.public import Schema
  from Products.Archetypes.atapi import ReferenceField
 -125,20
+126,14 
          # create a js object for each batch item
          for i,p in enumerate(batch):
              obj = p.getObject()
-            if IPossibleScalable.providedBy(obj):
-                #photo = IScalable(obj).getScalable()
-                photo = obj
-                # GAWEL this one i dont understand!
-                # getScalable just return context!?
-            else:
+            photo =
zapi.queryAdapter(obj,IScalable,default=None)
+            if not photo:
                  continue
- #               pass
- #               photo = obj
- #               continue
+
              # init BaseContent
              title = p.Title or p.getId
              url = p.getURL()
-            out.append(BaseContent % (url, p.getId,
+            out.append(BaseContent % (url + '/view',
p.getId,
                                 
title.replace("'","\\\'"),
                                 
p.Description.replace("'","\\\'"
;),
                                  p.meta_type,
 -167,8
+162,22 
      implements(IScalable)

      field = 'image'
+
      def __init__(self,context):
          self.context = context
+        self.content_type = context.content_type
+
+    def getWidth(self,scale=None):
+        """
+        return scaled width
+        """
+        return self.context.getWidth(scale=scale)
+
+    def getHeight(self,scale=None):
+        """
+        return scaled height
+        """
+        return self.context.getHeight(scale=None)

      def getScalable(self):
          """
 -213,6
+222,7 
      meta_types = ['ATImage']

      def __init__(self,container):
+        self.content_type = ''
          context = None
          container = aq_inner(container)
          try:
 -228,4
+238,6 
                  if brains:
                      context = brains[0].getObject()
          self.context = context
+        if context:
+            self.content_type =
getattr(context,'content_type','')


Modified:
ATContentTypes/branches/photoimagemerge-branch/interface/ima
ge.py
============================================================
==================
---  
ATContentTypes/branches/photoimagemerge-branch/interface/ima
ge.py	(original)
+++
ATContentTypes/branches/photoimagemerge-branch/interface/ima
ge.py	Mon  
May 22 21:36:21 2006
 -42,6
+42,16 
      """
      object with scalable image
      """
+
+    def getWidth(scale=None):
+        """
+        return scaled width
+        """
+
+    def getHeight(scale=None):
+        """
+        return scaled height
+        """

      def getScale(scale=None):
          """

Modified:  
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atphotoalbum.js
============================================================
==================
---  
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atphotoalbum.js	(original)
+++
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atphotoalbum.js	Mon  
May 22 21:36:21 2006
 -26,7
+26,7 
      }
      newNode.id = photo.getId;

-    var linkNode =  
this.createNode('a',null,photo.Title,photo.getURL+'/view
');
+    var linkNode =
this.createNode('a',null,photo.Title,photo.getURL);
      var textNode =
this.createNode('span','photoAlbumEntryWrapper')
      var imageNode =  
this.createNode('img',null,photo.Title,photo.getScaleUrl(t
his.getScale()));
      textNode.appendChild(imageNode);
 -80,7
+80,7 

      if (!W3CDOM) {
          /* redirect to the standard album view */
-        window.location = context.getURL +
'/atphotoalbum_view';
+        window.location = context.getURL +
'/atct_album_view';
          return;
      }


Modified:  
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atslideshow.js
============================================================
==================
---  
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atslideshow.js	(original)
+++
ATContentTypes/branches/photoimagemerge-branch/skins/ATConte
ntTypes/atslideshow.js	Mon  
May 22 21:36:21 2006
 -321,7
+321,7 

      if (!W3CDOM) {
          /* redirect to the standard album view */
-        window.location = context.getURL +
'/atphotoalbum_view';
+        window.location = context.getURL +
'/atct_album_view';
          return;
      }



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job  
easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642



-- 
"You can just adapt yourself out of it..." //
Archipelago sprint 26/04/2006



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Archetypes-devel mailing list
Archetypes-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/archet
ypes-devel
r23837 - in ATContentTypes/branches/photoimagemerge- branch: adapters interface skins/ATContentTypes
user name
2006-05-23 10:20:47
On Tue, 2006-23-05 at 08:41 +0100, Martin Aspeli wrote:
> Bear with me here, but I seem to remember that this
doesn't work as you  
> may think:
> 
> photo = zapi.queryAdapter(obj,IScalable,default=None)
> 
> will return None if obj directly provides or its class
implements the  
> interface. I believe the better syntax (which also
avoids the import of  
> (soon-)deprecated zapi) is:
> 
> photo = IScalable(obj, None)
> 
> ... which is also easier to read. 

I thought I read someplace that the new zope3.3 local
compoennt
(adapter) customization stuff isn't fully realized with
IScalable(obj,
None) (so queryAdapter was better) but I could be mistaken.

- Rocky

-- 
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )