众所周知(或应该),您可以使用Django的模板系统来呈现电子邮件正文:
def email(email, subject, template, context):
from django.core.mail import send_mail
from django.template import loader, Context
send_mail(subject, loader.get_template(template).render(Context(context)), 'from@domain.com', [email,])
Run Code Online (Sandbox Code Playgroud)
这有一个缺陷:要编辑电子邮件的主题和内容,您必须编辑视图和模板.虽然我可以证明给管理员用户访问模板是合理的,但我并没有让他们访问原始的python!
真正酷的是,如果您可以在电子邮件中指定块并在发送电子邮件时单独将它们拉出来:
{% block subject %}This is my subject{% endblock %}
{% block plaintext %}My body{% endblock%}
{% block html %}My HTML body{% endblock%}
Run Code Online (Sandbox Code Playgroud)
但是你会怎么做?你会如何一次只渲染一个块?
如何在Oracle中查看打开的事务?我正在做自定义性能工具,我想查看当前打开的事务的数量.是否有SQL请求要这样做,或采用其他方式来收集此信息?
问题是以下问题:在我的一个活动中,我需要为我的操作栏设置一个自定义布局,而且只需要在我的屏幕上设置一个透明的ActionBar就可以了.为此,我将ActionBar标记为叠加,并将操作栏背景指定为透明.这在使用Android> = 15时有效,但在14及以下,ActionBar保持其底部边框.我试了一下去除它,但没有用.
这是一张更清晰的图片:
在API 14上:

在API 16上:

设计如下:Action Bar应该是透明的并且处于叠加模式,并且在它后面有一个背景+徽标
<ImageView
android:id="@+id/action_bar_background"
android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:contentDescription="@string/action_bar"
android:scaleType="fitXY"
android:src="@drawable/actionbar_logo_extended" />
<ImageView
android:id="@+id/home_gallica_logo"
android:layout_width="@dimen/largeur_logo_carrousel"
android:layout_height="@dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/action_bar"
android:src="@drawable/logo_fullcolor" />
Run Code Online (Sandbox Code Playgroud)
一些准确性:我使用ABS,但这似乎不是问题的根源,因为切换到v7支持库做了完全相同的事情.
有谁知道如何删除这个底部边框?
我使用的是vim并且有一个大文本文件,其中包含一些在throoghout中抛出的html.我正在尝试为网络准备它,并需要将<p></p>标签添加到尚未格式化的行.这是我的一个例子:
Paragraph text one one line [... more ... ]
Other paragraph text on the next line [... more ... ]
<h1>html element thrown in on its own line</h1>
More paragraph text [... more ... ]
<!-- some other element (always own line) -->
There is still more text!
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种方法来搜索不以<字符开头的行,对于这些行,添加开始和结束<p></p>标记...以便之后,我的文件类似于:
<p>Paragraph text one one line [... more ... ] </p>
<p>Other paragraph text on the next line [... more ... …Run Code Online (Sandbox Code Playgroud) 最近我开始探索Officebean库,换句话说,我试图让一个简单的OOoBean示例运行.不幸的是,我没有得到任何进展.
首先,我尝试使用JPanel和bean内部构建Swing JFrame,但窗口内没有显示任何内容.
public class OpenOfficeGUI extends JFrame
{
private OOoBean ooBeanObj = null;
private OfficeConnection ooConnection = null;
public OpenOfficeGUI()
{
init();
}
private void init()
{
JPanel panel = new JPanel();
JButton myButton = new JButton("Arsch");
ooBeanObj = new OOoBean();
myButton.setSize(100, 32);
panel.setSize(800, 500);
panel.setLocation(5, 5);
panel.setBackground(new Color(125, 125, 125));
panel.add(ooBeanObj);
panel.add(myButton);
panel.setLayout(null);
this.add(panel);
this.setSize(800, 600);
this.setLocation(0, 0);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
Run Code Online (Sandbox Code Playgroud)
我的第二次尝试是SWT应用程序,显示在eclipsezone.com(http://www.eclipsezone.com/eclipse/forums/t48966.html).我让这个东西运行,但在启动时出现"com.sun.star.comp.beans.NoConnectionException".
我的第三次也是最后一次尝试是OpenOffice Wiki的OOoBeanViewer.因此,我发现了一个博客文章,它似乎解决了上面的ConnectionException,但它也没有运行,并出现相同的Exception.
我还尝试通过执行以下命令在"侦听"模式下手动启动OpenOffice: soffice.exe -bean -accept = pipe,name = login.name_Office; urp; StarOffice.NamingService …
我刚开始在Android上学习google-api-java-client.将下3个库添加到项目中.(我不使用Maven.)
并选择了可供使用的示例代码.在示例中,它使用了GoogleTransport,现在似乎无法使用.
HttpTransport transport = GoogleTransport.create();
Run Code Online (Sandbox Code Playgroud)
所以我把它改成了在网上找到的NetHttpTransport().
import com.google.api.client.http.javanet.NetHttpTransport;
...
HttpTransport transport = new NetHttpTransport();
Run Code Online (Sandbox Code Playgroud)
但是,我得到了例外.
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): java.lang.NoClassDefFoundError: com.google.common.base.Preconditions
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:324)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.ClassInfo.of(ClassInfo.java:77)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.GenericData.<init>(GenericData.java:44)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.HttpHeaders.<init>(HttpHeaders.java:37)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.HttpTransport.<init>(HttpTransport.java:82)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.javanet.NetHttpTransport.<init>(NetHttpTransport.java:35)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at net.DailyTimer.test.MainActivity.onCreate(MainActivity.java:290)
Run Code Online (Sandbox Code Playgroud)
这有什么问题?
我使用JDBC(mysql数据库)编写Java程序。当我违反 mysql 完整性(fe 我尝试插入相同的主键值)时,我会捕获SQL 异常。 我应该以它可能永远不会发生的方式编写它(首先是布尔函数检查主键值是否已经存在于数据库中,然后调用插入),还是可以仅通过异常处理它?例子 :
catch (SQLException ex) {ex.printStackTrace(); showSomeErrorDialog(); }
Run Code Online (Sandbox Code Playgroud) 我正在尝试从连接到我的机器的外部蓝牙加密狗读取数据,只要它从java中的任何其他蓝牙设备接收数据.我不知道如何实现这一点.如果有人知道如何做到这一点,请帮助我.
我的JSlider有点问题,我无法解决.为了解释一下这种情况,我必须做一个JSlider,从0到20,经过0.1步.我通过创建一个从0到200的JSlider来解决问题,并重新定义滑块下的标签以显示相应的百分比而不是整数值.
但我有一个最后的问题:我正在使用自定义L&F(我无法更改,显然,因为它来自客户端),它显示滑块拇指上的值.但是,此值以标准方式显示为整数.从我能够掌握的,这个显示与Slider.paintValue属性有关,正如我在javax.swing.plaf.synth.SynthSliderUI源代码中看到的那样.但是,我一直无法将其删除.
我现在尝试过的:
UIManager.getLookAndFeelDefaults().put("Slider.paintValue", false);
UIManager.put("Slider.paintValue", false);
Run Code Online (Sandbox Code Playgroud)
这两个都没有改变任何东西.
周围有一个Swing大师谁可以让我离开这个?