[Cubicweb] some cubicweb goals for 2010

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Apr 26 13:55:51 CEST 2010


On 26 avril 13:19, Nicolas Chauvat wrote:
> Syvlain,
> 
> Your time-machine seems to work really well. Would you lend it to me ?
> I have a couple things I would like to fix in my past.
> 
> On Mon, Apr 26, 2010 at 12:36:36PM +0200, Sylvain Thénault wrote:
> > >   project = _cw.entity_from_eid(1234)
> > >   tickets = project.reverse_done_in
> > >   self.wview('table', tickets, 'null')
> > 
> >    project = _cw.entity_from_eid(1234)
> >    self.wview('table', project.related('done_in', 'object', 'null'))
> 
> Shouldn't project.reverse_done_in return the same thing as
> project.related(..) then ?

imo that's fine now, becuase we would then need 
 "project.reverse_done_in.entities()" which loose readability.

> > we already to such kind of things heavily, using the rql st api. There
> > are already high level methods to do things such as adding a restriction
> > (could be improved though).
> > 
> >    project = _cw.entity_from_eid(1234)
> >    rset = project.related('done_in', 'object', 'null')
> >    union = rset.syntax_tree().children[0] # first Union node
> >    self.add_constant_restriction(union.get_variable('X'), 'type', 'bug', 'String')
> >    rql = union.as_string()
> 
> This would deserve a proper thread, but here are a couple comments:
> 
> * does rset.syntax_tree() really need to be a method ?

it's a method to inform that's not an attribute ;) The syntax tree
has to be created (copied/parsed, but that's internal you don't have
to care about).
 
> * does self.add_constant_restriction(...) really have to be a method
>   of self, I would expect to find it on the syntax_tree object or on
>   a RQLHandler object that would manipulate the syntax_tree as in
> 
>     project = _cw.entity_from_eid(1234)
>     rset = project.related('done_in', 'object', 'null')
>     tree = rset.syntax_tree
>     tree.add_constant_restriction(tree.children[0].get_variable('X'), 'type', 'bug', 'String')
>     rql = tree.as_string()
> 
> or
>     project = _cw.entity_from_eid(1234)
>     rset = project.related('done_in', 'object', 'null')
>     handler = RQLHandler(rset.syntax_tree)
>     handler.add_constant_restriction(tree.children[0].get_variable('X'), 'type', 'bug', 'String')
>     rql = tree.as_string()

are you pinailling ? :p
IMO yes it makes sense as a method, since the node is the context
on which you want to add something.

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org




More information about the Cubicweb mailing list