Re: [Components] CSV export view

2009-01-05 Thread Alexandru Stanoi
Philipp Kamps wrote:
> Hi,
> 
> my goal is to allow my users to download a CSV export from my web 
> application.
> 
> In a pure PHP application I would do following:
> 
> |// We'll be outputting a PDF
> header('Content-type: text/csv');
> 
> // It will be called downloaded.pdf
> header('Content-Disposition: attachment; filename="export.csv"');
> 
> |What would be a good way to do it with the MVC component?
> 
> Here is what I tried so far:
> 
> class ReportsExportView extends ezcMvcView
> {
>
> function createResponse()
> {
> $resultBody = 'csv content';
> 
> $result = $this->result;
> 
> // set $result->status ???
>
> $return = new ezcMvcResponse( $result->status, $result->date,
> $result->generator, $result->cache, $result->cookies,
> $result->content, $resultBody );
>
> // set $return->status ???

$content = new ezcMvcResultContent(); // see MvcTools/src/structs
$content->type = 'text/cvs';
// other properties can be set like charset, language, encoding
// but it seems it does not handle Content-Disposition: attachment
$return->content = $content;

> return $return;
> }
> 
> // Have to implement a dummy method :(
> function createZones( $layout )
> {
> return array();
> }
> }
> 
> So I override "createResponse" in my View class. But I don't know what 
> status
> to set or how to change ezcMvcResponse object to set a custom header info.
> 
> Can you help me here or point me to the documentation that will help me. 
> Also
> let me know if my approach is completely wrong :)
> 
> My Feedback:
> 
> For an abstract class, "ezcMvcView" seems to  be  too concrete. It 
> contains logic to
> work with the zones concept.
> 
> Would it make sense to have an example class to handle custom response 
> headers?
> 
> Regards,
>   Philipp
> 


-- 
Alexandru Stanoi
System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


[Components] Two proposals for extending ezcPersistentObject

2009-01-05 Thread Benjamin Eberlei

I have two proposals to extend ezcPersistentObject that i wanted to share
with
the list. Both proposals are very non-invasive to the current code of
ezcPersistentObject and offer a great chance to extend its functionality
without fiddling in the current code-basis.


1st proposal: Implement Repository Pattern

Implementation of a repository pattern in conjunction with
ezcPersistentObject
is only a very simple step and can provide a huge benefit.

Requirements of a new ezcPersistentRepository class are
ezcPersistentSession and its corresponding ezcPersistentDefinitionManager,
best implemented through a getRepository() function on the
ezcPersistentSession.

A ezcPersistentRepositoryCriteria object may be created from the repository
that allows the specification certain conditions that an object has to meet
like:

$criteria->add('person_name', 10);
$criteria->add('person_age', new
ezcPersistentCriteriaDateRange('1820-01-01', '1911-01-01'));
$repository->query($criteria);

This criteria object is given back to the repository object, which then
creates the ezcDbSelectQuery object from the criteria and the information
of the definition manager.

The resulting ezcDbSelectQuery is handed down to ezcPersistentSession and
all the matching objects are returned from the repository in an collection.
Optionally a method could be provided that returns one and only one
matching
object and throws an exception if a.) 0 b.) > 1 objects are found.

It maybe useful to proxy all other calls to repository to the persistent
session so that an application designer has the possitibilty to require
a controller to speak with the repository only.

Additionally it should be supported to extend the ezcPersistentRepository
to that any programmer can move often used queries into the repository for
convenience.

=
2nd proposal: Extended ezcPersistentObject Interface for Auto-Relation
support

An extended interface to ezcPersistentObject that offers the automatic
retrieval of related objects based on either a lazy load or a direct
loading
mechanism.

Two new functions should be required by this interface
ezcPersistentObjectWithRelations
setRelations(array $relations) and getRelations(). Set relations is given
the class name
of the related object with an collection/array of matching objects to that
relation. getRelation
retrieves the related objects for cascaded updating/inserting.

This might create some enourmous select/insert/update overhead that should
be fought by
the following mechanisms:

1.) Marker interface ezcPersistentObjectLazyLoadRelations, which when
detected returns
a ezcPersistentObjectLazyLoadCollection for all relations of the
implementing record.
The lazy load collection is given a php callback with the session object
and the required parameters to load the objects upon the first request of
the collection,
for example inside the load handler one would call:

// old code:
$object->setState($state);
// additional code to fetch related objects
$callback = array($session, 'getRelatedObjects');
$args = array($object, 'RelationName1');
$collection = new ezcPersistentObjectLazyLoadRelation($callback, $args);
$relations = array('RelationName1' => $collection1, 'RelationName2' =>
$collection2, ...);
$object->setRelations($relations);

the collection implements countable and iterator and when one of the
methods of those interfaces is called, the callback is invoked to lazy load
all the required objects. The collection also has a public method
"wasLazyLoaded()" that the persistent session might use to check wheater
the objects have been loaded at all and therefore don't have to be updated.

2.) a new interface ezcPersistentObjectModificationStatus that has a method
"wasModfied()"
with boolean return value. If the save handler of ezcPersistentObject is
invoked this interface
can be checked before inserting/updating the record.

-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


Re: [Components] eZ Components 2008.2 released

2009-01-05 Thread Derick Rethans
On Mon, 5 Jan 2009, Hans Melis wrote:

> Derick Rethans wrote:
> > 
> > The development team is happy to announce the release of the seventh 
> > major version of eZ Components: version 2008.2.
> > 
> 
> Congratulations with the release!
> 
> There's one issue though, the MvcFeedTieIn (and related autoload file)
> is missing in the downloadable archives. A quick look at the PEAR
> channel shows it's missing there too.

Yes, that's not by mistake. We found out too late that the feed tiein 
was a bit too rough to be released. It even has some hardcoded URLs in 
it. We'll be working on resolving this as one of our items on 
the highest priority list.

regards,
-- 
Derick Rethans
eZ components Product Manager
eZ systems | http://ez.no
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


Re: [Components] eZ Components 2008.2 released

2009-01-05 Thread Hans Melis
Derick Rethans wrote:
> Hello,
> 
> The development team is happy to announce the release of the seventh 
> major version of eZ Components: version 2008.2.
> 

Congratulations with the release!

There's one issue though, the MvcFeedTieIn (and related autoload file)
is missing in the downloadable archives. A quick look at the PEAR
channel shows it's missing there too.


Cheers
--
Hans
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


[Components] CSV export view

2009-01-05 Thread Philipp Kamps
Hi,

my goal is to allow my users to download a CSV export from my web
application.

In a pure PHP application I would do following:

// We'll be outputting a PDF
header('Content-type: text/csv');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="export.csv"');

What would be a good way to do it with the MVC component?

Here is what I tried so far:

class ReportsExportView extends ezcMvcView
{

function createResponse()
{
$resultBody = 'csv content';

$result = $this->result;

// set $result->status ???

$return = new ezcMvcResponse( $result->status, $result->date,
$result->generator, $result->cache, $result->cookies,
$result->content, $resultBody );

// set $return->status ???

return $return;
}

// Have to implement a dummy method :(
function createZones( $layout )
{
return array();
}
}

So I override "createResponse" in my View class. But I don't know what
status
to set or how to change ezcMvcResponse object to set a custom header info.

Can you help me here or point me to the documentation that will help me.
Also
let me know if my approach is completely wrong :)

My Feedback:

For an abstract class, "ezcMvcView" seems to  be  too concrete. It contains
logic to
work with the zones concept.

Would it make sense to have an example class to handle custom response
headers?

Regards,
  Philipp
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


[Components] MvcTools has leaky request abstraction?

2009-01-05 Thread Mike Simons
Hello all

I've recently been playing with svn r9721 MvcTools and something
struck me as odd while running through the "hello" example
implementation.

Isn't the url prefix an environment specific concern?
Surely the environment abstraction (i.e. ezcMvcHttpRequestParser)
should deal with this?

The implementation in the example would break under usage with php -r
(although I'm only using this to highlight the environmental aspect
and do not condone such fluffy kitten killing usage) as SCRIPT_NAME is
set to a single hyphen.

It strikes me that this data also probably belongs in the request
struct for purposes such as the "installRoot" usage in the example so
that logic is not duplicated.

If there is justification for deferring this responsibility to the
application I'll quite happily go crawl back under my rock :)

Thanks in advance & kind regards

Mike Simons
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components


[Components] eZ Components 2008.2 released

2009-01-05 Thread Derick Rethans
Hello,

The development team is happy to announce the release of the seventh 
major version of eZ Components: version 2008.2.

New Components

The main new development of this release is focused on the MvcTools (and 
accompanying) components.

MvcTools

The MvcTools component implements the tools for an framework. Instead of 
dedicating the structure of the application, it provides a dispatcher, 
two request parsers (one for HTTP, and one for e-mail message through 
the Mail component), two routing methods, two views handlers (one 
through plain PHP scripts, and one through the Template component) and a 
response writer for HTTP. The tools that are currently implemented, will 
in later releases be used by a Framework component.

There are currently two example applications available in the eZ 
Components SVN repository. A simple HelloMvc application, as well as a 
more advance application called TheWire that implements a twitter like 
internal-messaging system. The HelloMvc application is also described in 
the MvcTools tutorial.

Other Improvements

Main improvements in this release include support for more formats in 
the Document component and support for Webdav locking and 
authentication.

Document

The Document component enables you to convert documents between 
different formats. Previously, it would convert ReST to XHTML and 
DocBook. DocBook is intermediate format for most of the conversions. In 
this release more formats are implemented, such as three different wiki 
formats (Confluence, Creole and DokuWiki), the eZ Publish XML formats, 
as well as reading XHTML (before it could only output to XHTML) and 
writing ReST (before it could only parse ReST). The wiki parser can 
easily be extended for other wiki formats.

Webdav

The Webdav component now supports authentication and authorization as 
well as support for integration of authentication mechanisms into your 
already existing systems. In addition, it supports shared and exclusive 
write locks, even with your custom storage back-ends.

Statistics

For this release, the development team addressed 55 bugs, implemented 43 
new features and completed 14 tasks - 112 issues in total.

For the full ChangeLog, please refer to the full release announcement 
that you can find online here: 
http://ezcomponents.org/resources/news/news-2009-01-05

with kind regards,
-- 
Derick Rethans
eZ components Product Manager
eZ systems | http://ez.no
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components