[Seaside] Ideas worth stealing

Todd Blanchard tblanchard at mac.com
Sun Jun 1 18:45:32 UTC 2008

That is an interesting question - I've taken a run with magritte once  
or twice and did not make satisfactory progress and abandoned it.

I found the method of defining the meta model in magritte to be rather  
ponderous and awkward.

Not that it isn't expressive, but I don't know all the parts/mappings/ 
kinds of things - I spent all this time looking at the docs or  
examples.  Also the documentation is non-existent.  Really, if you  
want to get people to use magritte - STOP CODING AND START DOCUMENTING  
- I don't have time to figure it out from the examples or pier or any  
running code.  I want docs and code snippets I can steal and modify. I  
want them in a nicely indexed web site so I can find a solution to my  
exact problem using google in about sixty seconds.

Note website for activescaffold: http://activescaffold.com
Click on documentation.  Wow, everything I need to know right there.   
Brilliant. Where is the equivalent resource for Magritte?  Google  
couldn't find it.

Most of what you need to define the magritte model is already in the  
database schema - so can magritte just infer the fields and let me  
just customize it's behavior?

The missing part in the database is the mapping of widgets and the  
order or presentation of fields.

In the system I am doing (sells tickets to a new museum) there is

Order->OrderTransactions (subclassed to Purchase,Exchange,Return)- 
 >Tickets (actually two relations - tickets added, tickets removed)

The code to get a fully functioning back office/admin UI to edit this  
entire network is below - there's very little of it.  Most of the code  
is just to customize elements - change labels for columns, change  
column order, suppress presentation of some columns or relationships.

Why I picked Rails:

1) I already had an existing mysql database I had to use.
2) Client wanted a technology with a large local pool of talent he  
could hire - robotcoop is nearby (spinoff of amazon.com) - they are  
all rails and it is easy to hire people from there
3) I had a lot of UI that is back office and can be kind of ugyly/auto- 
generated and only a little public UI (ticket purchase flow)
4) Rails has a number of scalable deployment recipes available - I'm  
using apache->mongrel cluster.   I will add capistrano to automate  
upgrade deployments
5) I'm replacing an equivalent system written in a nightmare  
combination of Java/Hibernate/Cocoon-js/xml-xslt/tomcat that nobody  
wants to maintain.  I can't learn that many languages - but I most  
certainly can steal/translate logic and templates - it was easy to  
translate jsp to rhtml templates.

For your amusement - the entirety of the order/ordertransaction/ticket  
code is below - it does a two level master-detail view with ajax  
updates in a single page.  It took me almost no time at all to get  
this working and the majority of the code you see is just appearance  
tweaks or action disabling.

#model - (all of it - really)
class Order < ActiveRecord::Base
     set_table_name 'orders'
     has_many :order_transactions, :class_name =>  
'OrderTransaction', :foreign_key => 'order_id', :dependent => :destroy
     belongs_to :purchaseTransaction, :class_name =>  
'TicketPurchase', :foreign_key => 'purchaseTransaction'

class OrderTransaction < ActiveRecord::Base
     has_many :ticketsReturned, :class_name => 'Ticket', :foreign_key  
=> 'returnTransaction', :include => [:price, :product], :dependent  
=> :destroy, :order => 'sequence_number'
     has_many :ticketsAdded, :class_name => 'Ticket', :foreign_key =>  
'originatingTransaction', :include => [:price, :product], :dependent  
=> :destroy, :order => 'sequence_number'

class TicketPurchase <  OrderTransaction

class TicketExchange <  OrderTransaction

class TicketReturn <  OrderTransaction

class Ticket < ActiveRecord::Base

#controllers - tops is most complicated - remove create update and  
delete abilities - add some action links (all of it)
class Admin::OrderController < AdminController
     layout "admin"
     active_scaffold :orders do | config |
       config.actions.exclude :delete
       config.actions.exclude :update
       config.actions.exclude :create
       config.action_links.add :resend_email, :label => 'Resend  
Email', :type => :record, :position => false, :confirm => 'Resend  
purchase confirmation email?'
       config.action_links.add :exchange_tickets, :label => 'Exchange  
Tickets', :type => :record, :position => :after, :crud_type => :update
       config.action_links.add :refund_tickets, :label => 'Refund  
Tickets', :type => :record, :position => :after, :crud_type => :update
         list.sorting = {:date => 'ASC'}
         config.list.columns =  
, :commissionAccount 
, :nameFirst, :nameLast, :emailAddress, :order_transactions]
         config.list.per_page = 100
         config.columns =  
, :commissionAccount 
, :nameFirst 
, :nameLast 
, :emailAddress 
, :address1 
, :address2, :city, :state, :zip, :country, :order_transactions]

class Admin::OrderTransactionController < AdminController
   layout "admin"
   active_scaffold :order_transaction do | config |
     config.list.columns =  
, :type, :channel, :payment, :credit, :ticketsAdded, :ticketsReturned]
     config.actions.exclude :delete
     config.actions.exclude :update
     config.actions.exclude :create

class Admin::TicketController < AdminController
   layout "admin"
   active_scaffold :ticket do | config |
     config.list.columns =  
, :validForDate 
, :product, :price, :status, :purchasePrice, :serviceCharge, :order]
     config.list.per_page = 100
     list.sorting = {:validForDate => 'ASC'}
     columns[:validForDate].label = "Date"
     columns[:product].label = "Description"
     columns[:price].label = "Ticket"
     columns[:purchasePrice].label = "Price"
     columns[:serviceCharge].label = "Service Charge"
     config.actions.exclude :delete
     config.actions.exclude :update
     config.actions.exclude :create

#views - auto-generated - no code at all

On Jun 1, 2008, at 12:47 AM, stephane ducasse wrote:

> todd
> do you think that magritte could help there?
> Stef
> On May 31, 2008, at 1:04 AM, Todd Blanchard wrote:
>> I watched the screencast.  It is not the same thing.  I think you  
>> guys are missing something key in that project of yours.
>> Active scaffold simply lets me point the app at a db and ZAM total  
>> admin UI that looks nice with AJAX master detail editing.  I can  
>> then filter out attributes that people ought not to edit, apply  
>> permissions, and decorate the app with task links.
>> The demo shows app development.  I didn't develop a thing apart  
>> from specify some mappings because the database used weird and  
>> inconsistent naming conventions.
>> I also found it interesting that the app being developed in the  
>> screencast didn't look nearly as sophisticated as the tools being  
>> used to build it.  I don't find that a good selling point.
>> -Todd Blanchard
>> On May 30, 2008, at 4:28 AM, James Robertson wrote:
>>> Cincom is doing exactly that - combining the ActiveRecord pattern  
>>> with scaffolding.  Have a look here:
>>> http://www.cincomsmalltalk.com/userblogs/mls/blogView?showComments=true&printTitle=WebVelocity_alpha_screencast&entry=3388846573
>>> James Robertson
>>> Cincom Smalltalk Product Evangelist
>>> http://www.cincomsmalltalk.com/blog/blogView
>>> Talk Small and Carry a Big Class Library
>>> On May 30, 2008, at 3:13 AM, Todd Blanchard wrote:
>>>> With the idea that no good idea should go un-stolen, allow me to  
>>>> introduce seaside fans to active scaffold http:// 
>>>> activescaffold.com.
>>>> I am wrapping up a ruby on rails engagement with a client and  
>>>> discovered this framework.  I ended up using ROR because the  
>>>> client had an existing mysql database and Squeak's mysql support  
>>>> isn't so hot where rails is all about mysql, and I had only a  
>>>> couple "flows" but a whole lot of plain old admin-CRUD to do and  
>>>> rails excels at plain crud on mysql.  With activescaffold - I had  
>>>> to write very little code for the admin UI - a major plus because  
>>>> this project is on a very tight timeline.
>>>> Anyhow, activescaffold works with activerecord and infers a  
>>>> really slick AJAX UI that supports sensible CRUD more or less  
>>>> instantly.  Once installed, you can go through and customize  
>>>> views by adding actions links, filtering columns, and generally  
>>>> overriding bits of logic to make it more task focused.
>>>> It would be really cool to have a similar facility in Seaside.
>>>> Cheers,
>>>> -Todd Blanchard
>>>> _______________________________________________
>>>> seaside mailing list
>>>> seaside at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>> _______________________________________________
>>> seaside mailing list
>>> seaside at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20080601/dfd259f1/attachment-0001.htm

More information about the seaside mailing list