覆盖 Orchard CMS 中的连接字符串(来自 settings.txt)

发布于 2025-01-04 16:09:22 字数 526 浏览 3 评论 0原文

我在 AppHarbor 中部署了一个使用 MS SQL 数据库的网站。 AppHarbor 为我提供了一个在 settings.txt 中输入的连接字符串,它似乎工作正常,但 AppHarbor 建议使用 SQLSERVER_CONNECTION_STRING 变量。

这是因为连接字符串可能会在没有通知的情况下发生更改,因此唯一安全的方法是使用提到的变量。

应该访问下面的配置变量 以编程方式,因为附加组件提供商可能会更新这些值 恕不另行通知。

有没有办法覆盖 settings.txt 中的 DataConnectionString 设置并将应用程序设置为使用 SQLSERVER_CONNECTION_STRING 变量?我假设 AppHarbor 以某种方式将这些变量设置为 appSettings。

PS这是我第一次使用Orchard应用程序,我不熟悉这个CMS。

I deployed a web site in AppHarbor which uses a MS SQL database. AppHarbor provides me with a connection string which I entered in settings.txt and it seems to work fine BUT AppHarbor suggests to use the SQLSERVER_CONNECTION_STRING variable instead.

That is because the connection string may change without notice so the only safe way is to use the variable mentioned.

Accessing the configuration variables below should be done
programatically, as the values may be updated by the add-on provider
without notice.

Is there a way to override the DataConnectionString setting from settings.txt and set the application to use the SQLSERVER_CONNECTION_STRING variable instead? I assume AppHarbor somehow sets those variables as appSettings.

P.S. This is my first application with Orchard, I am not proficient with this CMS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苦行僧 2025-01-11 16:09:22

连接字符串在 ShellSettingsManager 类中设置。我不确定您是否可以轻松地从模块中替换此依赖项,但您当然可以更改设置连接字符串的代码行...

shellSettings.DataConnectionString = value;  //use your config value instead

ShellSettingsManager 是 IShellSettingsManager 的实现,因此如果您只想也实现你自己的。

The connection string is set in the ShellSettingsManager class. I'm not sure you can easily replace this dependency from a module, but you could certainly just change the line of code that sets the connections string...

shellSettings.DataConnectionString = value;  //use your config value instead

ShellSettingsManager is an implementation of IShellSettingsManager so you have some flexibility there if you want to just implement your own too.

翻身的咸鱼 2025-01-11 16:09:22

我刚刚将我的“Configuration Shell Settings” 模块 (Fineout.ConfigShellSettings) 发布到 Orchard Gallery。该模块最终提供了一种通过配置管理来管理 Orchard 站点(租户)shell 设置的轻松方法。

下载Orchard Gallery 中的 Configuration Shell 设置模块!

我复制了下面的模块包描述(版本 1.0.1):

允许通过配置应用程序设置(即“Web.config”而不是“Settings.txt”)指定租户的 Orchard shell 设置。这允许通过构建配置管理来控制站点(租户)设置,从而大大简化大多数环境和基础设施的构建和部署过程。

启用该功能后,所有租户的现有 shell 设置将从各自的“Settings.txt”文件复制到“Orchard.Web/Web.config”中定义的 AppSettings 中。同样,每当禁用该功能时,为所有租户定义的现有 AppSettings 将被复制回各自的“Settings.txt”文件。这样就可以管理该功能,而无需任何手动文件操作或代码更改。

由于这是该模块的初始版本,我预计会有很大的改进空间和偶尔的错误;我很乐意接受任何人的反馈或想法。我希望这一贡献对社区有用且节省时间。

I've just published my "Configuration Shell Settings" module (Fineout.ConfigShellSettings) to the Orchard Gallery. This module finally provides a painless way to manage Orchard site (tenant) shell settings via configuration management.

Download the Configuration Shell Settings module from the Orchard Gallery!

I've copied the module package description (version 1.0.1) below:

Allows Orchard shell settings for tenants to be specified through configuration application settings, i.e. "Web.config" instead of "Settings.txt". This allows site (tenant) settings control via build configuration management, considerably simplifying the build and deploy process for most environments and infrastructures.

Upon enabling the feature, existing shell settings for all tenants will be copied from respective "Settings.txt" files into AppSettings defined in "Orchard.Web/Web.config". Likewise, whenever the feature is disabled, existing AppSettings defined for all tenants will be copied back to the respective "Settings.txt" files. This allows the feature to be managed without any need for any manual file manipulation or code changes.

As this is the initial version of the module, I expect there will be plenty of room for improvement and the occasional bug; I'd love any feedback or ideas anyone has. I hope this contribution will prove useful and time-saving for the community.

痕至 2025-01-11 16:09:22

将 Orchard 部署到 Appharbor 可能不值得。 Appharbor 在进行部署时会清除整个应用程序,因此上传的媒体也会被清除。您可以通过将媒体文件夹托管在其他地方(例如 amazon s3)来解决此问题。

但您也无法通过 FTP 访问日志文件或其他任何内容。 (至少不是我上次看的时候)。

另外你不能利用网络部署。

您可以让它工作,但果园架构与 appharbor 的部署模型产生了很大的摩擦。

别误会我的意思。我爱阿法伯。但果园是方形的。我的视力在 appharbor 上工作,但 4 个月后我发现我害怕更新,因为太多非默认设置。最后,我认输了,每月在arvixe支付8美元。现在摩擦少多了。

Deploying orchard to appharbor might not be worth the effort. Appharbor wipes out the entire app when doing a deploy so uploaded media gets wiped out too. You can get around this by hosting the media folder somewhere else, like amazon s3.

But you also don't have FTP access to log files or anything else. (at least not the last time I looked).

Plus u can't take advantage of web deploy.

You can make it work but orchards architecture creates much friction with appharbor's deployment model.

Don't get me wrong. I love appharbor. But orchard is square peg. I got my sight working on appharbor but 4 months later I found I was afraid to update because too many non default settings. Finally, threw in towel and paid $8 per month at arvixe. Much less friction now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文