Ticket #1557 (closed defect: fixed)

Opened 14 years ago

Last modified 9 years ago

ZODBDirectory schema/layout can't hold any type of fields inherited from file widget/field

Reported by: div Owned by: fguillaume
Priority: P1 Milestone: CPS 3.5.2
Component: CPSDirectory Version: 3.4.0
Severity: major Keywords:
Cc:

Description

ZODBDirectory schema/layout can't hold any type of fields inherited from file widget/field because ZODBDirectoryEntry is not able to hold objects.

Attachments

PatchPhotoInMemberData.rar Download (4.4 KB) - added by tracguest 13 years ago.
patch for photo on member data
PatchesAddPhotoToMembers.2.zip Download (4.8 KB) - added by tracguest 13 years ago.
PatchesAddPhotoToMembers.zip Download (4.8 KB) - added by tracguest 13 years ago.

Change History

comment:1 Changed 14 years ago by div

  • Severity changed from normal to major
  • Milestone changed from unspecified to CPS 3.4.1

comment:2 Changed 14 years ago by fguillaume

What's the traceback? Would fixing the storage adapter to store always as simple attributes be enough?

comment:3 Changed 14 years ago by div

Traceback:

  Module ZPublisher.Publish, line 114, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 40, in call_object
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 195, in _exec
  Module Products.CMFCore.FSPageTemplate, line 134, in pt_render
  Module Products.PageTemplates.PageTemplate, line 104, in pt_render
<FSPageTemplate at /cps/cpsdirectory_entry_edit_form>
  Module TAL.TALInterpreter, line 238, in __call__
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 507, in do_setLocal_tal
  Module Products.PageTemplates.TALES, line 221, in evaluate

URL: file:eBAT/skins/ebat_directory/cpsdirectory_entry_edit_form.pt
Line 1, Column 0

Expression: <PythonExpr dir.renderEditEntryDetailed(id, request=edit_request)>
Names:
{'container': <CPSDefaultSite at /cps>,
 'context': <CPSDefaultSite at /cps>,
 'default': <Products.PageTemplates.TALES.Default instance at 0xb755d20c>,
 'here': <CPSDefaultSite at /cps>,
 'loop': <Products.PageTemplates.TALES.SafeMapping object at 0xb302268c>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0xb74fdcac>,
 'nothing': None,
 'options': {'args': ()},
 'repeat': <Products.PageTemplates.TALES.SafeMapping object at 0xb302268c>,
 'request': <HTTPRequest, URL=http://localhost:9080/cps/cpsdirectory_entry_edit_form>,
 'root': <Application at >,
 'template': <FSPageTemplate at /cps/cpsdirectory_entry_edit_form>,
 'traverse_subpath': [],
 'user': <CPSUser manager.manager@e-bat.org>}

  Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
__traceback_info__: dir.renderEditEntryDetailed(id, request=edit_request)
  Module Python expression "dir.renderEditEntryDetailed(id, request=edit_request)", line 1, in <expression>
  Module Products.CPSDirectory.BaseDirectory, line 611, in renderEditEntryDetailed
  Module Products.CPSDirectory.BaseDirectory, line 932, in _renderLayout
  Module Products.CPSSchemas.Layout, line 391, in renderLayoutStructure
  Module Products.CPSSchemas.BasicWidgets, line 1778, in render
  Module Products.CPSSchemas.BasicWidgets, line 1613, in getFileInfo
TypeError: _getContentUrl() takes exactly 4 arguments (3 given)

ZODBDirectory use as an adapter the AttributeStorageAdapter?, which seems to not offer all the needed functionality.

comment:4 Changed 13 years ago by sfermigier

  • Milestone changed from CPS 3.4.1 to CPS 3.4.2

comment:5 Changed 13 years ago by tracguest

  • Type changed from defect to enhancement

Patch to add a photo on member data, works with or without LDAP feature.

Changed 13 years ago by tracguest

patch for photo on member data

comment:6 Changed 13 years ago by ogrisel

  • Type changed from enhancement to defect

comment:7 Changed 13 years ago by tracguest

The rar attachment is not complete

Changed 13 years ago by tracguest

Changed 13 years ago by tracguest

comment:8 Changed 13 years ago by tracguest

I had the same problem using images for directory entries and used the patches, but I found a problem creating directory entries:

  • TypeError?: _getContentUrl() takes at least 3 arguments (2 given)

from getFileInfo() in PatchAddPhotoToLDAPMembers.py

I decided to modify the method getFileInfo to get the entry from the directory and get the url of the image from the entry itself (the image file is not stored in the ZODB so it is in the field 'image' within the entry). So, I changed:

... # some adapters does not have _getContentUrl if getattr(adapter, '_getContentUrl', None) is not None:

content_url = self._getContentUrl(entry_id, field_id)

...

for:

... # some adapters does not have _getContentUrl if getattr(adapter, '_getContentUrl', None) is not None:

dir = dm.getContext() try:

entry = dir.getEntry(entry_id) content_url = entryimage?.absolute_url()

except:

content_url =

...

and it worked. Then I decided to implement a new widget for directory entries that implemtents the patch functionality. It is called "DirectoryEntryImageWidget?". It just inherits from CPSImageWidget and redefines the getFileInfo method. And it worked too.

I hope this "solution" could help.

comment:9 Changed 9 years ago by gracinet

I dug this ticket while querying the database prior to a new ticket creation. In my opinion, widgets and fields should behave uniformly whatever the context. Therefore, subclassing the Image Widget for the directory use-case is not a good solution.

comment:10 Changed 9 years ago by gracinet

  • Status changed from new to closed
  • Resolution set to fixed

As a consequence of the refactor summarized in #2308, this works transparently for ZODBDirectory, now. Namely, putting an image in a ZODB directory now amounts to standard field and widget definitions.

This is supposed to work for LDAP and Meta/Stacking? directories as well, but I don't have a LDAP server with pictures on hand, and really doubt that editing an image would work so easily at this point. So if someone's interested and has a such a LDAP server, feedback is welcome !

This will now evolve a bit more with the introduction of 'sizedImage' URIs : Image Widgets for directories will probably have to be configured as not resizeable.

Note: See TracTickets for help on using tickets.