Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  patch: allow table() -> none.

Guest
Posted: Fri Feb 15, 2008 4:59 am Reply with quote
Guest
This is a small patch against erlyweb-0.7 to add support for

Model:table() ->
none.

meaning that you can now have models which do not need to have a table
in the database for your model - it can be purely computational. This
patch has not be rigorously tested, but seems to work for me.

Jeff.
--

diff -aur ../erlyweb-0.7/src/erlydb/erlydb.erl erlyweb/src/erlydb/erlydb.erl
--- ../erlyweb-0.7/src/erlydb/erlydb.erl Tue Dec 25 20:34:26 2007
+++ erlyweb/src/erlydb/erlydb.erl Fri Feb 15 15:35:00 2008
@@ -385,20 +385,25 @@
{{module, Module},
{pool_id, PoolId}}})
end,
-
- case gb_trees:lookup(get_table(Module), TablesData) of
- {value, Fields} ->
- ?Debug("Generating code for ~w", [Module]),
- Options2 = DriverOptions ++ Options,
- MetaMod =
- make_module(DriverMod, C2, Fields,
- [{pool_id, PoolId} | Options2],
- TablesData),
- smerl:compile(MetaMod, Options);
+ ?Debug("get_table() -> ~p", [get_table(Module)]),
+ case get_table(Module) of
none ->
- exit(
- {no_such_table, {{module, Module},
- {table, get_table(Module)}}})
+ ok;
+ Tab ->
+ case gb_trees:lookup(Tab, TablesData) of
+ {value, Fields} ->
+ ?Debug("Generating code for ~w", [Module]),
+ Options2 = DriverOptions ++ Options,
+ MetaMod =
+ make_module(DriverMod, C2, Fields,
+ [{pool_id, PoolId} | Options2],
+ TablesData),
+ smerl:compile(MetaMod, Options);
+ none ->
+ exit(
+ {no_such_table, {{module, Module},
+ {table, get_table(Module)}}})
+ end
end;
Err ->
Err
<

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Fri Feb 15, 2008 6:50 pm Reply with quote
Guest
Do you have a gmail account by any chance? I can give you svn access
to check it in.

On Thu, Feb 14, 2008 at 9:01 PM, jm <jeffm@ghostgun.com> wrote:
>
> This is a small patch against erlyweb-0.7 to add support for
>
> Model:table() ->
> none.
>
> meaning that you can now have models which do not need to have a table
> in the database for your model - it can be purely computational. This
> patch has not be rigorously tested, but seems to work for me.
>
> Jeff.
> --
>
> diff -aur ../erlyweb-0.7/src/erlydb/erlydb.erl erlyweb/src/erlydb/erlydb.erl
> --- ../erlyweb-0.7/src/erlydb/erlydb.erl Tue Dec 25 20:34:26 2007
> +++ erlyweb/src/erlydb/erlydb.erl Fri Feb 15 15:35:00 2008
> @@ -385,20 +385,25 @@
> {{module, Module},
> {pool_id, PoolId}}})
> end,
> -
> - case gb_trees:lookup(get_table(Module), TablesData) of
> - {value, Fields} ->
> - ?Debug("Generating code for ~w", [Module]),
> - Options2 = DriverOptions ++ Options,
> - MetaMod =
> - make_module(DriverMod, C2, Fields,
> - [{pool_id, PoolId} | Options2],
> - TablesData),
> - smerl:compile(MetaMod, Options);
> + ?Debug("get_table() -> ~p", [get_table(Module)]),
> + case get_table(Module) of
> none ->
> - exit(
> - {no_such_table, {{module, Module},
> - {table, get_table(Module)}}})
> + ok;
> + Tab ->
> + case gb_trees:lookup(Tab, TablesData) of
> + {value, Fields} ->
> + ?Debug("Generating code for ~w", [Module]),
> + Options2 = DriverOptions ++ Options,
> + MetaMod =
> + make_module(DriverMod, C2, Fields,
> + [{pool_id, PoolId} | Options2],
> + TablesData),
> + smerl:compile(MetaMod, Options);
> + none ->
> + exit(
> + {no_such_table, {{module, Module},
> + {table, get_table(Module)}}})
> + end
> end;
> Err ->
> Err
> <
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Thu Feb 21, 2008 3:13 am Reply with quote
Guest
Yariv Sadan wrote:
> Do you have a gmail account by any chance? I can give you svn access
> to check it in.

Not at the moment. Google may know me by this email address though. I
don't know if that's applicable. Worse comes to worse, I'll just have to
get yet another account.


Jeff.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum