AbracadabraObject

Current release:

Historic releases:

Bug reports:
maik (dot) jablonski (at) gmail (dot) com

Abracadabra Object - pre-configured objects with only one click

The "Abracadabra Object"-Product allows you to add pre-configured ZOPE-objects to your folders through the Zope-Management-Interface with only one click and run scripts on them. This is extremely useful if you use the Zope-Management-Interface as a content-management-system or to build a graphical user interface (GUI) for developing / prototyping database applications with Zope. Please note: Download and install the PropertyTools. AbracadabraObject & PropertyTools allow you to develop comfortable database applications in just a few minutes.

For example: You can set up a default DTML Document with your own default text and additional properties. Or you can set up a default Folder with properties and several objects already in it. Or you can create a simple FAQ-Object: Create a PropertyObject with additional properties as question, answer and so on. Then add a little script, which adds the date of creation in a property of the FAQ-object. If you now add a new FAQ-Object through the Abracadabra Object, you get a already configured document with additional properties and a correct datestamp.

In short terms: When you add an Abracadabra Object from your 'Select object'- list, you can select one of your default objects from a list and it will be copied with a given id and title into your current folder automagically. After the cloning you can run a PythonScript on your fresh cloned object. This is useful if you want to catalog, cache, mail etc. objects or store computed properties [e.g. dates] after the creation of an object.

AbracadabraObject even generates auto_ids in different flavors for your objects if you want to.

How does Abracadabra Object work?

Abracadabra Object works with all cloneable ZOPE-objects. Abracadabra Object searches for a folder with the id standard_object_folder. Please note: If Abracadabra Object can't find such a folder in your current folder, it goes up one level and so on, until it finds one. This is ZOPE's acquisition feature and can be used to create different standard_object_folder for different parts of your workspace. All objects in the standard_object_folder for which the user has the "Add"-permission will be listed in the select box of the Abracadabra Object. If you want to generate the AbracadabraObject-list dependent on different contexts, you can do this by creating a standard_object_list-object. This can be a PythonScript or a folder-property which simply returns the id's of the standard_object_folder-items you want to be shown in the AbracadabraSelectBox.

Enter the id and title of the new object to add... and that's it!!! Abracadabra Object simply clones the selected object from the standard_object_folder with the new id and title.

  • If your standard_object_folder has a property auto_id as string-type, AbracadabraObject tries to generate an auto_id with the auto_id-property as a python-format-string. For example: If your auto_id-property is document-%04d.html, AbracadabraObject will generate id's like document-0001.html, documet-0002.html and so on. If you have a %s in your format-string, AbracadabraObject tries to cook an id out of the title of the object.
  • If your standard_object_folder has a property auto_id as list-type, AbracadabraObject looks up the format-string in the auto_id-list. Therefore you must seperate the object_id and the format-string with a colon for every object in your standard_object_folder. For example: If you have a FAQ-Object and a FAQ-Folder in your standard_object_folder, add a property auto_id as list and edit it as follows. All your FAQ_Objects get an id cooked out of the title and all your FAQ_Folders get an numeric id:
        FAQ_Object:%s.html
        FAQ_Folder:%02d
    
  • If your standard_object_folder has a property auto_id as int-type, AbracadbraObject creates unique ids for all your AbracadabraObjects which will be cloned out of your standard_object_folder.
  • If nothing of the above matches, but an auto_id-property is present, an id will be generated out of the current timestamp.

If you want to hide some objects from being listed in the AbracadabraObjectBox, you can also set a lines-property with name=ignore_ids and enter all object-ids you don't want to be shown. This is mainly useful if you want to place a ZCatalog into the standard_object_folder to prevent cataloging your Abracadabra-Objects into your site-catalog.

After having cloned the specified object, Abracadabra Object looks for a method/script in the standard_object_folder which has the same id plus a underscore (id_) of the cloned object. For example: Imagine you have a FAQ-Object with the id faq in your standard_object_folder. If you want to send an email or add a datestamp as a property when a new faq-object is created, simply add a PythonScript with the id faq_ to the standard_object_folder which handles the logic. All objects in the standard_object_folder which end on an underscore will not be listed in the select box of the Abracadabra Object.

Let's go... Create a folder with the id standard_object_folder, populate it with some pre-configured objects, go to your workspace and enter the magic of Abracadabra Objects...

If you want to create AbracadabraObjects through scripts, you can use the global method manage_addAObject(id, object_id, title=''). Simply call it from a PythonScript with context.manage_addAObject(test,faq) to create a faq-object with id=test. Set id=None to use the auto_id-feature (see above).

Is there a patch for the Zope-Management-Interface for still more comfort with Abracadbra Object?

Abracadabra Object patches the Zope-Management-Interface (ZMI), so you can add Abracadabra Objects really fast through a special Abracadabra-Object-Widget. You should try this feature with a "clean" Zope to get the look&feel of this cool feature (means: try it with a fresh Zope with no additional products installed).

Please note: Several products (e.g. ExternalEditor, QuickLinks), try to patch the ZMI. If you have problems with one of them, try to mix the different '(manage)-main.dtml'-files in order to get correct results. Adding a AbracadabraObject-Box to your customized main-template is very simple. See dtml/main.dtml on how to do this properly. The product in alphabetical last position will win the Monkey-Patch-Race, so AbracadabraObject is kind of handicaped by default in this race.

If you want to give users only the view of the Abracadbra-Object-box [and not the regular "Select-Type-to-Add-Box"], click off the right "Abracadabra Object: Show StandardSelectBox".

Please send all bugs or feature-requests regarding AbracadabraObject to maik.jablonski@uni-bielefeld.de.

 

CHANGES

Changes

2.0.3:

- Some fixes to monkey-patched 'main.dtml' to be in line
with latest Zope-versions.

2.0.2:

- Language cleanups. Thanks to Tom Snell!

- fixed bug: auto_id as list were broken for current Zopes (>=2.6.4),
because line-properties changed from lists to tuples...

- added coding to CharacterMapping.py; Thanks to Yannick Dirou!

2.0.1:

- Updated patch for main.dtml to Zope 2.7.

2.0.0:

- New features

Added manage_addAObject(...) as global wrapper for
manage_addProduct['AbracadabraObject].manage_addAbracadabraObject(...).
Hope this will make it easier to create AbracadabraObjects
through scripts... for me it does.

All ids given to AbracadabraObject will be transformed
into valid Zope-Ids (independent of auto_id-feature).
Now you can even trust your Windows-Special-Characters-Must-
-Work-Here-Too-Users...:)

You can now specify the auto_id when calling the factory
through scripts.

If you set a lines-property with name=ignore_ids, you can hide
objects from being listed in the AbracadabraObjectBox. Mainly
useful if you want to place a ZCatalog into the standard_object_folder
to catch cataloging your Abracadabra-Objects into your
application-catalog.

- Policy changes

You cannot execute single scripts (ending
on underscore) with no corresponding AbracadabraObject
due to security reasons anymore.

You can only call PythonScripts as post-processors on objects
due to security reasons. Please call your DTML-Methods etc.
through a PythonScript.

- UI changes

Removed "Add and Edit" and "Add and Edit Properties"-Buttons
to keep the widget smaller.

Moved descriptions (id, title) into input-boxes to make
the widget smaller.

Made the first entry in select-list selected by default, so
IE-Users should have the same look&feel as Mozilla-Users.

- Bug fixes

Made some fixes for catching errors for empty
standard_object_folder or empty object_id.

Fixed acquisition bug for script-execution.

- Things removed

Removed ZZZMonkeyPatch. AbracadabraObject patches now
the manage_main directly with a slightly modified
Zope 2.6.2-template (only two minor changes).

Removed demo.zexp. It was a little bit outdated because
it didn't used PropertyObject/Folder to show the real
power of AbracadabraObject.