Some considerations on refactoring the eZ Publish API

Author Message

Gaetano Giunta

Friday 23 April 2010 1:55:32 pm

List of current eZ Publish APIs:

1. template language API
 . template operators
 . template functions
 . template fetch  functions
 . objects

- template variables are not the same between  node templates and module templates (persistent_variable,  view_parameters)
- no documentation of variables available in every  template
- some simple template operators miss (str_replace)
- some template operators are named differently from their php counterpart
- the variable scoping system is borderline blackmagic / it makes it  difficult to pass variables up the include() chain
+ well documented

2. module views
 . positional params
 . named params
 . single/multiple actions
 . POST vars

- extremely poorly documented
- the view template is hardcoded into the view
- redirects are  hardcoded into the view (views are not atomic)

3. php code
- misses a lot of "private" definitions on object members
- should be  documented in phpdoc style for current toolchains/ides
- misses some  architecture doc documenting the layering
- still a few global  variables and functions here and there (not 100% oop)

IDEAS:

+  before/besides adding YOMA (yet one more api), improve existing ones

+  principle of discoverability: document better existing ones
 . add  (optional) declaration of parameter types for views in module.php; it  allows automatic type coercion (safety!), introspection (wsdl!)
 . add definition of all used POST/GET vars for views
 . add links to  docs on ez.no site in the code; in the error messages; in the interface
 . an introspection view can be used in the backoffice to list all  installed modules, views, fetch functions, including code from  extensions
 . it should be doable to do the same with template  functions/operators
 . add a 'description' member in definition of  template operators, fetch functions (could be doable via an explicit  member in the definition struct or via phpdoc parsing)

+ principle of  least resistance: make APIs at the different levels identical or at  least as similar as possible
 . the same operation executed by a view  should be available via ws and via php
 . template operators and  fetch functions should be available via php (ok for objects even though  this is often overlooked, ok for fetch functions with some limitations,  not for operators?)
 . make the module object available to the view  templates

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Sunday 25 April 2010 11:22:28 pm

Some related issues:

http://issues.ez.no/IssueView.php?Id=16731&activeItem=1

http://issues.ez.no/IssueView.php?Id=16730&activeItem=2

http://issues.ez.no/IssueView.php?Id=16729&activeItem=3

http://issues.ez.no/IssueView.php?Id=16728&activeItem=4

http://issues.ez.no/IssueView.php?Id=16727&activeItem=5

http://issues.ez.no/IssueView.php?Id=16684&activeItem=8

http://issues.ez.no/IssueView.php?Id=16683&activeItem=10

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Sunday 25 April 2010 11:23:58 pm

Some introspection capabilities have been added to extension ggsysinfo in release 0.2: http://projects.ez.no/ggsysinfo

Screenshots:

http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_fetch_functions

http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_views

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Monday 03 May 2010 6:19:58 am

one more similar issue

http://issues.ez.no/IssueView.php?Id=16770

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Thursday 27 May 2010 2:34:18 am

One more thing that would help introspection is better tagging of php classes methods (I think this is called "annotation" ).

In short: an example of a currently much needed information is "who does permission checking ?"

Afaik:

  • index.php checks access perms for current user to module/view if the corresponding perm has no limitation
  • the view php code needs to do access checking on its own if the corresponding perm has some limitation
  • other bits of code do access checking on their own (eg. the template fetch functions do some, but not all are created equal, eg. checking perms on related object is not always done in a way that is expected)

See issue http://issues.ez.no/IssueView.php?Id=16862 for the feat.request.

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Tuesday 22 June 2010 1:44:56 am

Interesting blog post on the tpoic: http://blog.tabini.ca/2010/06/software-apis-and-all-the-kings-men/

Principal Consultant International Business
Member of the Community Project Board

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 14:44:35
Script start
Timing: Jan 29 2025 14:44:35
Module start 'layout'
Timing: Jan 29 2025 14:44:35
Module start 'content'
Timing: Jan 29 2025 14:44:36
Module end 'content'
Timing: Jan 29 2025 14:44:36
Script end

Main resources:

Total runtime0.9597 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 588.3750151.2422
Module start 'layout' 0.00720.0041 739.617236.7109
Module start 'content' 0.01130.9476 776.3281487.3203
Module end 'content' 0.95890.0008 1,263.648419.7969
Script end 0.9597  1,283.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3193160.0002
Check MTime0.00120.1270160.0001
Mysql Total
Database connection0.00070.077110.0007
Mysqli_queries0.914795.3139650.0141
Looping result0.00050.0568630.0000
Template Total0.913795.220.4569
Template load0.00180.188320.0009
Template processing0.911995.019220.4559
Template load and register function0.00010.011810.0001
states
state_id_array0.00240.254810.0024
state_identifier_array0.00190.202720.0010
Override
Cache load0.00160.1630390.0000
Sytem overhead
Fetch class attribute can translate value0.00050.056510.0005
Fetch class attribute name0.00100.106970.0001
XML
Image XML parsing0.00040.044710.0004
class_abstraction
Instantiating content class attribute0.00000.0024120.0000
General
dbfile0.00070.0778160.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs