Skip to content

Commit

Permalink
Call load_tpl on startup automatically
Browse files Browse the repository at this point in the history
Improvement suggested by Denis Ibaev
  • Loading branch information
Krzysztof Goj committed Jul 1, 2010
1 parent c9379ef commit c70cfe9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions doc/NEXT_RELEASE
@@ -0,0 +1,8 @@
1.4.2
=====

* wpart_my_primitive_type:load_tpl() is called automatically for
all user-defined primitive types on application startup.
- you don't have to do it yourself anymore
- make sure that you implement load_tpl
(it's required by wpart behaviour, anyway)
16 changes: 8 additions & 8 deletions lib/wpart-1.4.1/src/wpart_app.erl
Expand Up @@ -52,17 +52,17 @@ init([]) ->
%% Internal functions %% Internal functions
%%==================================================================== %%====================================================================


-spec(ets_tables_install/0 :: () -> ok). -spec(ets_tables_install/0 :: () -> ok).
ets_tables_install() -> ets_tables_install() ->
{ok, [TypesT]} = file:consult(filename:join([code:priv_dir(wparts),"basic_types.conf"])), {ok, [TypesT]} = file:consult(filename:join([code:priv_dir(wparts),"basic_types.conf"])),
Types = tuple_to_list(TypesT), Types = tuple_to_list(TypesT) ++ e_conf:primitive_types(),
ets:insert(e_conf, {primitive_types, Types ++ e_conf:primitive_types()}), ets:insert(e_conf, {primitive_types, Types}),

catch ets:delete(templates), catch ets:delete(templates),
ets:new(templates, [named_table, public]), ets:new(templates, [named_table, public]),

Additional = [form, derived, input], Additional = [form, derived, input],
lists:foreach(fun(Type) -> lists:foreach(fun(Type) ->
Mod = list_to_atom("wpart_" ++ atom_to_list(Type)), Mod = list_to_atom("wpart_" ++ atom_to_list(Type)),
Mod:load_tpl() end, Mod:load_tpl() end,
Types ++ Additional). Types ++ Additional).

0 comments on commit c70cfe9

Please sign in to comment.